Skip to content

Commit db46726

Browse files
pbuff07pengzy2vineethsai7
authored
Fix/update deepseek not support response format (#45)
* fix: fix deepseek llm not support response_format type * delete comment * Update llm_request_handler.py with Lint and bug fixes The condition if self.response_schema and not any(...) has three outcomes folded into two branches: response_schema exists AND model is not deepseek --> json_schema (correct) response_schema exists AND model is deepseek --> falls to else, gets json_object (correct) response_schema is None (any model) --> falls to else, gets json_object (BUG -- previously no response_format was set at all) The fix: the else with json_object should only apply when we have a schema but the provider doesn't support json_schema. When there's no schema, we should skip response_format entirely (original behavior). * Update llm_request_handler.py with lint issues --------- Co-authored-by: pengzy2 <pengzy2@knownsec.com> Co-authored-by: Vineeth Sai Narajala <vnarajal@cisco.com>
1 parent ca5db66 commit db46726

1 file changed

Lines changed: 13 additions & 8 deletions

File tree

skill_scanner/core/analyzers/llm_request_handler.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -211,14 +211,19 @@ async def _make_litellm_request(self, messages: list[dict[str, str]], context: s
211211
# Format: response_format={ "type": "json_schema", "json_schema": { "name": "...", "schema": {...}, "strict": true } }
212212
# Works for: OpenAI, Anthropic Claude, Gemini (via LiteLLM), Bedrock, Vertex AI, Groq, Ollama, Databricks
213213
if self.response_schema:
214-
request_params["response_format"] = {
215-
"type": "json_schema",
216-
"json_schema": {
217-
"name": "security_analysis_response",
218-
"schema": self.response_schema,
219-
"strict": True, # Enforce strict schema compliance - prevents extra fields
220-
},
221-
}
214+
model_lower = self.provider_config.model.lower()
215+
unsupported_json_schema_providers = ["deepseek"]
216+
if any(p in model_lower for p in unsupported_json_schema_providers):
217+
request_params["response_format"] = {"type": "json_object"}
218+
else:
219+
request_params["response_format"] = {
220+
"type": "json_schema",
221+
"json_schema": {
222+
"name": "security_analysis_response",
223+
"schema": self.response_schema,
224+
"strict": True,
225+
},
226+
}
222227

223228
response = await acompletion(**request_params)
224229
content: str = response.choices[0].message.content or ""

0 commit comments

Comments
 (0)