mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-23 15:19:33 +00:00
google-genai[patch]: no error for FunctionMessage (#17215)
Both should eventually match this: https://github.com/langchain-ai/langchain/blob/master/libs/partners/google-vertexai/langchain_google_vertexai/chat_models.py#L179 But seems undocumented / can't find types in genai package
This commit is contained in:
parent
2ecf318218
commit
927ab77d6e
@ -39,6 +39,7 @@ from langchain_core.messages import (
|
|||||||
BaseMessage,
|
BaseMessage,
|
||||||
ChatMessage,
|
ChatMessage,
|
||||||
ChatMessageChunk,
|
ChatMessageChunk,
|
||||||
|
FunctionMessage,
|
||||||
HumanMessage,
|
HumanMessage,
|
||||||
HumanMessageChunk,
|
HumanMessageChunk,
|
||||||
SystemMessage,
|
SystemMessage,
|
||||||
@ -326,14 +327,20 @@ llm = ChatGoogleGenerativeAI(model="gemini-pro", convert_system_message_to_human
|
|||||||
continue
|
continue
|
||||||
elif isinstance(message, AIMessage):
|
elif isinstance(message, AIMessage):
|
||||||
role = "model"
|
role = "model"
|
||||||
|
# TODO: Handle AImessage with function call
|
||||||
|
parts = _convert_to_parts(message.content)
|
||||||
elif isinstance(message, HumanMessage):
|
elif isinstance(message, HumanMessage):
|
||||||
role = "user"
|
role = "user"
|
||||||
|
parts = _convert_to_parts(message.content)
|
||||||
|
elif isinstance(message, FunctionMessage):
|
||||||
|
role = "user"
|
||||||
|
# TODO: Handle FunctionMessage
|
||||||
|
parts = _convert_to_parts(message.content)
|
||||||
else:
|
else:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
f"Unexpected message with type {type(message)} at the position {i}."
|
f"Unexpected message with type {type(message)} at the position {i}."
|
||||||
)
|
)
|
||||||
|
|
||||||
parts = _convert_to_parts(message.content)
|
|
||||||
if raw_system_message:
|
if raw_system_message:
|
||||||
if role == "model":
|
if role == "model":
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
|
Loading…
Reference in New Issue
Block a user