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

Function startBasicAssistant

src/commands/agent-llm.ts:675–716  ·  view source on GitHub ↗

* 启动基础助手

(config: AgentConfig)

Source from the content-addressed store, hash-verified

673 * 启动基础助手
674 */
675async function startBasicAssistant(config: AgentConfig) {
676 console.log(chalk.cyan('\n=== 🤖 智能助手 Agent ==='));
677
678 const agent = new Agent(config);
679 await agent.init();
680
681 // 显示 Agent 状态
682 const status = agent.getStatus();
683 console.log(
684 chalk.gray(`Agent 状态: LLM=${status.llmProvider}, 组件数=${status.components.componentCount}`)
685 );
686
687 try {
688 // 智能问答
689 console.log(chalk.yellow('\n问题: 什么是微服务架构?'));
690 const answer = await agent.ask('什么是微服务架构?请简洁地解释');
691 console.log(chalk.green(`回答: ${answer}`));
692
693 // 代码生成
694 console.log(chalk.yellow('\n请求: 生成快速排序算法'));
695 const code = await agent.generateCode('实现快速排序算法', 'python');
696 console.log(chalk.green(`生成的代码:\n${code}`));
697
698 // 流式回答
699 console.log(chalk.yellow('\n流式问答: 解释区块链技术'));
700 process.stdout.write(chalk.green('AI: '));
701
702 const messages: LLMMessage[] = [
703 { role: 'user' as const, content: '请简单解释什么是区块链技术' },
704 ];
705
706 await agent.streamChat(messages, chunk => {
707 process.stdout.write(chunk);
708 });
709 console.log('\n');
710 } catch (error) {
711 console.error(chalk.red('❌ 助手操作失败:'), error);
712 }
713
714 await agent.destroy();
715 console.log(chalk.green('\n✅ 智能助手演示完成'));
716}

Callers 1

runScenarioDemoFunction · 0.85

Calls 8

initMethod · 0.95
getStatusMethod · 0.95
askMethod · 0.95
generateCodeMethod · 0.95
streamChatMethod · 0.95
destroyMethod · 0.95
logMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected