openhands.llm.fn_call_converter
Convert function calling messages to non-function calling messages and vice versa.
This will inject prompts so that models that doesn't support function calling can still be used with function calling agents.
We follow format from: https://docs.litellm.ai/docs/completion/function_call
convert_tool_call_to_string
def convert_tool_call_to_string(tool_call: dict) -> str
Convert tool call to content in string format.
convert_fncall_messages_to_non_fncall_messages
def convert_fncall_messages_to_non_fncall_messages(
messages: list[dict],
tools: list[ChatCompletionToolParam],
add_in_context_learning_example: bool = True) -> list[dict]
Convert function calling messages to non-function calling messages.
convert_non_fncall_messages_to_fncall_messages
def convert_non_fncall_messages_to_fncall_messages(
messages: list[dict],
tools: list[ChatCompletionToolParam]) -> list[dict]
Convert non-function calling messages back to function calling messages.
convert_from_multiple_tool_calls_to_single_tool_call_messages
def convert_from_multiple_tool_calls_to_single_tool_call_messages(
messages: list[dict],
ignore_final_tool_result: bool = False) -> list[dict]
Break one message with multiple tool calls into multiple messages.