langgraph_agent_toolkit.helper.utils module
- langgraph_agent_toolkit.helper.utils.convert_message_content_to_string(content)[source][source]
- Parameters:
content (str | list[str | dict])
- Return type:
str
- langgraph_agent_toolkit.helper.utils.langchain_to_chat_message(message)[source][source]
Create a ChatMessage from a LangChain message.
- Parameters:
message (BaseMessage | dict | BaseModel | list)
- Return type:
- langgraph_agent_toolkit.helper.utils.remove_tool_calls(content)[source][source]
Remove tool calls from content.
- Parameters:
content (str | list[str | dict])
- Return type:
str | list[str | dict]
- langgraph_agent_toolkit.helper.utils.sanitize_chat_history(messages)[source][source]
Keep paired tool calls and tool results in chat history.
Remove an AIMessage tool call without a ToolMessage response. Remove a ToolMessage without a requesting AIMessage tool call.
- Parameters:
messages (list[BaseMessage]) – Messages to sanitize.
- Returns:
Messages with paired AIMessage tool calls and ToolMessage results.
- Return type:
list[BaseMessage]
- langgraph_agent_toolkit.helper.utils.create_ai_message(parts)[source][source]
- Parameters:
parts (dict)
- Return type:
AIMessage
- langgraph_agent_toolkit.helper.utils.read_file(file_path, mode='r', encoding='utf-8', **kwargs)[source][source]
Read a file and return its content.
- Parameters:
file_path (Path | str) – File path.
mode (str) – File mode. The default is “r”.
encoding (str) – File encoding. The default is “utf-8”.
**kwargs – Arguments for open.
- Returns:
File content.
- Return type:
Any