Skip to content

Commit 6792a35

Browse files
pretidavbaskaryan
andauthored
Update openai.py compatibility with azure 2023-07-01-preview (#7937)
Fixed missing "content" field in azure. Added a check for "content" in _dict (missing for azure api=2023-07-01-preview) @baskaryan --------- Co-authored-by: Bagatur <[email protected]>
1 parent b65102b commit 6792a35

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

langchain/chat_models/openai.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ def _convert_dict_to_message(_dict: Mapping[str, Any]) -> BaseMessage:
100100
if role == "user":
101101
return HumanMessage(content=_dict["content"])
102102
elif role == "assistant":
103-
content = _dict["content"] or "" # OpenAI returns None for tool invocations
103+
# Fix for azure
104+
# Also OpenAI returns None for tool invocations
105+
content = _dict.get("content", "")
104106
if _dict.get("function_call"):
105107
additional_kwargs = {"function_call": dict(_dict["function_call"])}
106108
else:

langchain/vectorstores/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ class VectorStoreRetriever(BaseRetriever):
445445
search_kwargs: dict = Field(default_factory=dict)
446446
allowed_search_types: ClassVar[Collection[str]] = (
447447
"similarity",
448-
"similarity_score_threshold",
448+
"similarityatscore_threshold",
449449
"mmr",
450450
)
451451

0 commit comments

Comments
 (0)