MCPcopy Create free account
hub / github.com/echoVic/blade-code / main

Function main

examples/qwen-function-call-example.ts:9–37  ·  view source on GitHub ↗

* Qwen Function Call 功能示例 * 演示如何使用 Qwen 模型的现代 tools 接口和传统 functions 接口

()

Source from the content-addressed store, hash-verified

7 */
8
9async function main() {
10 console.log('=== Qwen Function Call 示例 ===\n');
11
12 // 初始化 Qwen LLM
13 const qwenLLM = new QwenLLM({
14 apiKey: process.env.QWEN_API_KEY || 'your-api-key',
15 // baseURL: 'https://dashscope.aliyuncs.com/compatible-mode/v1', // 可选
16 });
17
18 await qwenLLM.init();
19
20 // 创建工具管理器
21 const toolManager = await createToolManager();
22 const availableTools = toolManager.getAllTools();
23
24 console.log(`已加载 ${availableTools.length} 个工具\n`);
25
26 // 示例1: 使用现代 Tools 格式
27 await demonstrateToolsFormat(qwenLLM, availableTools);
28
29 // 示例2: 使用传统 Functions 格式
30 await demonstrateFunctionsFormat(qwenLLM, availableTools);
31
32 // 示例3: 自动选择最佳格式
33 await demonstrateSmartFunctionCall(qwenLLM, availableTools);
34
35 // 示例4: 完整的工具调用工作流
36 await demonstrateToolWorkflow(qwenLLM, toolManager);
37}
38
39/**
40 * 示例1: 使用现代 OpenAI Tools 格式

Callers 1

Calls 8

initMethod · 0.95
createToolManagerFunction · 0.85
demonstrateToolsFormatFunction · 0.85
demonstrateToolWorkflowFunction · 0.85
getAllToolsMethod · 0.80
logMethod · 0.45

Tested by

no test coverage detected