mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-02 21:19:12 +00:00
Enforce json for non reasoning anthropic models even in deepthought
This commit is contained in:
@@ -73,7 +73,7 @@ def anthropic_completion_with_backoff(
|
|||||||
if response_schema:
|
if response_schema:
|
||||||
tool = create_anthropic_tool_definition(response_schema=response_schema)
|
tool = create_anthropic_tool_definition(response_schema=response_schema)
|
||||||
model_kwargs["tools"] = [tool]
|
model_kwargs["tools"] = [tool]
|
||||||
elif response_type == "json_object" and not deepthought:
|
elif response_type == "json_object" and not (is_reasoning_model(model_name) and deepthought):
|
||||||
# Prefill model response with '{' to make it output a valid JSON object. Not supported with extended thinking.
|
# Prefill model response with '{' to make it output a valid JSON object. Not supported with extended thinking.
|
||||||
formatted_messages.append(anthropic.types.MessageParam(role="assistant", content="{"))
|
formatted_messages.append(anthropic.types.MessageParam(role="assistant", content="{"))
|
||||||
aggregated_response += "{"
|
aggregated_response += "{"
|
||||||
|
|||||||
Reference in New Issue
Block a user