From 4051f0120e8242c1ca86e0c121b415d784433753 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sat, 20 Dec 2025 15:32:34 -0600 Subject: [PATCH] Increase default max tokens and fetch size --- custom_components/groqd/config_flow.py | 3 ++- custom_components/groqd/const.py | 3 ++- custom_components/groqd/conversation.py | 9 +++++---- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/custom_components/groqd/config_flow.py b/custom_components/groqd/config_flow.py index c8da565..987d179 100644 --- a/custom_components/groqd/config_flow.py +++ b/custom_components/groqd/config_flow.py @@ -57,6 +57,7 @@ from .const import ( DEFAULT_SEARXNG_SAFESEARCH, DEFAULT_SEARXNG_LANGUAGE, DEFAULT_AUTO_FETCH_URLS, + DEFAULT_FETCH_MAX_CHARS, DOMAIN, ) from .const import DEFAULT_MAX_TOKENS, CONF_MAX_TOKENS @@ -209,7 +210,7 @@ class GroqdOptionsFlow(OptionsFlow): CONF_MAX_TOKENS, description={"suggested_value": options.get(CONF_MAX_TOKENS, DEFAULT_MAX_TOKENS)}, default=options.get(CONF_MAX_TOKENS, DEFAULT_MAX_TOKENS), - ): NumberSelector(NumberSelectorConfig(min=1, max=8192, step=1)), + ): NumberSelector(NumberSelectorConfig(min=1, max=16384, step=1)), vol.Optional( CONF_TEMPERATURE, description={"suggested_value": options.get(CONF_TEMPERATURE, DEFAULT_TEMPERATURE)}, diff --git a/custom_components/groqd/const.py b/custom_components/groqd/const.py index 7bd32c6..48cd4a1 100644 --- a/custom_components/groqd/const.py +++ b/custom_components/groqd/const.py @@ -31,7 +31,7 @@ CONF_AUTO_FETCH_URLS = "auto_fetch_urls" DEFAULT_CHAT_MODEL = "meta-llama/llama-4-maverick-17b-128e-instruct" DEFAULT_CONTEXT_MESSAGES = 20 -DEFAULT_MAX_TOKENS = 512 +DEFAULT_MAX_TOKENS = 4096 DEFAULT_TEMPERATURE = 1.0 DEFAULT_TOP_P = 1.0 DEFAULT_FREQUENCY_PENALTY = 0.0 @@ -45,3 +45,4 @@ DEFAULT_SEARXNG_URL = "http://127.0.0.1:8800" DEFAULT_SEARXNG_SAFESEARCH = 1 DEFAULT_SEARXNG_LANGUAGE = "en" DEFAULT_AUTO_FETCH_URLS = True +DEFAULT_FETCH_MAX_CHARS = 12000 diff --git a/custom_components/groqd/conversation.py b/custom_components/groqd/conversation.py index e34ff34..08fde55 100644 --- a/custom_components/groqd/conversation.py +++ b/custom_components/groqd/conversation.py @@ -70,6 +70,7 @@ from .const import ( DEFAULT_SEARXNG_SAFESEARCH, DEFAULT_SEARXNG_URL, DEFAULT_AUTO_FETCH_URLS, + DEFAULT_FETCH_MAX_CHARS, DEFAULT_TEMPERATURE, DEFAULT_TOOL_CHOICE, DEFAULT_TOP_P, @@ -153,7 +154,7 @@ def _fetch_tool() -> ChatCompletionToolParam: "type": "object", "properties": { "url": {"type": "string"}, - "max_chars": {"type": "integer", "default": 4000}, + "max_chars": {"type": "integer", "default": 12000}, }, "required": ["url"], }, @@ -400,7 +401,7 @@ class GroqdConversationEntity( fetched_chunks = [] for url in urls: try: - fetched = await _run_fetch(self.hass, url, 2000) + fetched = await _run_fetch(self.hass, url, DEFAULT_FETCH_MAX_CHARS) fetched_chunks.append( f"URL: {fetched['url']}\\nCONTENT: {fetched['text']}" ) @@ -522,11 +523,11 @@ class GroqdConversationEntity( tool_response = {"error": type(err).__name__, "error_text": str(err)} elif tool_name == "fetch_url": url = tool_args.get("url", "") - max_chars = tool_args.get("max_chars", 4000) + max_chars = tool_args.get("max_chars", DEFAULT_FETCH_MAX_CHARS) try: max_chars = int(max_chars) except (TypeError, ValueError): - max_chars = 4000 + max_chars = DEFAULT_FETCH_MAX_CHARS try: tool_response = await _run_fetch(self.hass, url, max_chars) except Exception as err: