-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from TarsLab/vendor-deepSeek
增加供应商deepseek
- Loading branch information
Showing
5 changed files
with
53 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
{ | ||
"id": "tars", | ||
"name": "Tars", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"minAppVersion": "1.5.8", | ||
"description": "Use Kimi and other Chinese LLMs for text generation based on tag suggestions.", | ||
"author": "Tarslab", | ||
"authorUrl": "https://github.com/tarslab", | ||
"isDesktopOnly": true | ||
} | ||
} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import OpenAI from 'openai' | ||
import { t } from 'src/lang/helper' | ||
import { BaseOptions, Message, SendRequest, Vendor } from '.' | ||
|
||
const sendRequestFunc = (settings: BaseOptions): SendRequest => | ||
async function* (messages: Message[]) { | ||
const { parameters, ...optionsExcludingParams } = settings | ||
const options = { ...optionsExcludingParams, ...parameters } | ||
const { apiKey, baseURL, model, ...remains } = options | ||
if (!apiKey) throw new Error(t('API key is required')) | ||
|
||
const client = new OpenAI({ | ||
apiKey, | ||
baseURL, | ||
dangerouslyAllowBrowser: true | ||
}) | ||
|
||
const stream = await client.chat.completions.create({ | ||
model, | ||
messages, | ||
stream: true, | ||
...remains | ||
}) | ||
|
||
for await (const part of stream) { | ||
const text = part.choices[0]?.delta?.content | ||
if (!text) continue | ||
yield text | ||
} | ||
} | ||
|
||
const models = ['deepseek-chat', 'deepseek-coder'] | ||
|
||
export const deepSeekVendor: Vendor = { | ||
name: 'DeepSeek', | ||
defaultOptions: { | ||
apiKey: '', | ||
baseURL: 'https://api.deepseek.com', | ||
model: models[0], | ||
parameters: {} | ||
}, | ||
sendRequestFunc, | ||
models, | ||
websiteToObtainKey: 'https://platform.deepseek.com' | ||
} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,6 @@ | |
"0.1.0": "1.5.8", | ||
"0.1.1": "1.5.8", | ||
"0.1.2": "1.5.8", | ||
"0.2.0": "1.5.8" | ||
"0.2.0": "1.5.8", | ||
"0.2.1": "1.5.8" | ||
} |