Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
178 changes: 114 additions & 64 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,11 @@
"rather than in app.asar."
],
"devDependencies": {
"@ai-sdk/anthropic": "^3.0.125",
"@ai-sdk/google": "^3.0.129",
"@ai-sdk/openai": "^3.0.121",
"@ai-sdk/openai-compatible": "^2.0.80",
"@ai-sdk/provider": "^3.0.18",
"@ai-sdk/anthropic": "^4.0.69",
"@ai-sdk/google": "^4.0.86",
"@ai-sdk/openai": "^4.0.81",
"@ai-sdk/openai-compatible": "^3.0.60",
"@ai-sdk/provider": "^4.0.20",
"@dagrejs/dagre": "^1.1.8",
"@dnd-kit/core": "^6.3.1",
"@dnd-kit/sortable": "^10.0.0",
Expand Down Expand Up @@ -165,7 +165,7 @@
"@types/turndown": "^5.0.6",
"@vitejs/plugin-react": "^5.1.2",
"@xyflow/react": "^12.10.0",
"ai": "^6.0.297",
"ai": "^7.0.123",
"autoprefixer": "^10.4.23",
"cheerio": "^1.2.0",
"class-variance-authority": "^0.7.1",
Expand Down
13 changes: 11 additions & 2 deletions src/main/models/ModelClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 提供对话流式生成与 embedding 能力。业务代码只依赖它,不感知厂商。
*/

import { embed, embedMany, streamText } from 'ai'
import { embed, embedMany, streamText, toUIMessageStream } from 'ai'
import type { AsyncIterableStream, LanguageModel, LanguageModelUsage, UIMessageChunk } from 'ai'
import type { SharedV2ProviderOptions } from '@ai-sdk/provider'
import type { APIMessage, ChatTokenUsage } from '../../shared/types/chat'
Expand Down Expand Up @@ -119,6 +119,12 @@ export class ModelClient {

const result = streamText({
model: this.getAIModel(),
// KnowNote puts the retrieved context (and the title-generation prompt) into
// the history as a `system` message. AI SDK 7 rejects those by default, and
// it does not throw: the answer comes back empty. Every message here is
// built by this app, so the untrusted-injection case the default guards
// against does not apply.
allowSystemInMessages: true,
messages: toModelMessages(messages),
temperature: DEFAULT_TEMPERATURE,
// Only when the connection asks for a ceiling. Absent means the model's own
Expand All @@ -135,7 +141,10 @@ export class ModelClient {
})

return {
events: result.toUIMessageStream({
// The stateless helper, not `result.toUIMessageStream`: the result method is
// deprecated in v7 and logs a warning on every turn.
events: toUIMessageStream({
stream: result.stream,
sendReasoning: true,
// The SDK replaces a provider error with a generic sentence by default; the
// reader is owed the real one, which is what the transcript has always shown.
Expand Down
4 changes: 2 additions & 2 deletions src/main/models/protocols/googleGenerativeAi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Google Generative AI (Gemini) API,含 embedding 端点。
*/

import { createGoogleGenerativeAI } from '@ai-sdk/google'
import { createGoogle } from '@ai-sdk/google'
import type { EmbeddingModel, LanguageModel } from 'ai'
import type { ModelConnection } from '../../../shared/types/connection'
import type { ProtocolAdapter } from './types'
Expand All @@ -13,7 +13,7 @@ import { listGoogleModels } from './modelListing'
const PROVIDER_OPTIONS_KEY = 'google'

function createProvider(connection: ModelConnection) {
return createGoogleGenerativeAI({
return createGoogle({
baseURL: connection.baseUrl,
apiKey: connection.apiKey
})
Expand Down
Loading
Loading