FunctionGemmaModel
- model_type (Union[ModelType, str]): Model for which a backend is created (e.g., “functiongemma”).
- model_config_dict (Optional[Dict[str, Any]], optional): A dictionary of configuration options. If :obj:
None, :obj:FunctionGemmaConfig().as_dict()will be used. (default: :obj:None) - api_key (Optional[str], optional): Not required for local Ollama. (default: :obj:
None) - url (Optional[str], optional): The URL to the Ollama server. (default: :obj:
http://localhost:11434) - token_counter (Optional[BaseTokenCounter], optional): Token counter to use for the model. If not provided, :obj:
OpenAITokenCounter( ModelType.GPT_4O_MINI)will be used. (default: :obj:None) - timeout (Optional[float], optional): The timeout value in seconds for API calls. If not provided, will fall back to the MODEL_TIMEOUT environment variable or default to 180 seconds. (default: :obj:
None) - max_retries (int, optional): Maximum number of retries for API calls. (default: :obj:
3)
init
token_counter
_escape_string
<escape> tags for FunctionGemma format.
Parameters:
- s (str): The string to escape.
_unescape_string
<escape> tags from string values.
Parameters:
- s (str): The string to unescape.
_type_to_function_gemma
- json_type (Union[str, List[str]]): The JSON schema type. Can be a string like “string” or a list like [“string”, “null”] for optional parameters.
_format_parameter_properties
- properties (Dict[str, Any]): The properties dictionary.
- required (List[str]): List of required parameter names.
_convert_tool_to_function_gemma
- tool (Dict[str, Any]): The OpenAI tool schema.
_format_developer_turn
- content (str): The system message content.
- tools (Optional[List[Dict[str, Any]]]): List of tool schemas.
_format_user_turn
- content (str): The user message content.
_format_model_turn
- message (OpenAIMessage): The assistant message.
_format_tool_response
- message (OpenAIMessage): The tool response message.
_format_messages
- messages (List[OpenAIMessage]): List of messages in OpenAI format.
- tools (Optional[List[Dict[str, Any]]]): List of tool schemas.
_extract_function_calls
- text (str): The model output text.
- tools (Optional[List[Dict[str, Any]]]): Available tools to infer function names when the model outputs malformed calls.
_infer_function_name
- args_str (str): The arguments string from the model output.
- tools (Optional[List[Dict[str, Any]]]): Available tools.
_parse_function_args
- args_str (str): The arguments string (e.g., “a:15,b:27”).
_parse_value
- value (str): The value string.
_to_chat_completion
- response_text (str): The model response text.
- model (str): The model name.
- tools (Optional[List[Dict[str, Any]]]): Available tools for function name inference.
_call_ollama_generate
- prompt (str): The formatted prompt string.
_run
- messages (List[OpenAIMessage]): Message list with the chat history in OpenAI API format.
- response_format (Optional[Type[BaseModel]]): Not supported for FunctionGemma. (default: :obj:
None) - tools (Optional[List[Dict[str, Any]]]): The schema of the tools to use for the request.