Skip to content

Commit

Permalink
community[patch]: Make AzureML endpoint return AI messages for type a…
Browse files Browse the repository at this point in the history
…ssistant (langchain-ai#24085)
  • Loading branch information
jacoblee93 authored Jul 11, 2024
1 parent 4ba14ad commit f1f1f75
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,8 @@ def format_response_payload(
except (KeyError, IndexError, TypeError) as e:
raise ValueError(self.format_error_msg.format(api_type=api_type)) from e
return ChatGeneration(
message=BaseMessage(
message=AIMessage(
content=choice.strip(),
type="assistant",
),
generation_info=None,
)
Expand All @@ -158,7 +157,9 @@ def format_response_payload(
except (KeyError, IndexError, TypeError) as e:
raise ValueError(self.format_error_msg.format(api_type=api_type)) from e
return ChatGeneration(
message=BaseMessage(
message=AIMessage(content=choice["message"]["content"].strip())
if choice["message"]["role"] == "assistant"
else BaseMessage(
content=choice["message"]["content"].strip(),
type=choice["message"]["role"],
),
Expand Down

0 comments on commit f1f1f75

Please sign in to comment.