UPDATE README
This commit is contained in:
@@ -1,16 +1,92 @@
|
||||
# example
|
||||
# AI Chat Assistant Example
|
||||
|
||||
A new Flutter project.
|
||||
这是 AI Chat Assistant Flutter 插件的示例应用,展示了如何集成和使用 AI 聊天助手功能。
|
||||
|
||||
## Getting Started
|
||||
## 🚀 快速开始
|
||||
|
||||
This project is a starting point for a Flutter application.
|
||||
### 1. 安装依赖
|
||||
|
||||
A few resources to get you started if this is your first Flutter project:
|
||||
```bash
|
||||
cd example
|
||||
flutter pub get
|
||||
```
|
||||
|
||||
- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab)
|
||||
- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook)
|
||||
### 2. 运行应用
|
||||
|
||||
For help getting started with Flutter development, view the
|
||||
[online documentation](https://docs.flutter.dev/), which offers tutorials,
|
||||
samples, guidance on mobile development, and a full API reference.
|
||||
```bash
|
||||
flutter run
|
||||
```
|
||||
|
||||
## 📱 示例功能
|
||||
|
||||
### 车控命令处理器示例
|
||||
|
||||
本示例展示了如何实现自定义的车控命令处理器:
|
||||
|
||||
```dart
|
||||
class VehicleCommandClent extends VehicleCommandHandler {
|
||||
@override
|
||||
Future<(bool, Map<String, dynamic>?)> executeCommand(VehicleCommand command) async {
|
||||
// 在这里实现具体的车控命令执行逻辑
|
||||
print('执行车控命令: ${command.type}, 参数: ${command.params}');
|
||||
|
||||
// 更新命令状态为执行中
|
||||
commandCubit?.emit(AIChatCommandState(
|
||||
commandId: command.commandId,
|
||||
commandType: command.type,
|
||||
params: command.params,
|
||||
status: AIChatCommandStatus.executing,
|
||||
timestamp: DateTime.now(),
|
||||
));
|
||||
|
||||
// 模拟命令执行
|
||||
await Future.delayed(const Duration(seconds: 2));
|
||||
|
||||
// 更新命令状态为成功
|
||||
commandCubit?.emit(AIChatCommandState(
|
||||
commandId: command.commandId,
|
||||
commandType: command.type,
|
||||
params: command.params,
|
||||
status: AIChatCommandStatus.success,
|
||||
timestamp: DateTime.now(),
|
||||
result: {'message': '命令执行成功'},
|
||||
));
|
||||
|
||||
return (true, {'message': '命令已执行'});
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 初始化示例
|
||||
|
||||
```dart
|
||||
void main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
// 请求麦克风权限
|
||||
if (!await Permission.microphone.isGranted) {
|
||||
await Permission.microphone.request();
|
||||
}
|
||||
|
||||
// 初始化 AI Chat Assistant,注册车控命令处理器
|
||||
AIChatAssistantManager.instance.setupCommandHandle(
|
||||
commandHandler: VehicleCommandClent()
|
||||
);
|
||||
|
||||
runApp(const MyApp());
|
||||
}
|
||||
```
|
||||
|
||||
## 🎯 示例特性
|
||||
|
||||
- ✅ 完整的车控命令处理示例
|
||||
- ✅ 权限管理示例
|
||||
- ✅ 状态管理集成
|
||||
- ✅ AI 聊天界面集成
|
||||
- ✅ 语音识别功能
|
||||
- ✅ TTS 语音播报
|
||||
|
||||
## 📖 了解更多
|
||||
|
||||
- 查看主项目 [README](../README.md) 了解完整的功能特性
|
||||
- 查看 [API 文档](../README.md#-api-文档) 了解接口使用方法
|
||||
|
||||
Reference in New Issue
Block a user