community[patch]: Make AzureML endpoint return AI messages for type assistant (#24085)

This commit is contained in:
Jacob Lee 2024-07-11 12:45:30 -07:00 committed by GitHub
parent 4ba14adec6
commit f1f1f75782
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -141,9 +141,8 @@ class CustomOpenAIChatContentFormatter(ContentFormatterBase):
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,
)
@ -158,7 +157,9 @@ class CustomOpenAIChatContentFormatter(ContentFormatterBase):
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"],
),