Skip to content

Commit

Permalink
Update openai.py compatibility with azure 2023-07-01-preview (#7937)
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
pretidav and baskaryan authored Jul 19, 2023
1 parent b65102b commit 6792a35
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion langchain/chat_models/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion langchain/vectorstores/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
)

Expand Down

1 comment on commit 6792a35

@ElunDai
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similarityatscore_threshold doesn't appear anywhere else, it seems to be a misspelling

Please sign in to comment.