pw.xpacks.llm.servers
class pw.xpacks.llm.servers.DocumentStoreServer(host, port, document_store, **rest_kwargs)
[source]Creates a REST Server for answering queries to a given instance of DocumentStore
.
It exposes three endpoints:
/v1/retrieve
which is answered usingretrieve
method,/v1/statistics
which is answered usingstatistics
method,/v1/inputs
which is answered usinglist_documents
method,
- Parameters
- host (
-
) – host on which server will run - port (
-
) – port on which server will run - document_store (
-
) – instance ofDocumentStore
which is used to answer queries received in the endpoints. - rest_kwargs (
-
) – optional kwargs to be passed topw.io.http.rest_connector
- host (
run(threaded=False, with_cache=True, cache_backend=pw.persistence.Backend.filesystem('./Cache'), *args, **kwargs)
sourceStart the app with cache configs. Enabling persistence will cache the embedding, and LLM requests between the runs.
class pw.xpacks.llm.servers.QARestServer(host, port, rag_question_answerer, **rest_kwargs)
[source]Creates a REST Server for answering queries to a given instance of BaseQuestionAnswerer
.
It exposes four endpoints:
/v1/retrieve
which is answered usingretrieve
method,/v1/statistics
which is answered usingstatistics
method,/v1/pw_list_documents
which is answered usinglist_documents
method,/v1/pw_ai_answer
which is answered usinganswer_query
method,
- Parameters
- host (
-
) – host on which server will run - port (
-
) – port on which server will run - rag_question_answerer (
-
) – instance ofBaseQuestionAnswerer
which is used to answer queries received in the endpoints. - rest_kwargs (
-
) – optional kwargs to be passed topw.io.http.rest_connector
- host (
run(threaded=False, with_cache=True, cache_backend=pw.persistence.Backend.filesystem('./Cache'), *args, **kwargs)
sourceStart the app with cache configs. Enabling persistence will cache the embedding, and LLM requests between the runs.
class pw.xpacks.llm.servers.QASummaryRestServer(host, port, rag_question_answerer, **rest_kwargs)
[source]Creates a REST Server for answering queries to a given instance of SummaryQuestionAnswerer
.
It exposes five endpoints:
/v1/retrieve
which is answered usingretrieve
method,/v1/statistics
which is answered usingstatistics
method,/v1/pw_list_documents
which is answered usinglist_documents
method,/v1/pw_ai_answer
which is answered usinganswer
method,/v1/pw_ai_summary
which is answered usingsummarize_query
method.
- Parameters
- host (
-
) – host on which server will run - port (
-
) – port on which server will run - rag_question_answerer (
-
) – instance ofSummaryQuestionAnswerer
which is used to answer queries received in the endpoints. - rest_kwargs (
-
) – optional kwargs to be passed topw.io.http.rest_connector
- host (
run(threaded=False, with_cache=True, cache_backend=pw.persistence.Backend.filesystem('./Cache'), *args, **kwargs)
sourceStart the app with cache configs. Enabling persistence will cache the embedding, and LLM requests between the runs.