camel.messages.conversion.sharegpt.hermes package#
Submodules#
camel.messages.conversion.sharegpt.hermes.hermes_function_formatter module#
- class camel.messages.conversion.sharegpt.hermes.hermes_function_formatter.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
- class camel.messages.conversion.sharegpt.hermes.hermes_function_formatter.HermesToolCall(*, name: str, arguments: Dict[str, Any])[source]#
Bases:
ToolCall
Represents a single tool/function call with validation
- model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}#
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'json_schema_extra': {'examples': [{'arguments': {'city': 'London', 'units': 'celsius'}, 'name': 'get_weather'}]}}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[Dict[str, FieldInfo]] = {'arguments': FieldInfo(annotation=Dict[str, Any], required=True, description='The arguments to pass to the tool'), 'name': FieldInfo(annotation=str, required=True, description='The name of the tool to call', metadata=[MinLen(min_length=1), MaxLen(max_length=256)])}#
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
- class camel.messages.conversion.sharegpt.hermes.hermes_function_formatter.HermesToolResponse(*, name: str, content: Any)[source]#
Bases:
ToolResponse
Represents a single tool/function call with validation
- model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}#
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'json_schema_extra': {'examples': [{'content': {'conditions': 'sunny', 'humidity': 65, 'temperature': 20}, 'name': 'get_weather'}]}}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[Dict[str, FieldInfo]] = {'content': FieldInfo(annotation=Any, required=True, description='The response content from the tool. Must be JSON serializable literal or object'), 'name': FieldInfo(annotation=str, required=True, description='The name of the tool that was called', metadata=[MinLen(min_length=1), MaxLen(max_length=256)])}#
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
Module contents#
- class camel.messages.conversion.sharegpt.hermes.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