* 启动智能客服
(config: AgentConfig)
| 596 | * 启动智能客服 |
| 597 | */ |
| 598 | async function startCustomerService(config: AgentConfig) { |
| 599 | console.log(chalk.cyan('\n=== 🎧 智能客服 Agent ===')); |
| 600 | |
| 601 | const agent = new Agent(config); |
| 602 | await agent.init(); |
| 603 | |
| 604 | const scenarios = [ |
| 605 | '我想了解你们的退货政策', |
| 606 | '这个产品质量太差了,我要求退款!', |
| 607 | '请问你们有什么优惠活动吗?', |
| 608 | ]; |
| 609 | |
| 610 | for (const inquiry of scenarios) { |
| 611 | console.log(chalk.yellow(`\n客户: ${inquiry}`)); |
| 612 | |
| 613 | try { |
| 614 | const systemPrompt = '你是专业的客服代表,友好耐心地解答问题'; |
| 615 | const response = await agent.chatWithSystem(systemPrompt, inquiry); |
| 616 | console.log(chalk.green(`客服: ${response}`)); |
| 617 | |
| 618 | if (inquiry.includes('质量太差')) { |
| 619 | console.log(chalk.gray('\n分析客户情绪...')); |
| 620 | const sentiment = await agent.analyzeSentiment(inquiry); |
| 621 | console.log(chalk.blue(`情绪分析: ${sentiment}`)); |
| 622 | } |
| 623 | } catch (error) { |
| 624 | console.error(chalk.red('❌ 处理失败:'), error); |
| 625 | } |
| 626 | } |
| 627 | |
| 628 | await agent.destroy(); |
| 629 | console.log(chalk.green('\n✅ 客服演示完成')); |
| 630 | } |
| 631 | |
| 632 | /** |
| 633 | * 启动代码助手 |
no test coverage detected