Skip to content

Commit b01e971

Browse files
committed
fix: use json_mode for structured output to support all groq models
1 parent 23e1d30 commit b01e971

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

  • apps/python-service/routers

‎apps/python-service/routers/ai.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ async def query_builder(request: QueryBuilderRequest, req: Request):
115115
)
116116

117117
# Enforce structured output based on our Pydantic schema
118-
structured_llm = llm.with_structured_output(QueryResult)
118+
structured_llm = llm.with_structured_output(QueryResult, method="json_mode")
119119

120120
# Build the system prompt
121121
system_prompt = """You are a highly intelligent database query builder for a MongoDB-based BaaS called urBackend.
@@ -193,9 +193,10 @@ async def collection_creator(request: CollectionCreatorRequest, req: Request):
193193
model=request.model,
194194
)
195195

196-
structured_llm = llm.with_structured_output(CollectionCreatorResponse)
196+
structured_llm = llm.with_structured_output(CollectionCreatorResponse, method="json_mode")
197197

198198
system_prompt = """You are a MongoDB schema designer for urBackend, a Backend-as-a-Service platform.
199+
You MUST output valid JSON only.
199200
200201
Rules:
201202
1. If the description is vague, ask 2-3 specific clarifying questions and set type: "clarify". You MUST set "schema": null. NEVER ask more than 3 at once.

0 commit comments

Comments
 (0)