chore(version): 0.7.5

This commit is contained in:
kangfenmao 2024-09-20 16:51:33 +08:00
parent 6bb7b2ca5d
commit a22a47c16a
2 changed files with 11 additions and 2 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "CherryStudio", "name": "CherryStudio",
"version": "0.7.4", "version": "0.7.5",
"private": true, "private": true,
"description": "A powerful AI assistant for producer.", "description": "A powerful AI assistant for producer.",
"main": "./out/main/index.js", "main": "./out/main/index.js",

View File

@ -124,16 +124,25 @@ export default class OpenAIProvider extends BaseProvider {
userMessages.push(await this.getMessageParam(message, model)) userMessages.push(await this.getMessageParam(message, model))
} }
const isSupportStreamOutput = this.isSupportStreamOutput(model.id)
// @ts-ignore key is not typed // @ts-ignore key is not typed
const stream = await this.sdk.chat.completions.create({ const stream = await this.sdk.chat.completions.create({
model: model.id, model: model.id,
messages: [systemMessage, ...userMessages].filter(Boolean) as ChatCompletionMessageParam[], messages: [systemMessage, ...userMessages].filter(Boolean) as ChatCompletionMessageParam[],
stream: this.isSupportStreamOutput(model.id), stream: isSupportStreamOutput,
temperature: assistant?.settings?.temperature, temperature: assistant?.settings?.temperature,
max_tokens: maxTokens, max_tokens: maxTokens,
keep_alive: this.keepAliveTime keep_alive: this.keepAliveTime
}) })
if (!isSupportStreamOutput) {
return onChunk({
text: stream.choices[0].message?.content || '',
usage: stream.usage
})
}
for await (const chunk of stream) { for await (const chunk of stream) {
if (window.keyv.get(EVENT_NAMES.CHAT_COMPLETION_PAUSED)) { if (window.keyv.get(EVENT_NAMES.CHAT_COMPLETION_PAUSED)) {
break break