update pay function

This commit is contained in:
2025-11-28 16:08:31 +08:00
parent 8cf2850660
commit 250d585b87
19 changed files with 51 additions and 17 deletions

View File

@@ -519,8 +519,10 @@ export const agentHandlers = [
await delay(200);
// 发送工具调用
const toolCallResults = [];
for (const tool of role.tools) {
const toolCallId = `tc-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
const execTime = 0.5 + Math.random() * 0.5;
// tool_call_start
controller.enqueue(encoder.encode(`data: ${JSON.stringify({
@@ -538,11 +540,20 @@ export const agentHandlers = [
type: 'tool_call_result',
role_id: role.role_id,
tool_call_id: toolCallId,
result: tool.result,
tool_name: tool.name,
result: { success: true, data: tool.result },
status: 'success',
execution_time: 0.5 + Math.random() * 0.5,
execution_time: execTime,
})}\n\n`));
toolCallResults.push({
tool_call_id: toolCallId,
tool_name: tool.name,
result: { success: true, data: tool.result },
status: 'success',
execution_time: execTime,
});
await delay(200);
}
@@ -561,8 +572,13 @@ export const agentHandlers = [
controller.enqueue(encoder.encode(`data: ${JSON.stringify({
type: 'message_complete',
role_id: role.role_id,
content: role.content,
is_conclusion: role.is_conclusion || false,
message: {
role_id: role.role_id,
role_name: role.role_name,
content: role.content,
tool_calls: toolCallResults,
is_conclusion: role.is_conclusion || false,
},
})}\n\n`));
await delay(500);