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

Function agentLlmCommand

src/commands/agent-llm.ts:12–199  ·  view source on GitHub ↗
(program: Command)

Source from the content-addressed store, hash-verified

10 * 注册智能聊天命令
11 */
12export function agentLlmCommand(program: Command) {
13 program
14 .command('chat')
15 .description('🤖 智能 Agent 聊天')
16 .argument('[question...]', '要问的问题(可选)')
17 .option('-p, --provider <provider>', '选择 LLM 提供商 (volcengine|qwen)')
18 .option('-k, --api-key <key>', 'API 密钥')
19 .option('-m, --model <model>', '指定模型')
20 .option('-s, --scenario <scenario>', '选择场景 (customer|code|assistant)', 'assistant')
21 .option('-i, --interactive', '启动交互式聊天模式', false)
22 .option('--stream', '启用流式输出', false)
23 .option('--demo', '运行场景演示', false)
24 .option('--context', '启用上下文管理(记住对话历史)', false)
25 .option('--context-session <sessionId>', '加载指定的上下文会话')
26 .option('--context-user <userId>', '指定用户ID用于上下文管理', 'default-user')
27 .option('--mcp [servers...]', '启用 MCP 并连接到指定服务器(可指定多个)')
28 .action(async (questionArgs, options) => {
29 try {
30 // 使用用户配置作为默认值
31 const provider = options.provider || getCurrentProvider();
32
33 // 验证提供商
34 if (!isProviderSupported(provider)) {
35 console.log(chalk.red(`❌ 不支持的提供商: ${provider}`));
36 console.log(chalk.gray('支持的提供商: qwen, volcengine'));
37 return;
38 }
39
40 // 获取模型(优先级:命令行 > 用户配置 > 默认)
41 const userModel = getCurrentModel(provider);
42 const defaultModel = getProviderConfig(provider).defaultModel;
43 const model = options.model || userModel || defaultModel;
44
45 // 创建 Agent 配置
46 const agentConfig: AgentConfig = {
47 debug: false,
48 llm: {
49 provider: provider,
50 apiKey: options.apiKey,
51 model: model,
52 },
53 tools: {
54 enabled: true,
55 includeBuiltinTools: true,
56 },
57 context: options.context
58 ? {
59 enabled: true,
60 debug: false,
61 storage: {
62 maxMemorySize: 1000,
63 persistentPath: './blade-context',
64 cacheSize: 100,
65 compressionEnabled: true,
66 },
67 defaultFilter: {
68 maxTokens: 4000,
69 maxMessages: 50,

Callers 1

index.tsFile · 0.85

Calls 14

initMethod · 0.95
loadContextSessionMethod · 0.95
createContextSessionMethod · 0.95
destroyMethod · 0.95
getCurrentProviderFunction · 0.85
isProviderSupportedFunction · 0.85
getCurrentModelFunction · 0.85
getProviderConfigFunction · 0.85
getModelDescriptionFunction · 0.85
runScenarioDemoFunction · 0.85
answerSingleQuestionFunction · 0.85
startInteractiveChatFunction · 0.85

Tested by

no test coverage detected