camel.messages.conversion.sharegpt package#
Subpackages#
Submodules#
camel.messages.conversion.sharegpt.function_call_formatter module#
- class camel.messages.conversion.sharegpt.function_call_formatter.FunctionCallFormatter[source]#
Bases:
ABC
,Generic
[CallT
,ResponseT
]Abstract base class for function calling formats
- abstract extract_tool_calls(message: str) → List[CallT][source]#
Extract function call info from a message string
- abstract extract_tool_response(message: str) → ResponseT | None[source]#
Extract function response info from a message string
Module contents#
- class camel.messages.conversion.sharegpt.HermesFunctionFormatter[source]#
Bases:
FunctionCallFormatter
[HermesToolCall
,HermesToolResponse
]Hermes-style function calling format implementation with validation
- extract_tool_calls(message: str) → List[HermesToolCall][source]#
Extracts all tool calls from the provided message string.
- Parameters:
message (str) β The input message string containing potential tool calls.
- Returns:
A list of parsed HermesToolCall objects.
- Return type:
List[HermesToolCall]
- extract_tool_response(message: str) → HermesToolResponse | None[source]#
Extracts a single tool response from the provided message string.
- Parameters:
message (str) β The input message string containing a potential tool response.
- Returns:
- A parsed HermesToolResponse object,
or None if no valid response is found.
- Return type:
Optional[HermesToolResponse]
- format_tool_call(content: str, func_name: str, args: Dict[str, Any]) → str[source]#
Formats a tool call message with the given content, function name, and arguments.
- Parameters:
content (str) β The content or message to be included in the tool call.
func_name (str) β The name of the function being called.
args (Dict[str, Any]) β A dictionary of arguments to be passed to the function.
- Returns:
- A formatted string representing the tool call in Hermes
format.
- Return type:
str
- format_tool_response(func_name: str, result: Any) → str[source]#
Formats a tool response message with the given function name and result.
- Parameters:
func_name (str) β The name of the function whose result is being returned.
result (Any) β The result to be included in the tool response.
- Returns:
- A formatted string representing the tool response in Hermes
format.
- Return type:
str