Skip to content

Commit db91ceb

Browse files
committed
add support for deepseek api (previously required filling in the URL via the custom model option)
1 parent c66e195 commit db91ceb

File tree

4 files changed

+47
-0
lines changed

4 files changed

+47
-0
lines changed

src/background/index.mjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import {
3737
isUsingMoonshotWebModel,
3838
isUsingOpenRouterApiModel,
3939
isUsingAimlApiModel,
40+
isUsingDeepSeekApiModel,
4041
} from '../config/index.mjs'
4142
import '../_locales/i18n'
4243
import { openUrl } from '../utils/open-url'
@@ -54,6 +55,7 @@ import { generateAnswersWithClaudeWebApi } from '../services/apis/claude-web.mjs
5455
import { generateAnswersWithMoonshotCompletionApi } from '../services/apis/moonshot-api.mjs'
5556
import { generateAnswersWithMoonshotWebApi } from '../services/apis/moonshot-web.mjs'
5657
import { isUsingModelName } from '../utils/model-name-convert.mjs'
58+
import { generateAnswersWithDeepSeekApi } from '../services/apis/deepseek-api.mjs'
5759

5860
function setPortProxy(port, proxyTabId) {
5961
port.proxy = Browser.tabs.connect(proxyTabId)
@@ -146,6 +148,8 @@ async function executeApi(session, port, config) {
146148
)
147149
} else if (isUsingChatGLMApiModel(session)) {
148150
await generateAnswersWithChatGLMApi(port, session.question, session)
151+
} else if (isUsingDeepSeekApiModel(session)) {
152+
await generateAnswersWithDeepSeekApi(port, session.question, session, config.deepSeekApiKey)
149153
} else if (isUsingOllamaApiModel(session)) {
150154
await generateAnswersWithOllamaApi(port, session.question, session)
151155
} else if (isUsingOpenRouterApiModel(session)) {

src/config/index.mjs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ export const moonshotApiModelKeys = [
105105
'moonshot_v1_32k',
106106
'moonshot_v1_128k',
107107
]
108+
export const deepSeekApiModelKeys = ['deepseek_chat', 'deepseek_reasoner']
108109
export const openRouterApiModelKeys = [
109110
'openRouter_anthropic_claude_sonnet4',
110111
'openRouter_anthropic_claude_3_7_sonnet',
@@ -187,6 +188,10 @@ export const ModelGroups = {
187188
value: githubThirdPartyApiModelKeys,
188189
desc: 'Github Third Party Waylaidwanderer (API)',
189190
},
191+
deepSeekApiModelKeys: {
192+
value: deepSeekApiModelKeys,
193+
desc: 'DeepSeek (API)',
194+
},
190195
openRouterApiModelKeys: {
191196
value: openRouterApiModelKeys,
192197
desc: 'OpenRouter (API)',
@@ -346,6 +351,15 @@ export const Models = {
346351
desc: 'Kimi.Moonshot (128k)',
347352
},
348353

354+
deepseek_chat: {
355+
value: 'deepseek-chat',
356+
desc: 'DeepSeek (Chat)',
357+
},
358+
deepseek_reasoner: {
359+
value: 'deepseek-reasoner',
360+
desc: 'DeepSeek (Reasoner)',
361+
},
362+
349363
openRouter_anthropic_claude_sonnet4: {
350364
value: 'anthropic/claude-sonnet-4',
351365
desc: 'OpenRouter (Claude Sonnet 4)',
@@ -461,6 +475,7 @@ export const defaultConfig = {
461475
claudeApiKey: '',
462476
chatglmApiKey: '',
463477
moonshotApiKey: '',
478+
deepSeekApiKey: '',
464479

465480
customApiKey: '',
466481

@@ -653,6 +668,10 @@ export function isUsingMoonshotApiModel(configOrSession) {
653668
return isInApiModeGroup(moonshotApiModelKeys, configOrSession)
654669
}
655670

671+
export function isUsingDeepSeekApiModel(configOrSession) {
672+
return isInApiModeGroup(deepSeekApiModelKeys, configOrSession)
673+
}
674+
656675
export function isUsingOpenRouterApiModel(configOrSession) {
657676
return isInApiModeGroup(openRouterApiModelKeys, configOrSession)
658677
}

src/popup/sections/GeneralPart.jsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {
2424
Models,
2525
isUsingOpenRouterApiModel,
2626
isUsingAimlApiModel,
27+
isUsingDeepSeekApiModel,
2728
} from '../../config/index.mjs'
2829
import Browser from 'webextension-polyfill'
2930
import { languageList } from '../../config/language.mjs'
@@ -408,6 +409,17 @@ export function GeneralPart({ config, updateConfig, setTabIndex }) {
408409
}}
409410
/>
410411
)}
412+
{isUsingDeepSeekApiModel(config) && (
413+
<input
414+
type="password"
415+
value={config.deepSeekApiKey}
416+
placeholder={t('API Key')}
417+
onChange={(e) => {
418+
const apiKey = e.target.value
419+
updateConfig({ deepSeekApiKey: apiKey })
420+
}}
421+
/>
422+
)}
411423
{isUsingOllamaApiModel(config) && (
412424
<input
413425
type="password"

src/services/apis/deepseek-api.mjs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { generateAnswersWithChatgptApiCompat } from './openai-api.mjs'
2+
3+
/**
4+
* @param {Browser.Runtime.Port} port
5+
* @param {string} question
6+
* @param {Session} session
7+
* @param {string} apiKey
8+
*/
9+
export async function generateAnswersWithDeepSeekApi(port, question, session, apiKey) {
10+
const baseUrl = 'https://api.deepseek.com'
11+
return generateAnswersWithChatgptApiCompat(baseUrl, port, question, session, apiKey)
12+
}

0 commit comments

Comments
 (0)