Merge branch 'develop' into feature/polish-dataset

This commit is contained in:
Alex O'Connell
2024-06-16 15:32:18 -04:00
5 changed files with 32 additions and 9 deletions

View File

@@ -26,6 +26,10 @@ The latest models can be found on HuggingFace:
3B v3 (Based on StableLM-Zephyr-3B): https://huggingface.co/acon96/Home-3B-v3-GGUF (Zephyr prompt format)
1B v3 (Based on TinyLlama-1.1B): https://huggingface.co/acon96/Home-1B-v3-GGUF (Zephyr prompt format)
Non English experiments:
German, French, & Spanish (3B): https://huggingface.co/acon96/stablehome-multilingual-experimental
Polish (1B): https://huggingface.co/acon96/tinyhome-polish-experimental
<details>
<summary>Old Models</summary>
@@ -132,6 +136,7 @@ In order to facilitate running the project entirely on the system where Home Ass
## Version History
| Version | Description |
|---------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| v0.3.3 | Improvements to the Generic OpenAI Backend, improved area handling, fix issue using RGB colors, remove EOS token from responses, replace requests dependency with aiohttp included with Home Assistant |
| v0.3.2 | Fix for exposed script entities causing errors, fix missing GBNF error, trim whitespace from model output |
| v0.3.1 | Adds basic area support in prompting, Fix for broken requirements, fix for issue with formatted tools, fix custom API not registering on startup properly |
| v0.3 | Adds support for Home Assistant LLM APIs, improved model prompting and tool formatting options, and automatic detection of GGUF quantization levels on HuggingFace |

View File

@@ -2,6 +2,7 @@
from __future__ import annotations
import aiohttp
import asyncio
import csv
import importlib
import json
@@ -488,8 +489,9 @@ class LocalLLMAgent(AbstractConversationAgent):
if area_id:
area = area_registry.async_get_area(entity.area_id)
attributes["area_id"] = area.id
attributes["area_name"] = area.name
if area:
attributes["area_id"] = area.id
attributes["area_name"] = area.name
entity_states[state.entity_id] = attributes
domains.add(state.domain)
@@ -1130,7 +1132,7 @@ class GenericOpenAIAPIAgent(LocalLLMAgent):
request_params = {}
api_base_path = self.entry.options.get(CONF_GENERIC_OPENAI_PATH, DEFAULT_GENERIC_OPENAI_PATH)
endpoint = f"{api_base_path}/chat/completions"
endpoint = f"/{api_base_path}/chat/completions"
request_params["messages"] = [ { "role": x["role"], "content": x["message"] } for x in conversation ]
return endpoint, request_params
@@ -1181,6 +1183,7 @@ class GenericOpenAIAPIAgent(LocalLLMAgent):
headers["Authorization"] = f"Bearer {self.api_key}"
session = async_get_clientsession(self.hass)
response = None
try:
async with session.post(
f"{self.api_host}{endpoint}",
@@ -1190,7 +1193,7 @@ class GenericOpenAIAPIAgent(LocalLLMAgent):
) as response:
response.raise_for_status()
result = await response.json()
except aiohttp.ClientTimeout:
except asyncio.TimeoutError:
return "The generation request timed out! Please check your connection settings, increase the timeout in settings, or decrease the number of exposed entities."
except aiohttp.ClientError as err:
_LOGGER.debug(f"Err was: {err}")
@@ -1446,6 +1449,7 @@ class OllamaAPIAgent(LocalLLMAgent):
headers["Authorization"] = f"Bearer {self.api_key}"
session = async_get_clientsession(self.hass)
response = None
try:
async with session.post(
f"{self.api_host}{endpoint}",
@@ -1455,7 +1459,7 @@ class OllamaAPIAgent(LocalLLMAgent):
) as response:
response.raise_for_status()
result = await response.json()
except aiohttp.ClientTimeout:
except asyncio.TimeoutError:
return "The generation request timed out! Please check your connection settings, increase the timeout in settings, or decrease the number of exposed entities."
except aiohttp.ClientError as err:
_LOGGER.debug(f"Err was: {err}")

View File

@@ -324,8 +324,21 @@ OPTIONS_OVERRIDES = {
"command-r": {
CONF_PROMPT: DEFAULT_PROMPT_BASE + ICL_EXTRAS,
CONF_PROMPT_TEMPLATE: PROMPT_TEMPLATE_COMMAND_R,
}
},
"stablehome": {
CONF_PROMPT: DEFAULT_PROMPT_BASE_LEGACY,
CONF_PROMPT_TEMPLATE: PROMPT_TEMPLATE_ZEPHYR,
CONF_USE_IN_CONTEXT_LEARNING_EXAMPLES: False,
CONF_SERVICE_CALL_REGEX: FINE_TUNED_SERVICE_CALL_REGEX,
CONF_TOOL_FORMAT: TOOL_FORMAT_MINIMAL,
},
"tinyhome": {
CONF_PROMPT: DEFAULT_PROMPT_BASE_LEGACY,
CONF_USE_IN_CONTEXT_LEARNING_EXAMPLES: False,
CONF_SERVICE_CALL_REGEX: FINE_TUNED_SERVICE_CALL_REGEX,
CONF_TOOL_FORMAT: TOOL_FORMAT_MINIMAL,
},
}
INTEGRATION_VERSION = "0.3.2"
INTEGRATION_VERSION = "0.3.3"
EMBEDDED_LLAMA_CPP_PYTHON_VERSION = "0.2.77"

View File

@@ -1,7 +1,7 @@
{
"domain": "llama_conversation",
"name": "Local LLM Conversation",
"version": "0.3.2",
"version": "0.3.3",
"codeowners": ["@acon96"],
"config_flow": true,
"dependencies": ["conversation"],

View File

@@ -130,8 +130,9 @@ Llama 3 8B can be set up and downloaded on the serving machine using LM Studio b
- **IP Address**: Fill out IP Address for the machine hosting LM Studio
- **Port**: enter the port that was listed in LM Studio
- **Use HTTPS**: unchecked
- **Model Name**: This can be any value, as LM Studio uses the currently loaded model for all incoming requests.
- **Model Name**: Set this to the name of the model as it appears in LM Studio. If you receive an error that the model does not exist, then select the model from the dropdown list.
- **API Key**: leave blank
- **API Path**: leave as `/v1`
6. Click `Submit`
### Step 3: Model Configuration