diff --git a/TODO.md b/TODO.md index 320d063..0ff83ec 100644 --- a/TODO.md +++ b/TODO.md @@ -1,7 +1,8 @@ # TODO -- [ ] new model based on qwen3 0.6b, 1.7b and 4b -- [ ] new model based on gemma3 270m -- [ ] support AI task API +- [ ] new model based on qwen3 0.6b, 1.7b and 4b +- [ ] add examples of 'fixing' a failed tool call to the dataset +- [x] new model based on gemma3 270m +- [x] support AI task API - [ ] vision support for remote backends - [ ] vision support for local backend (llama.cpp + llava) - [ ] move llamacpp to a separate process because of all the crashing diff --git a/custom_components/llama_conversation/const.py b/custom_components/llama_conversation/const.py index 9fe7214..b744eb9 100644 --- a/custom_components/llama_conversation/const.py +++ b/custom_components/llama_conversation/const.py @@ -63,7 +63,6 @@ USER_INSTRUCTION = { "pl": "Instrukcja użytkownika" } DEFAULT_PROMPT_BASE = """ - : {% for device in devices | selectattr('area_id', 'none'): %} {{ device.entity_id }} '{{ device.name }}' = {{ device.state }}{{ ([""] + device.attributes) | join(";") }} @@ -73,23 +72,19 @@ DEFAULT_PROMPT_BASE = """ {% for device in area.list %} {{ device.entity_id }} '{{ device.name }}' = {{ device.state }};{{ device.attributes | join(";") }} {% endfor %} -{% endfor %}""" +{% endfor %} +""" DEFAULT_PROMPT_BASE_LEGACY = """ - : -{{ formatted_devices }}""" +{{ formatted_devices }} +""" ICL_EXTRAS = """ {% for item in response_examples %} {{ item.request }} {{ item.response }} {{ tool_call_prefix }}{{ item.tool | to_json }}{{ tool_call_suffix }} {% endfor %}""" -ICL_NO_SYSTEM_PROMPT_EXTRAS = """ -{% for item in response_examples %} -{{ item.request }} -{{ item.response }} -{{ tool_call_prefix }}{{ item.tool | to_json }}{{ tool_call_suffix }} -{% endfor %} +NO_SYSTEM_PROMPT_EXTRAS = """ :""" DEFAULT_PROMPT = DEFAULT_PROMPT_BASE + ICL_EXTRAS CONF_CHAT_MODEL = "huggingface_model" @@ -239,6 +234,13 @@ DEFAULT_OPTIONS = types.MappingProxyType( def option_overrides(backend_type: str) -> dict[str, Any]: return { + "home-functiongemma": { + CONF_PROMPT: DEFAULT_PROMPT_BASE + NO_SYSTEM_PROMPT_EXTRAS, + CONF_USE_IN_CONTEXT_LEARNING_EXAMPLES: False, + CONF_TOOL_CALL_PREFIX: "", + CONF_TOOL_CALL_SUFFIX: "", + CONF_TOOL_RESPONSE_AS_STRING: False, # gemma function calling requires tool responses as a dictionary + }, "home-llama-3.2": { CONF_PROMPT: DEFAULT_PROMPT_BASE_LEGACY, CONF_USE_IN_CONTEXT_LEARNING_EXAMPLES: False, @@ -247,7 +249,7 @@ def option_overrides(backend_type: str) -> dict[str, Any]: CONF_CONTEXT_LENGTH: 131072, CONF_MAX_TOOL_CALL_ITERATIONS: 0, # llama cpp server doesn't support custom tool calling formats. so just use legacy tool calling - CONF_ENABLE_LEGACY_TOOL_CALLING: backend_type == BACKEND_TYPE_LLAMA_CPP_SERVER + CONF_ENABLE_LEGACY_TOOL_CALLING: True }, "home-3b-v3": { CONF_PROMPT: DEFAULT_PROMPT_BASE_LEGACY, @@ -256,7 +258,7 @@ def option_overrides(backend_type: str) -> dict[str, Any]: CONF_TOOL_CALL_SUFFIX: "```", CONF_MAX_TOOL_CALL_ITERATIONS: 0, # llama cpp server doesn't support custom tool calling formats. so just use legacy tool calling - CONF_ENABLE_LEGACY_TOOL_CALLING: backend_type == BACKEND_TYPE_LLAMA_CPP_SERVER + CONF_ENABLE_LEGACY_TOOL_CALLING: True }, "home-3b-v2": { CONF_PROMPT: DEFAULT_PROMPT_BASE_LEGACY, @@ -310,14 +312,14 @@ def option_overrides(backend_type: str) -> dict[str, Any]: CONF_TOP_P: 0.95 }, "mistral": { - CONF_PROMPT: DEFAULT_PROMPT_BASE + ICL_NO_SYSTEM_PROMPT_EXTRAS, + CONF_PROMPT: DEFAULT_PROMPT_BASE + ICL_EXTRAS + NO_SYSTEM_PROMPT_EXTRAS, CONF_MIN_P: 0.1, CONF_TYPICAL_P: 0.9, # no prompt formats with tool calling support, so just use legacy tool calling CONF_ENABLE_LEGACY_TOOL_CALLING: True, }, "mixtral": { - CONF_PROMPT: DEFAULT_PROMPT_BASE + ICL_NO_SYSTEM_PROMPT_EXTRAS, + CONF_PROMPT: DEFAULT_PROMPT_BASE + ICL_EXTRAS + NO_SYSTEM_PROMPT_EXTRAS, CONF_MIN_P: 0.1, CONF_TYPICAL_P: 0.9, # no prompt formats with tool calling support, so just use legacy tool calling