mirror of
https://github.com/sudoxreboot/groqd
synced 2026-04-14 11:36:49 +00:00
Add time format option and enforce numeric time
This commit is contained in:
parent
4051f0120e
commit
9aa02e07f1
4 changed files with 31 additions and 0 deletions
|
|
@ -36,6 +36,7 @@ from .const import (
|
|||
CONF_SEARXNG_SAFESEARCH,
|
||||
CONF_SEARXNG_LANGUAGE,
|
||||
CONF_AUTO_FETCH_URLS,
|
||||
CONF_TIME_FORMAT,
|
||||
CONF_SEED,
|
||||
CONF_STOP,
|
||||
CONF_TEMPERATURE,
|
||||
|
|
@ -58,6 +59,7 @@ from .const import (
|
|||
DEFAULT_SEARXNG_LANGUAGE,
|
||||
DEFAULT_AUTO_FETCH_URLS,
|
||||
DEFAULT_FETCH_MAX_CHARS,
|
||||
DEFAULT_TIME_FORMAT,
|
||||
DOMAIN,
|
||||
)
|
||||
from .const import DEFAULT_MAX_TOKENS, CONF_MAX_TOKENS
|
||||
|
|
@ -301,6 +303,18 @@ class GroqdOptionsFlow(OptionsFlow):
|
|||
description={"suggested_value": options.get(CONF_AUTO_FETCH_URLS, DEFAULT_AUTO_FETCH_URLS)},
|
||||
default=options.get(CONF_AUTO_FETCH_URLS, DEFAULT_AUTO_FETCH_URLS),
|
||||
): bool,
|
||||
vol.Optional(
|
||||
CONF_TIME_FORMAT,
|
||||
description={"suggested_value": options.get(CONF_TIME_FORMAT, DEFAULT_TIME_FORMAT)},
|
||||
default=options.get(CONF_TIME_FORMAT, DEFAULT_TIME_FORMAT),
|
||||
): SelectSelector(
|
||||
SelectSelectorConfig(
|
||||
options=[
|
||||
SelectOptionDict(label="12-hour", value="12h"),
|
||||
SelectOptionDict(label="24-hour", value="24h"),
|
||||
]
|
||||
)
|
||||
),
|
||||
vol.Optional(
|
||||
CONF_LLM_HASS_API,
|
||||
description={"suggested_value": options.get(CONF_LLM_HASS_API)},
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ CONF_SEARXNG_URL = "searxng_url"
|
|||
CONF_SEARXNG_SAFESEARCH = "searxng_safesearch"
|
||||
CONF_SEARXNG_LANGUAGE = "searxng_language"
|
||||
CONF_AUTO_FETCH_URLS = "auto_fetch_urls"
|
||||
CONF_TIME_FORMAT = "time_format"
|
||||
|
||||
DEFAULT_CHAT_MODEL = "meta-llama/llama-4-maverick-17b-128e-instruct"
|
||||
DEFAULT_CONTEXT_MESSAGES = 20
|
||||
|
|
@ -46,3 +47,4 @@ DEFAULT_SEARXNG_SAFESEARCH = 1
|
|||
DEFAULT_SEARXNG_LANGUAGE = "en"
|
||||
DEFAULT_AUTO_FETCH_URLS = True
|
||||
DEFAULT_FETCH_MAX_CHARS = 12000
|
||||
DEFAULT_TIME_FORMAT = "12h"
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
|||
from homeassistant.helpers.storage import Store
|
||||
from homeassistant.helpers import device_registry as dr, intent, llm, template
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.util import dt as dt_util
|
||||
from homeassistant.util import ulid
|
||||
|
||||
from . import GroqdConfigEntry
|
||||
|
|
@ -53,6 +54,7 @@ from .const import (
|
|||
CONF_SEARXNG_SAFESEARCH,
|
||||
CONF_SEARXNG_URL,
|
||||
CONF_AUTO_FETCH_URLS,
|
||||
CONF_TIME_FORMAT,
|
||||
CONF_SEED,
|
||||
CONF_STOP,
|
||||
CONF_TEMPERATURE,
|
||||
|
|
@ -71,6 +73,7 @@ from .const import (
|
|||
DEFAULT_SEARXNG_URL,
|
||||
DEFAULT_AUTO_FETCH_URLS,
|
||||
DEFAULT_FETCH_MAX_CHARS,
|
||||
DEFAULT_TIME_FORMAT,
|
||||
DEFAULT_TEMPERATURE,
|
||||
DEFAULT_TOOL_CHOICE,
|
||||
DEFAULT_TOP_P,
|
||||
|
|
@ -395,6 +398,17 @@ class GroqdConversationEntity(
|
|||
response=intent_response, conversation_id=conversation_id
|
||||
)
|
||||
|
||||
time_format = options.get(CONF_TIME_FORMAT, DEFAULT_TIME_FORMAT)
|
||||
now = dt_util.now()
|
||||
if time_format == "24h":
|
||||
formatted_time = now.strftime("%H:%M")
|
||||
else:
|
||||
formatted_time = now.strftime("%-I:%M %p")
|
||||
prompt_parts.append(
|
||||
f"Current local time: {formatted_time}. "
|
||||
"Always express time exactly in this numeric format; do not spell out numbers."
|
||||
)
|
||||
|
||||
if options.get(CONF_AUTO_FETCH_URLS, DEFAULT_AUTO_FETCH_URLS):
|
||||
urls = _extract_urls(user_input.text)
|
||||
if urls:
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@
|
|||
"searxng_language": "SearxNG language",
|
||||
"searxng_safesearch": "SearxNG safe search",
|
||||
"auto_fetch_urls": "Auto-fetch URLs in user messages",
|
||||
"time_format": "Time format",
|
||||
"llm_hass_api": "Home Assistant LLM API"
|
||||
},
|
||||
"data_description": {
|
||||
|
|
|
|||
Loading…
Reference in a new issue