PebbloRetrievalAPIWrapper#
- class langchain_community.chains.pebblo_retrieval.utilities.PebbloRetrievalAPIWrapper[source]#
Bases:
BaseModel
Wrapper for Pebblo Retrieval API.
Validate that api key in environment.
- param api_key: str | None = None#
API key for Pebblo Cloud
- param classifier_location: str = 'local'#
Location of the classifier, local or cloud. Defaults to βlocalβ
- param classifier_url: str | None = None#
URL of the Pebblo Classifier
- param cloud_url: str | None = None#
URL of the Pebblo Cloud
- async acheck_prompt_validity(question: str) Tuple[bool, Dict[str, Any]] [source]#
Check the validity of the given prompt using a remote classification service.
This method sends a prompt to a remote classifier service and return entities present in prompt or not.
- Parameters:
question (str) β The prompt question to be validated.
- Returns:
True if the prompt is valid (does not contain deny list entities), False otherwise. dict: The entities present in the prompt
- Return type:
bool
- async static amake_request(method: str, url: str, headers: dict, payload: dict | None = None, timeout: int = 20) Any [source]#
Make a async request to the Pebblo server/cloud API.
- Parameters:
method (str) β HTTP method (GET, POST, PUT, DELETE, etc.).
url (str) β URL for the request.
headers (dict) β Headers for the request.
payload (Optional[dict]) β Payload for the request (for POST, PUT, etc.).
timeout (int) β Timeout for the request in seconds.
- Returns:
Response json if the request is successful.
- Return type:
Any
- async asend_prompt(app_name: str, retriever: VectorStoreRetriever, question: str, answer: str, auth_context: AuthContext | None, docs: List[Document], prompt_entities: Dict[str, Any], prompt_time: str, prompt_gov_enabled: bool = False) None [source]#
Send prompt to Pebblo server for classification. Then send prompt to Daxa cloud(If api_key is present).
- Parameters:
app_name (str) β Name of the app.
retriever (VectorStoreRetriever) β Retriever instance.
question (str) β Question asked in the prompt.
answer (str) β Answer generated by the model.
auth_context (Optional[AuthContext]) β Authentication context.
docs (List[Document]) β List of documents retrieved.
prompt_entities (Dict[str, Any]) β Entities present in the prompt.
prompt_time (str) β Time when the prompt was generated.
prompt_gov_enabled (bool) β Whether prompt governance is enabled.
- Return type:
None
- build_prompt_qa_payload(app_name: str, retriever: VectorStoreRetriever, question: str, answer: str, auth_context: AuthContext | None, docs: List[Document], prompt_entities: Dict[str, Any], prompt_time: str, prompt_gov_enabled: bool = False) dict [source]#
Build the QA payload for the prompt.
- Args:
app_name (str): Name of the app. retriever (VectorStoreRetriever): Retriever instance. question (str): Question asked in the prompt. answer (str): Answer generated by the model. auth_context (Optional[AuthContext]): Authentication context. docs (List[Document]): List of documents retrieved. prompt_entities (Dict[str, Any]): Entities present in the prompt. prompt_time (str): Time when the prompt was generated. prompt_gov_enabled (bool): Whether prompt governance is enabled.
- Returns:
The QA payload for the prompt.
- Return type:
dict
- Parameters:
app_name (str) β
retriever (VectorStoreRetriever) β
question (str) β
answer (str) β
auth_context (AuthContext | None) β
docs (List[Document]) β
prompt_entities (Dict[str, Any]) β
prompt_time (str) β
prompt_gov_enabled (bool) β
- check_prompt_validity(question: str) Tuple[bool, Dict[str, Any]] [source]#
Check the validity of the given prompt using a remote classification service.
This method sends a prompt to a remote classifier service and return entities present in prompt or not.
- Parameters:
question (str) β The prompt question to be validated.
- Returns:
True if the prompt is valid (does not contain deny list entities), False otherwise. dict: The entities present in the prompt
- Return type:
bool
- static make_request(method: str, url: str, headers: dict, payload: dict | None = None, timeout: int = 20) Response | None [source]#
Make a request to the Pebblo server/cloud API.
- Parameters:
method (str) β HTTP method (GET, POST, PUT, DELETE, etc.).
url (str) β URL for the request.
headers (dict) β Headers for the request.
payload (Optional[dict]) β Payload for the request (for POST, PUT, etc.).
timeout (int) β Timeout for the request in seconds.
- Returns:
Response object if the request is successful.
- Return type:
Optional[Response]
- send_app_discover(app: App) None [source]#
Send app discovery request to Pebblo server & cloud.
- Parameters:
app (App) β App instance to be discovered.
- Return type:
None
- send_prompt(app_name: str, retriever: VectorStoreRetriever, question: str, answer: str, auth_context: AuthContext | None, docs: List[Document], prompt_entities: Dict[str, Any], prompt_time: str, prompt_gov_enabled: bool = False) None [source]#
Send prompt to Pebblo server for classification. Then send prompt to Daxa cloud(If api_key is present).
- Parameters:
app_name (str) β Name of the app.
retriever (VectorStoreRetriever) β Retriever instance.
question (str) β Question asked in the prompt.
answer (str) β Answer generated by the model.
auth_context (Optional[AuthContext]) β Authentication context.
docs (List[Document]) β List of documents retrieved.
prompt_entities (Dict[str, Any]) β Entities present in the prompt.
prompt_time (str) β Time when the prompt was generated.
prompt_gov_enabled (bool) β Whether prompt governance is enabled.
- Return type:
None