mirror of
https://github.com/hwchase17/langchain.git
synced 2025-07-14 08:56:27 +00:00
google-genai[patch]: fix new core typing (#16988)
This commit is contained in:
parent
35446c814e
commit
849051102a
@ -341,7 +341,9 @@ llm = ChatGoogleGenerativeAI(model="gemini-pro", convert_system_message_to_human
|
|||||||
return messages
|
return messages
|
||||||
|
|
||||||
|
|
||||||
def _parts_to_content(parts: List[genai.types.PartType]) -> Union[List[dict], str]:
|
def _parts_to_content(
|
||||||
|
parts: List[genai.types.PartType],
|
||||||
|
) -> Union[str, List[Union[Dict[Any, Any], str]]]:
|
||||||
"""Converts a list of Gemini API Part objects into a list of LangChain messages."""
|
"""Converts a list of Gemini API Part objects into a list of LangChain messages."""
|
||||||
if len(parts) == 1 and parts[0].text is not None and not parts[0].inline_data:
|
if len(parts) == 1 and parts[0].text is not None and not parts[0].inline_data:
|
||||||
# Simple text response. The typical response
|
# Simple text response. The typical response
|
||||||
@ -349,7 +351,7 @@ def _parts_to_content(parts: List[genai.types.PartType]) -> Union[List[dict], st
|
|||||||
elif not parts:
|
elif not parts:
|
||||||
logger.warning("Gemini produced an empty response.")
|
logger.warning("Gemini produced an empty response.")
|
||||||
return ""
|
return ""
|
||||||
messages = []
|
messages: List[Union[Dict[Any, Any], str]] = []
|
||||||
for part in parts:
|
for part in parts:
|
||||||
if part.text is not None:
|
if part.text is not None:
|
||||||
messages.append(
|
messages.append(
|
||||||
|
Loading…
Reference in New Issue
Block a user