Handle price, responses of models served via Groq

Their tool call response may not strictly follow expected response
format. Let researcher handle incorrect arguments to code tool (i.e
triggers type error)
This commit is contained in:
Debanjum
2025-08-11 19:31:33 -07:00
parent b2d26088dc
commit 41f89cf7f3
3 changed files with 7 additions and 1 deletions

View File

@@ -934,6 +934,9 @@ async def astream_thought_processor(
if not chunk_data.get("object") or chunk_data.get("object") != "chat.completion.chunk": if not chunk_data.get("object") or chunk_data.get("object") != "chat.completion.chunk":
logger.warning(f"Skipping invalid chunk with object field: {chunk_data.get('object', 'missing')}") logger.warning(f"Skipping invalid chunk with object field: {chunk_data.get('object', 'missing')}")
continue continue
# Handle unsupported service tiers like "on_demand" by Groq
if chunk.service_tier and chunk.service_tier == "on_demand":
chunk_data["service_tier"] = "auto"
tchunk = ChatCompletionWithThoughtsChunk.model_validate(chunk_data) tchunk = ChatCompletionWithThoughtsChunk.model_validate(chunk_data)

View File

@@ -433,7 +433,7 @@ async def research(
this_iteration.codeContext = code_results this_iteration.codeContext = code_results
async for result in send_status_func(f"**Ran code snippets**: {len(this_iteration.codeContext)}"): async for result in send_status_func(f"**Ran code snippets**: {len(this_iteration.codeContext)}"):
yield result yield result
except ValueError as e: except (ValueError, TypeError) as e:
this_iteration.warning = f"Error running code: {e}" this_iteration.warning = f"Error running code: {e}"
logger.warning(this_iteration.warning, exc_info=True) logger.warning(this_iteration.warning, exc_info=True)

View File

@@ -71,4 +71,7 @@ model_to_cost: Dict[str, Dict[str, float]] = {
"grok-3-latest": {"input": 3.0, "output": 15.0}, "grok-3-latest": {"input": 3.0, "output": 15.0},
"grok-3-mini": {"input": 0.30, "output": 0.50}, "grok-3-mini": {"input": 0.30, "output": 0.50},
"grok-3-mini-latest": {"input": 0.30, "output": 0.50}, "grok-3-mini-latest": {"input": 0.30, "output": 0.50},
# Groq pricing
"moonshotai/kimi-k2-instruct": {"input": 1.00, "output": 3.00},
"openai/gpt-oss-120b": {"input": 0.15, "output": 0.75},
} }