Repository navigation
DeepSeek: json_schema is a 400, so the preset says json_schema="reject" - #35
Open
chaitanya0305 wants to merge 1 commit into
Open
chaitanya0305 wants to merge 1 commit into
chaitanya0305 wants to merge 1 commit into
Conversation
…_format.type is text or json_object, chat--create.md), so the preset sets json_schema="reject": the request goes out without it, recorded as dropped, and a caller that reads the knob before the call (DSPy's JSONAdapter) asks for JSON mode instead of failing
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #34
Why
DeepSeek's Chat Completions API takes
response_format.typetextorjson_object(chat--create.md; https://api-docs.deepseek.com/api/create-chat-completion, https://api-docs.deepseek.com/guides/json_mode). TheOpenAIChatJsonSchemacomment already records that DeepSeek answers 400, but thedeepseekpreset left the knob unset. Callers that read the knob before the call therefore cannot see the limit. DSPy's capability check (compat.json_schema == "reject"makessupports_response_schemaFalse) falls through to LiteLLM metadata that says True.dspy.JSONAdapterthen sends json_schema, and every structured-output call to DeepSeek fails, including ChatAdapter's JSON fallback.Change
lm15/compat.py:deepseekpreset gainsjson_schema="reject", citing chat--create.md. TheOpenAIChatJsonSchemacomment now explains why a loud 400 still gets the knob.lm15/providers/openai_chat.py: the "reject" branch's comment and adaptation reason no longer say the server "accepts and ignores" json_schema, which was true only for Z.AI. The reason now reads "this server does not apply response_format type 'json_schema'; use {'type': 'json_object'} ...".tests/test_registry.py:test_deepseek_declarationassertsjson_schema == "reject". The newtest_deepseek_keeps_json_schema_off_the_wirechecks that json_schema is dropped and recorded, and thatjson_objectstill goes out unchanged.Behaviour for direct lm15 users: a json_schema request to DeepSeek is now sent without
response_format, with an adaptation record, as Z.AI already is, instead of coming back as a 400. Underadaptations="refuse"it raises before the wire.Tests
pytest tests/test_registry.py -k deepseek: on origin/main source, 2 failed and 1 passed. With the fix, 3 passed.pytest tests/(ignoring the two modules that need a siblinglm15-contractcheckout): 3187 passed, 43 skipped. The 2 remaining failures intest_cross_provider_review.py(tinker) are the same missing-contract-file errors as on origin/main.cases/deepseek/*json_schema*case, so no fixture changes.dspy.JSONAdapterondeepseek/deepseek-flashsends{"type": "json_object"}and succeeds. Without it, it raisesLMInvalidRequestError.