Home Assistant Unofficial Reference 2024.12.1
homeassistant.components.ollama.conversation Namespace Reference

Classes

class  OllamaConversationEntity
 

Functions

Any _fix_invalid_arguments (Any value)
 
dict[str, Any] _format_tool (llm.Tool tool, Callable[[Any], Any]|None custom_serializer)
 
dict[str, Any] _parse_tool_args (dict[str, Any] arguments)
 
None async_setup_entry (HomeAssistant hass, ConfigEntry config_entry, AddEntitiesCallback async_add_entities)
 

Variables

 _LOGGER = logging.getLogger(__name__)
 
int MAX_TOOL_ITERATIONS = 10
 

Detailed Description

The conversation platform for the Ollama integration.

Function Documentation

◆ _fix_invalid_arguments()

Any homeassistant.components.ollama.conversation._fix_invalid_arguments ( Any  value)
private
Attempt to repair incorrectly formatted json function arguments.

Small models (for example llama3.1 8B) may produce invalid argument values
which we attempt to repair here.

Definition at line 68 of file conversation.py.

◆ _format_tool()

dict[str, Any] homeassistant.components.ollama.conversation._format_tool ( llm.Tool  tool,
Callable[[Any], Any] | None   custom_serializer 
)
private
Format tool specification.

Definition at line 55 of file conversation.py.

◆ _parse_tool_args()

dict[str, Any] homeassistant.components.ollama.conversation._parse_tool_args ( dict[str, Any]  arguments)
private
Rewrite ollama tool arguments.

This function improves tool use quality by fixing common mistakes made by
small local tool use models. This will repair invalid json arguments and
omit unnecessary arguments with empty values that will fail intent parsing.

Definition at line 86 of file conversation.py.

◆ async_setup_entry()

None homeassistant.components.ollama.conversation.async_setup_entry ( HomeAssistant  hass,
ConfigEntry  config_entry,
AddEntitiesCallback  async_add_entities 
)
Set up conversation entities.

Definition at line 45 of file conversation.py.

Variable Documentation

◆ _LOGGER

homeassistant.components.ollama.conversation._LOGGER = logging.getLogger(__name__)
private

Definition at line 42 of file conversation.py.

◆ MAX_TOOL_ITERATIONS

int homeassistant.components.ollama.conversation.MAX_TOOL_ITERATIONS = 10

Definition at line 40 of file conversation.py.