mirror of
https://github.com/hellodigua/ChatLab.git
synced 2026-10-25 17:54:34 +08:00
refactor(ai): upgrade pi runtime and define execution semantics
This commit is contained in:
1 parent
dea6eb8f0d
commit
cf1aee9e5b
37 files changed
+313
-133
No files matched your search
@@ -15,7 +15,7 @@
|
||||
"LICENSE"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
"node": ">=22.19.0"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
@@ -48,8 +48,8 @@
|
||||
"dependencies": {
|
||||
"@fastify/multipart": "^10.0.0",
|
||||
"@fastify/static": "^9.1.3",
|
||||
"@earendil-works/pi-agent-core": "0.74.2",
|
||||
"@earendil-works/pi-ai": "0.74.2",
|
||||
"@earendil-works/pi-agent-core": "0.83.0",
|
||||
"@earendil-works/pi-ai": "0.83.0",
|
||||
"@modelcontextprotocol/sdk": "^1.12.1",
|
||||
"better-sqlite3": "^12.4.6",
|
||||
"commander": "^13.1.0",
|
||||
|
||||
@@ -251,6 +251,7 @@ export async function runServerAgent(options: RunAgentOptions): Promise<void> {
|
||||
userMessage,
|
||||
maxToolRounds: DEFAULT_MAX_TOOL_ROUNDS,
|
||||
abortSignal,
|
||||
providerSessionId: aiChatId,
|
||||
steerMessage,
|
||||
thinkingLevel: thinkingLevel as import('@openchatlab/core').ThinkingLevel | undefined,
|
||||
onConvertToLlm: (filteredMessages) => {
|
||||
|
||||
@@ -37,6 +37,7 @@ describe('adaptToolsForAgent', () => {
|
||||
name: 'render_chart',
|
||||
description: 'Render a chart',
|
||||
inputSchema: { type: 'object', properties: {} },
|
||||
executionMode: 'sequential',
|
||||
async handler() {
|
||||
chartCalls += 1
|
||||
return { content: 'Generated chart.' }
|
||||
@@ -51,6 +52,7 @@ describe('adaptToolsForAgent', () => {
|
||||
|
||||
const result = await agentTool.execute('call-1', {})
|
||||
|
||||
assert.equal(agentTool.executionMode, 'sequential')
|
||||
assert.equal(chartCalls, 0)
|
||||
assert.deepEqual(result.content, [{ type: 'text', text: CHART_SCHEMA_REQUIRED_MESSAGE }])
|
||||
assert.equal(result.details, null)
|
||||
|
||||
@@ -73,6 +73,7 @@ export function adaptToolsForAgent(
|
||||
label: tool.name,
|
||||
description: tool.description,
|
||||
parameters: toAgentToolParameters(tool.inputSchema) as any,
|
||||
executionMode: tool.executionMode,
|
||||
async execute(_toolCallId: string, params: unknown) {
|
||||
const ctx = getContext()
|
||||
const execCtx: ToolExecutionContext = {
|
||||
|
||||
@@ -15,7 +15,7 @@ export default defineConfig({
|
||||
splitting: true,
|
||||
sourcemap: true,
|
||||
clean: true,
|
||||
target: 'node20',
|
||||
target: 'node22',
|
||||
platform: 'node',
|
||||
define: {
|
||||
'process.env.UMAMI_ENDPOINT': JSON.stringify(process.env.UMAMI_ENDPOINT || ''),
|
||||
|
||||
@@ -231,6 +231,7 @@ export class Agent {
|
||||
userMessage,
|
||||
maxToolRounds,
|
||||
abortSignal: this.abortSignal,
|
||||
providerSessionId: this.context.aiChatId,
|
||||
steerMessage: answerWithoutToolsPrompt,
|
||||
thinkingLevel: this.config.thinkingLevel,
|
||||
streamFn: errorCapturingStreamFn,
|
||||
|
||||
@@ -58,6 +58,7 @@ export function adaptSharedTool(tool: ToolDefinition): ToolRegistryEntry {
|
||||
// 缺 key 时回退到此英文描述,避免把裸 i18n key 当作工具描述传给 LLM。
|
||||
description: tool.description,
|
||||
parameters: toAgentToolParameters(tool.inputSchema) as any,
|
||||
executionMode: tool.executionMode,
|
||||
async execute(_toolCallId: string, params: unknown) {
|
||||
return executeToolForAgent(tool, params, buildExecutionContext(context))
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user