You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I searched the LangChain documentation with the integrated search.
I used the GitHub search to find a similar question and didn't find it.
I am sure that this is a bug in LangChain rather than my code.
The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).
Example Code
We have the following code:
openai_api_key: str="PLACEHOLDER FOR YOUR API KEY"openai_api_version: str="2023-05-15"model: str="text-embedding-ada-002"azure_endpoint: str="PLACEHOLDER FOR YOUR AZURE OPENAI ENDPOINT"azure_openai_api_key: str="PLACEHOLDER FOR YOUR AZURE OPENAI KEY"azure_openai_api_version: str="2023-05-15"azure_deployment: str="text-embedding-ada-002"vector_store_address: str="YOUR_AZURE_SEARCH_ENDPOINT"vector_store_password: str="YOUR_AZURE_SEARCH_ADMIN_KEY"embeddings: AzureOpenAIEmbeddings=AzureOpenAIEmbeddings(
azure_deployment=azure_deployment,
openai_api_version=azure_openai_api_version,
azure_endpoint=azure_endpoint,
api_key=azure_openai_api_key,
)
vector_store: AzureSearch=AzureSearch(
azure_search_endpoint=vector_store_address,
azure_search_key=vector_store_password,
index_name=index_name,
embedding_function=embeddings.embed_query,
# Configure max retries for the Azure clientadditional_search_client_options={"retry_total": 4},
)
docs=vector_store.similarity_search(
query="What did the president say about Ketanji Brown Jackson",
k=3,
search_type="similarity",
)
print(docs[0].page_content)
It is just adding up a latency to AzureSearch component since it is called get_index function twice.
Description
I am trying to use LangChain to integrate with Azure AI Search and noticed that get_index function is getting called twice when trying to intialize AzureSearch.
System Info
System Information
OS: Linux
OS Version: #1 SMP PREEMPT Thu Jun 30 08:18:26 UTC 2022
Python Version: 3.10.14 (main, Jul 2 2024, 22:06:13) [GCC 12.2.0]
msetbar
changed the title
Azure AI Search Client Component Calling get_index function twicec\
Azure AI Search Client Component Calling get_index function twice
Jan 27, 2025
Checked other resources
Example Code
We have the following code:
In AzureSearch, get_index function is called twice which is not needed. One is called for intialization of client and the second time is called for the intialization of client_async. Please check this line: https://github.com/langchain-ai/langchain/blob/master/libs/community/langchain_community/vectorstores/azuresearch.py#L361
Error Message and Stack Trace (if applicable)
It is just adding up a latency to AzureSearch component since it is called get_index function twice.
Description
I am trying to use LangChain to integrate with Azure AI Search and noticed that get_index function is getting called twice when trying to intialize AzureSearch.
System Info
System Information
Package Information
Optional packages not installed
Other Dependencies
The text was updated successfully, but these errors were encountered: