大模型(LLM) Agent Toy(一) - 简易语音助手

date
Jun 5, 2024
slug
简易语音助手
status
Published
tags
Agent
大模型(LLM)
人工智能(AI)
summary
通过本文你将了解如何基于Chatgpt构建一个简易语音助手,它可以接受你的语音输入、回答问题并且还可以执行特定操作,适用于希望用户使用自然语言与应用程序进行交互的场景。语音助手设计实现中包含了意图识别以及对于不同意图执行不同功能的产品特性。
type
Post
 
通过本文你将了解如何基于Chatgpt构建一个简易语音助手,它可以接受你的语音输入、回答问题并且还可以执行特定操作,适用于希望用户使用自然语言与应用程序进行交互的场景。

功能介绍

简易语音助手实现的功能简单如下图所示,其中用户意图分为三种:QUESTION(问题)、WRITE_EMAIL(写邮件)和OTHER(其他)。功能分为四种:ANSWER(回答问题)、MORE(更多信息)、ACTION_WRITE_EMAIL(写邮件内容)和OTHER(其他)。
notion image
各意图和功能之间的状态转移关系如下图所示。
notion image

功能演示

语音助手界面如下面两图所示。上图是助手启动界面,下图是在输入语音”原子是由什么构成的”后系统返回结果的界面。一个简易语音助手agent功能初步达到。
notion image
notion image
在输入语音”原子是由什么构成的”后,系统的重要中间结果如下所示,可以结合最后的代码模块来加深彼此的理解。
  • [{'role': 'user', 'content': 'Classify the intent of the next input. Is it: WRITE_EMAIL, QUESTION, OTHER ? Only answer one word.'}, {'role': 'user', 'content': 'the question is: 原子是有什麼組成的?'}]
  • [{'role': 'user', 'content': 'Classify the intent of the next input. Is it: WRITE_EMAIL, QUESTION, OTHER ? Only answer one word.'}, {'role': 'user', 'content': 'the question is: 原子是有什麼組成的?'}, {'role': 'assistant', 'content': 'QUESTION'}, {'role': 'user', 'content': 'If you can answer the question: ANSWER, if you need more information: MORE, if you can not answer: OTHER. Only answer one word.'}]
  • [{'role': 'user', 'content': 'Classify the intent of the next input. Is it: WRITE_EMAIL, QUESTION, OTHER ? Only answer one word.'}, {'role': 'user', 'content': 'the question is: 原子是有什麼組成的?'}, {'role': 'assistant', 'content': 'QUESTION'}, {'role': 'user', 'content': 'If you can answer the question: ANSWER, if you need more information: MORE, if you can not answer: OTHER. Only answer one word.'}, {'role': 'assistant', 'content': 'ANSWER'}, {'role': 'user', 'content': 'Now answer the original question'}]

代码


© ShanJ 2021 - 2024