`Vectara API` vector store. See (https://vectara.com). Example: .. code-block:: python from langchain_community.vectorstores import Vectara vectorstore = Vectara( vectara_customer_id=vectara_customer_id, vectara_corpus_id=v
| 166 | |
| 167 | |
| 168 | class Vectara(VectorStore): |
| 169 | """`Vectara API` vector store. |
| 170 | |
| 171 | See (https://vectara.com). |
| 172 | |
| 173 | Example: |
| 174 | .. code-block:: python |
| 175 | |
| 176 | from langchain_community.vectorstores import Vectara |
| 177 | |
| 178 | vectorstore = Vectara( |
| 179 | vectara_customer_id=vectara_customer_id, |
| 180 | vectara_corpus_id=vectara_corpus_id, |
| 181 | vectara_api_key=vectara_api_key |
| 182 | ) |
| 183 | """ |
| 184 | |
| 185 | def __init__( |
| 186 | self, |
| 187 | vectara_customer_id: Optional[str] = None, |
| 188 | vectara_corpus_id: Optional[str] = None, |
| 189 | vectara_api_key: Optional[str] = None, |
| 190 | vectara_api_timeout: int = 120, |
| 191 | source: str = "langchain", |
| 192 | ): |
| 193 | """Initialize with Vectara API.""" |
| 194 | self._vectara_customer_id = vectara_customer_id or os.environ.get( |
| 195 | "VECTARA_CUSTOMER_ID" |
| 196 | ) |
| 197 | self._vectara_corpus_id = vectara_corpus_id or os.environ.get( |
| 198 | "VECTARA_CORPUS_ID" |
| 199 | ) |
| 200 | self._vectara_api_key = vectara_api_key or os.environ.get("VECTARA_API_KEY") |
| 201 | if ( |
| 202 | self._vectara_customer_id is None |
| 203 | or self._vectara_corpus_id is None |
| 204 | or self._vectara_api_key is None |
| 205 | ): |
| 206 | logger.warning( |
| 207 | "Can't find Vectara credentials, customer_id or corpus_id in " |
| 208 | "environment." |
| 209 | ) |
| 210 | else: |
| 211 | logger.debug(f"Using corpus id {self._vectara_corpus_id}") |
| 212 | self._source = source |
| 213 | |
| 214 | self._session = requests.Session() # to reuse connections |
| 215 | adapter = requests.adapters.HTTPAdapter(max_retries=3) |
| 216 | self._session.mount("http://", adapter) |
| 217 | self.vectara_api_timeout = vectara_api_timeout |
| 218 | |
| 219 | @property |
| 220 | def embeddings(self) -> Optional[Embeddings]: |
| 221 | return None |
| 222 | |
| 223 | def _get_post_headers(self) -> dict: |
| 224 | """Returns headers that should be attached to each post request.""" |
| 225 | return { |