From 3c7653bf0f68c15067839c5a2a8761bd04fd367f Mon Sep 17 00:00:00 2001 From: Ofer Mendelevitch Date: Thu, 5 Oct 2023 17:04:14 -0700 Subject: [PATCH] "source" argument in constructor of Vectara (#11454) Replace this entire comment with: - **Description:** minor update to constructor to allow for specification of "source" - **Tag maintainer:** @baskaryan - **Twitter handle:** @ofermend --- libs/langchain/langchain/vectorstores/vectara.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libs/langchain/langchain/vectorstores/vectara.py b/libs/langchain/langchain/vectorstores/vectara.py index cb390780a7a..ed3ffedf66d 100644 --- a/libs/langchain/langchain/vectorstores/vectara.py +++ b/libs/langchain/langchain/vectorstores/vectara.py @@ -39,6 +39,7 @@ class Vectara(VectorStore): vectara_corpus_id: Optional[str] = None, vectara_api_key: Optional[str] = None, vectara_api_timeout: int = 60, + source: Optional[str] = "langchain", ): """Initialize with Vectara API.""" self._vectara_customer_id = vectara_customer_id or os.environ.get( @@ -59,6 +60,8 @@ class Vectara(VectorStore): ) else: logger.debug(f"Using corpus id {self._vectara_corpus_id}") + self._source = source + self._session = requests.Session() # to reuse connections adapter = requests.adapters.HTTPAdapter(max_retries=3) self._session.mount("http://", adapter) @@ -74,7 +77,7 @@ class Vectara(VectorStore): "x-api-key": self._vectara_api_key, "customer-id": self._vectara_customer_id, "Content-Type": "application/json", - "X-Source": "langchain", + "X-Source": self._source, } def _delete_doc(self, doc_id: str) -> bool: