Skip to content

Commit

Permalink
Fix an issue with chat request validation for LangChain flavor (mlflo…
Browse files Browse the repository at this point in the history
…w#11478)

Signed-off-by: Ben Wilson <[email protected]>
  • Loading branch information
BenWilson2 authored Mar 20, 2024
1 parent 695d287 commit 7d110f7
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions mlflow/langchain/api_request_parallel_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,13 +285,14 @@ def _transform_request_json_for_chat_if_necessary(request_json, lc_model):
# is handling the "messages" field by itself
return request_json, False

def json_dict_might_be_chat_request(json: Dict):
def json_dict_might_be_chat_request(json_message: Dict):
return (
"messages" in request_json
isinstance(json_message, dict)
and "messages" in json_message
and
# Additional keys can't be specified when calling LangChain invoke() / batch()
# with chat messages
len(request_json) == 1
len(json_message) == 1
)

if isinstance(request_json, dict) and json_dict_might_be_chat_request(request_json):
Expand Down

0 comments on commit 7d110f7

Please sign in to comment.