feat: Add DeepSeek AI provider support#1026
feat: Add DeepSeek AI provider support#1026haosenwang1018 wants to merge 1 commit intoItzCrazyKns:masterfrom
Conversation
Add DeepSeek as a new model provider option, including: - DeepSeek LLM implementation with streaming and object generation - DeepSeek Embedding implementation for document/query embeddings - Provider configuration with default models (deepseek-chat, deepseek-reasoner) - Registration in the providers index DeepSeek provides high-quality language models at competitive pricing and uses an OpenAI-compatible API for easy integration.
There was a problem hiding this comment.
3 issues found across 4 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/lib/models/providers/deepseek/deepseekLLM.ts">
<violation number="1" location="src/lib/models/providers/deepseek/deepseekLLM.ts:90">
P2: DeepSeek chat-completions payload uses `max_completion_tokens` instead of the documented `max_tokens`, risking ignored limits or request errors.</violation>
<violation number="2" location="src/lib/models/providers/deepseek/deepseekLLM.ts:106">
P2: Unguarded `JSON.parse` of model tool arguments can throw and fail the entire non-stream completion when one tool call contains invalid JSON.</violation>
<violation number="3" location="src/lib/models/providers/deepseek/deepseekLLM.ts:165">
P1: Streaming tool-call reconstruction is mis-indexed: new calls are appended with `push()` but subsequent chunks are merged by `tc.index`, which can corrupt multi-tool outputs.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| id: tc.id!, | ||
| arguments: tc.function?.arguments || '', | ||
| }; | ||
| recievedToolCalls.push(call); |
There was a problem hiding this comment.
P1: Streaming tool-call reconstruction is mis-indexed: new calls are appended with push() but subsequent chunks are merged by tc.index, which can corrupt multi-tool outputs.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/lib/models/providers/deepseek/deepseekLLM.ts, line 165:
<comment>Streaming tool-call reconstruction is mis-indexed: new calls are appended with `push()` but subsequent chunks are merged by `tc.index`, which can corrupt multi-tool outputs.</comment>
<file context>
@@ -0,0 +1,228 @@
+ id: tc.id!,
+ arguments: tc.function?.arguments || '',
+ };
+ recievedToolCalls.push(call);
+ return { ...call, arguments: parse(call.arguments || '{}') };
+ } else {
</file context>
| messages: this.convertToDeepSeekMessages(input.messages), | ||
| temperature: input.options?.temperature ?? 1.0, | ||
| top_p: input.options?.topP, | ||
| max_completion_tokens: input.options?.maxTokens, |
There was a problem hiding this comment.
P2: DeepSeek chat-completions payload uses max_completion_tokens instead of the documented max_tokens, risking ignored limits or request errors.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/lib/models/providers/deepseek/deepseekLLM.ts, line 90:
<comment>DeepSeek chat-completions payload uses `max_completion_tokens` instead of the documented `max_tokens`, risking ignored limits or request errors.</comment>
<file context>
@@ -0,0 +1,228 @@
+ messages: this.convertToDeepSeekMessages(input.messages),
+ temperature: input.options?.temperature ?? 1.0,
+ top_p: input.options?.topP,
+ max_completion_tokens: input.options?.maxTokens,
+ stop: input.options?.stopSequences,
+ frequency_penalty: input.options?.frequencyPenalty,
</file context>
| return { | ||
| name: tc.function.name, | ||
| id: tc.id, | ||
| arguments: JSON.parse(tc.function.arguments), |
There was a problem hiding this comment.
P2: Unguarded JSON.parse of model tool arguments can throw and fail the entire non-stream completion when one tool call contains invalid JSON.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/lib/models/providers/deepseek/deepseekLLM.ts, line 106:
<comment>Unguarded `JSON.parse` of model tool arguments can throw and fail the entire non-stream completion when one tool call contains invalid JSON.</comment>
<file context>
@@ -0,0 +1,228 @@
+ return {
+ name: tc.function.name,
+ id: tc.id,
+ arguments: JSON.parse(tc.function.arguments),
+ };
+ }
</file context>
xkonjin
left a comment
There was a problem hiding this comment.
Quick review pass:
- Main risk area here is auth/session state and stale credential handling.
- I didn’t see targeted regression coverage in the diff; please add or point CI at a focused test for the changed path in deepseekEmbedding.ts, deepseekLLM.ts, index.ts (+1 more).
- Before merge, I’d smoke-test the behavior touched by deepseekEmbedding.ts, deepseekLLM.ts, index.ts (+1 more) with malformed input / retry / rollback cases, since that’s where this class of change usually breaks.
This PR adds DeepSeek as a new model provider option for Perplexica.
Changes
Why DeepSeek?
DeepSeek provides high-quality language models at competitive pricing with strong performance on various benchmarks.
Testing
Fixes #XXX (if there's a related issue)
Summary by cubic
Added DeepSeek as a new model provider for chat and embeddings using an OpenAI-compatible API. Supports streaming and tool calls with default models deepseek-chat, deepseek-reasoner, and deepseek-embedding.
New Features
Migration
Written for commit 16df10e. Summary will update on new commits.