fix(agent): handle non-builtin models in getModelFromDb and upgrade pi-ai

This commit is contained in:
yiling
2026-07-22 16:09:36 +08:00
parent fbf963fe43
commit e9959bcc68
4 changed files with 70 additions and 30 deletions
+6 -2
View File
@@ -6,7 +6,7 @@ import {
type ThinkingLevel,
} from '@earendil-works/pi-agent-core'
import { NodeExecutionEnv } from '@earendil-works/pi-agent-core/node'
import { getModel } from '@earendil-works/pi-ai'
import { getModel } from '@earendil-works/pi-ai/compat'
import { Type, type TSchema } from '@sinclair/typebox'
import * as fs from 'fs'
import * as path from 'path'
@@ -47,7 +47,11 @@ export function getModelFromDb(providers: DbProviderInfo[], providerName: string
try {
// Try to get built-in model as template
// eslint-disable-next-line @typescript-eslint/no-explicit-any
m = { ...(getModel as any)(providerName, modelId) }
const builtIn = (getModel as any)(providerName, modelId)
if (!builtIn) {
throw new Error(`Model ${modelId} is not a built-in model`)
}
m = { ...builtIn }
} catch {
// Not a built-in model
m = {