fix(model): route requests through Electron net
This commit is contained in:
@@ -46,6 +46,7 @@ import {
|
|||||||
import type { LaunchEnvironmentProvider } from '../local-tool-environment/launch-environment-provider'
|
import type { LaunchEnvironmentProvider } from '../local-tool-environment/launch-environment-provider'
|
||||||
import type { DesktopDiagnosticFailureObserver } from '../desktop-diagnostics'
|
import type { DesktopDiagnosticFailureObserver } from '../desktop-diagnostics'
|
||||||
export type AgentCapabilityContext = {
|
export type AgentCapabilityContext = {
|
||||||
|
modelFetcher?: ModelRuntimeOptions['fetcher']
|
||||||
outputStore?: ModelRuntimeOptions['outputStore']
|
outputStore?: ModelRuntimeOptions['outputStore']
|
||||||
outputAdopt?: ModelRuntimeOptions['outputAdopt']
|
outputAdopt?: ModelRuntimeOptions['outputAdopt']
|
||||||
observeFailure?: DesktopDiagnosticFailureObserver
|
observeFailure?: DesktopDiagnosticFailureObserver
|
||||||
@@ -139,9 +140,11 @@ export function createDefaultModelRuntime(
|
|||||||
export function createModelProfileRuntime(
|
export function createModelProfileRuntime(
|
||||||
defaultWorkspace: string,
|
defaultWorkspace: string,
|
||||||
settings: ResolvedRuntimeSettings,
|
settings: ResolvedRuntimeSettings,
|
||||||
profile: ResolvedModelProfile
|
profile: ResolvedModelProfile,
|
||||||
|
fetcher?: ModelRuntimeOptions['fetcher']
|
||||||
): ModelAgentRuntime {
|
): ModelAgentRuntime {
|
||||||
return new ModelAgentRuntime({
|
return new ModelAgentRuntime({
|
||||||
|
fetcher,
|
||||||
apiKey: profile.apiKey,
|
apiKey: profile.apiKey,
|
||||||
baseUrl: profile.baseUrl,
|
baseUrl: profile.baseUrl,
|
||||||
model: profile.modelName,
|
model: profile.modelName,
|
||||||
@@ -359,6 +362,7 @@ export function createAgentRuntime(
|
|||||||
(modelAuthentication === 'none' || modelApiKey))
|
(modelAuthentication === 'none' || modelApiKey))
|
||||||
) {
|
) {
|
||||||
return new ModelAgentRuntime({
|
return new ModelAgentRuntime({
|
||||||
|
fetcher: capabilities.modelFetcher,
|
||||||
outputStore: capabilities.outputStore,
|
outputStore: capabilities.outputStore,
|
||||||
outputAdopt: capabilities.outputAdopt,
|
outputAdopt: capabilities.outputAdopt,
|
||||||
apiKey: modelApiKey ?? '',
|
apiKey: modelApiKey ?? '',
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import {
|
|||||||
dialog,
|
dialog,
|
||||||
globalShortcut,
|
globalShortcut,
|
||||||
Menu,
|
Menu,
|
||||||
|
net,
|
||||||
safeStorage,
|
safeStorage,
|
||||||
session,
|
session,
|
||||||
shell,
|
shell,
|
||||||
@@ -1115,6 +1116,7 @@ if (hasSingleInstanceLock) {
|
|||||||
: Promise.resolve([])
|
: Promise.resolve([])
|
||||||
])
|
])
|
||||||
return createAgentRuntime(defaultWorkspace, settings, {
|
return createAgentRuntime(defaultWorkspace, settings, {
|
||||||
|
modelFetcher: net.fetch,
|
||||||
outputStore: { backingStore: storageFiles.backingStore },
|
outputStore: { backingStore: storageFiles.backingStore },
|
||||||
outputAdopt: storageFiles.attachments.outputAdopt,
|
outputAdopt: storageFiles.attachments.outputAdopt,
|
||||||
observeFailure: observeDesktopFailure,
|
observeFailure: observeDesktopFailure,
|
||||||
|
|||||||
+2
-1
@@ -11,6 +11,7 @@ import {
|
|||||||
BrowserWindow,
|
BrowserWindow,
|
||||||
dialog,
|
dialog,
|
||||||
ipcMain,
|
ipcMain,
|
||||||
|
net,
|
||||||
shell,
|
shell,
|
||||||
type NotificationConstructorOptions,
|
type NotificationConstructorOptions,
|
||||||
type IpcMainInvokeEvent
|
type IpcMainInvokeEvent
|
||||||
@@ -6318,7 +6319,7 @@ export function registerIpcHandlers(
|
|||||||
if (profile.authentication === 'api-key' && !profile.apiKey) {
|
if (profile.authentication === 'api-key' && !profile.apiKey) {
|
||||||
throw new Error(`监督者模型连接“${profile.name}”未配置 API Key`)
|
throw new Error(`监督者模型连接“${profile.name}”未配置 API Key`)
|
||||||
}
|
}
|
||||||
return createModelProfileRuntime(settings.workspacePath, settings, profile)
|
return createModelProfileRuntime(settings.workspacePath, settings, profile, net.fetch)
|
||||||
}
|
}
|
||||||
const supervisorService = createProductionSupervisorService(supervisionDatabase,
|
const supervisorService = createProductionSupervisorService(supervisionDatabase,
|
||||||
async () => applicationSettingsStore?.get(), resolveSupervisorRuntime, supervisionModelPool,
|
async () => applicationSettingsStore?.get(), resolveSupervisorRuntime, supervisionModelPool,
|
||||||
|
|||||||
Reference in New Issue
Block a user