Skip to content

The agent engineering platform.

Update openai.py compatibility with azure 2023-07-01-preview (#7937)

David Preti6792a3557dc3
diff --git a/langchain/chat_models/openai.py b/langchain/chat_models/openai.py
index e09ac9abf7..0a8d7b84fd 100644
--- a/langchain/chat_models/openai.py
+++ b/langchain/chat_models/openai.py
@@ -100,7 +100,9 @@ def _convert_dict_to_message(_dict: Mapping[str, Any]) -> BaseMessage:
if role == "user":
return HumanMessage(content=_dict["content"])
elif role == "assistant":
- content = _dict["content"] or "" # OpenAI returns None for tool invocations
+ # Fix for azure
+ # Also OpenAI returns None for tool invocations
+ content = _dict.get("content", "")
if _dict.get("function_call"):
additional_kwargs = {"function_call": dict(_dict["function_call"])}
else:
diff --git a/langchain/vectorstores/base.py b/langchain/vectorstores/base.py
index a09ee25759..73b2710228 100644
--- a/langchain/vectorstores/base.py
+++ b/langchain/vectorstores/base.py
@@ -445,7 +445,7 @@ class VectorStoreRetriever(BaseRetriever):
search_kwargs: dict = Field(default_factory=dict)
allowed_search_types: ClassVar[Collection[str]] = (
"similarity",
- "similarity_score_threshold",
+ "similarityatscore_threshold",
"mmr",
)