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

Function demonstrateLLMManager

examples/refactored-agent-example.ts:28–58  ·  view source on GitHub ↗

* 示例1: 直接使用 LLM 管理器

()

Source from the content-addressed store, hash-verified

26 * 示例1: 直接使用 LLM 管理器
27 */
28async function demonstrateLLMManager() {
29 console.log('=== 示例1: 直接使用 LLM 管理器 ===');
30
31 try {
32 // 创建独立的 LLM 管理器
33 const llmManager = new LLMManager(true); // 启用调试
34
35 // 配置 LLM
36 llmManager.configure({
37 provider: 'qwen',
38 apiKey: process.env.QWEN_API_KEY || 'your-api-key',
39 model: 'qwen3-235b-a22b',
40 });
41
42 // 初始化
43 await llmManager.init();
44
45 // 基础聊天
46 const response = await llmManager.chat('你好,请介绍一下自己');
47 console.log('LLM 回复:', response.substring(0, 100) + '...');
48
49 // 检查状态
50 console.log('LLM 状态:', llmManager.getStatus());
51
52 // 销毁
53 await llmManager.destroy();
54 console.log('LLM 管理器已销毁\n');
55 } catch (error) {
56 console.error('LLM 管理器示例失败:', error);
57 }
58}
59
60/**
61 * 示例2: 直接使用组件管理器

Callers 1

mainFunction · 0.85

Calls 7

configureMethod · 0.95
initMethod · 0.95
chatMethod · 0.95
getStatusMethod · 0.95
destroyMethod · 0.95
logMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected