Skip to content

Commit

Permalink
community: undo azure_ad_access_token breaking change (#25818)
Browse files Browse the repository at this point in the history
  • Loading branch information
efriis authored Aug 30, 2024
1 parent 6047138 commit f7e6275
Showing 1 changed file with 27 additions and 19 deletions.
46 changes: 27 additions & 19 deletions libs/community/langchain_community/vectorstores/azuresearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,6 @@ def __init__(
self,
azure_search_endpoint: str,
azure_search_key: str,
azure_ad_access_token: Optional[str],
index_name: str,
embedding_function: Union[Callable, Embeddings],
search_type: str = "hybrid",
Expand All @@ -281,6 +280,7 @@ def __init__(
*,
vector_search_dimensions: Optional[int] = None,
additional_search_client_options: Optional[Dict[str, Any]] = None,
azure_ad_access_token: Optional[str] = None,
**kwargs: Any,
):
try:
Expand Down Expand Up @@ -1298,14 +1298,18 @@ def semantic_hybrid_search_with_score_and_rerank(
}
),
**{
"captions": {
"text": result.get("@search.captions", [{}])[0].text,
"highlights": result.get("@search.captions", [{}])[
0
].highlights,
}
if result.get("@search.captions")
else {},
"captions": (
{
"text": result.get("@search.captions", [{}])[
0
].text,
"highlights": result.get("@search.captions", [{}])[
0
].highlights,
}
if result.get("@search.captions")
else {}
),
"answers": semantic_answers_dict.get(
result.get(FIELDS_ID, ""),
"",
Expand Down Expand Up @@ -1382,14 +1386,18 @@ async def asemantic_hybrid_search_with_score_and_rerank(
}
),
**{
"captions": {
"text": result.get("@search.captions", [{}])[0].text,
"highlights": result.get("@search.captions", [{}])[
0
].highlights,
}
if result.get("@search.captions")
else {},
"captions": (
{
"text": result.get("@search.captions", [{}])[
0
].text,
"highlights": result.get("@search.captions", [{}])[
0
].highlights,
}
if result.get("@search.captions")
else {}
),
"answers": semantic_answers_dict.get(
result.get(FIELDS_ID, ""),
"",
Expand Down Expand Up @@ -1421,10 +1429,10 @@ def from_texts(
azure_search = cls(
azure_search_endpoint,
azure_search_key,
azure_ad_access_token,
index_name,
embedding,
fields=fields,
azure_ad_access_token=azure_ad_access_token,
**kwargs,
)
azure_search.add_texts(texts, metadatas, **kwargs)
Expand All @@ -1447,10 +1455,10 @@ async def afrom_texts(
azure_search = cls(
azure_search_endpoint,
azure_search_key,
azure_ad_access_token,
index_name,
embedding,
fields=fields,
azure_ad_access_token=azure_ad_access_token,
**kwargs,
)
await azure_search.aadd_texts(texts, metadatas, **kwargs)
Expand Down

0 comments on commit f7e6275

Please sign in to comment.