mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-22 14:49:29 +00:00
community[patch]: Make AzureML endpoint return AI messages for type assistant (#24085)
This commit is contained in:
parent
4ba14adec6
commit
f1f1f75782
@ -141,9 +141,8 @@ class CustomOpenAIChatContentFormatter(ContentFormatterBase):
|
|||||||
except (KeyError, IndexError, TypeError) as e:
|
except (KeyError, IndexError, TypeError) as e:
|
||||||
raise ValueError(self.format_error_msg.format(api_type=api_type)) from e
|
raise ValueError(self.format_error_msg.format(api_type=api_type)) from e
|
||||||
return ChatGeneration(
|
return ChatGeneration(
|
||||||
message=BaseMessage(
|
message=AIMessage(
|
||||||
content=choice.strip(),
|
content=choice.strip(),
|
||||||
type="assistant",
|
|
||||||
),
|
),
|
||||||
generation_info=None,
|
generation_info=None,
|
||||||
)
|
)
|
||||||
@ -158,7 +157,9 @@ class CustomOpenAIChatContentFormatter(ContentFormatterBase):
|
|||||||
except (KeyError, IndexError, TypeError) as e:
|
except (KeyError, IndexError, TypeError) as e:
|
||||||
raise ValueError(self.format_error_msg.format(api_type=api_type)) from e
|
raise ValueError(self.format_error_msg.format(api_type=api_type)) from e
|
||||||
return ChatGeneration(
|
return ChatGeneration(
|
||||||
message=BaseMessage(
|
message=AIMessage(content=choice["message"]["content"].strip())
|
||||||
|
if choice["message"]["role"] == "assistant"
|
||||||
|
else BaseMessage(
|
||||||
content=choice["message"]["content"].strip(),
|
content=choice["message"]["content"].strip(),
|
||||||
type=choice["message"]["role"],
|
type=choice["message"]["role"],
|
||||||
),
|
),
|
||||||
|
Loading…
Reference in New Issue
Block a user