|
|
|
@ -1,3 +1,5 @@ |
|
|
|
import 'dart:async'; |
|
|
|
|
|
|
|
import 'package:flutter/material.dart'; |
|
|
|
import 'package:flutter_easyloading/flutter_easyloading.dart'; |
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
|
|
|
@ -5,6 +7,7 @@ import 'package:get/get.dart'; |
|
|
|
import 'package:get_storage/get_storage.dart'; |
|
|
|
|
|
|
|
import '../../../../data/services/db/sqflite_api.dart'; |
|
|
|
import '../../../../data/services/deapsound_ai_service.dart'; |
|
|
|
import '../../../../data/services/network/api.dart'; |
|
|
|
import '../../controllers/meeting_details_controller.dart'; |
|
|
|
|
|
|
|
@ -27,6 +30,10 @@ class _TemplateEditViewState extends State<TemplateEditView> { |
|
|
|
|
|
|
|
bool _isEnable = false; |
|
|
|
|
|
|
|
final _deapsoundAI = DeapsoundAIService(); |
|
|
|
StreamSubscription? _aiResponseSubscription; |
|
|
|
bool _isLoading = false; |
|
|
|
|
|
|
|
@override |
|
|
|
void initState() { |
|
|
|
super.initState(); |
|
|
|
@ -42,6 +49,7 @@ class _TemplateEditViewState extends State<TemplateEditView> { |
|
|
|
_nameController.dispose(); |
|
|
|
_descController.dispose(); |
|
|
|
_promptController.dispose(); |
|
|
|
_aiResponseSubscription?.cancel(); |
|
|
|
super.dispose(); |
|
|
|
} |
|
|
|
|
|
|
|
@ -151,15 +159,42 @@ class _TemplateEditViewState extends State<TemplateEditView> { |
|
|
|
return Column( |
|
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
|
children: [ |
|
|
|
Padding( |
|
|
|
padding: EdgeInsets.only(left: 10.w), |
|
|
|
child: Text( |
|
|
|
title, |
|
|
|
style: TextStyle( |
|
|
|
fontSize: 14.sp, |
|
|
|
color: isDarkMode ? Colors.white60 : Colors.black87, |
|
|
|
Row( |
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween, |
|
|
|
children: [ |
|
|
|
Padding( |
|
|
|
padding: EdgeInsets.only(left: 10.w), |
|
|
|
child: Text( |
|
|
|
title, |
|
|
|
style: TextStyle( |
|
|
|
fontSize: 14.sp, |
|
|
|
color: isDarkMode ? Colors.white60 : Colors.black87, |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
if (maxLines > 1) |
|
|
|
GestureDetector( |
|
|
|
onTap: () { |
|
|
|
_generateTemplatePrompt(); |
|
|
|
}, |
|
|
|
child: Container( |
|
|
|
width: 26.w, |
|
|
|
height: 26.w, |
|
|
|
margin: EdgeInsets.only(right: 10.w), |
|
|
|
decoration: BoxDecoration( |
|
|
|
color: _isLoading |
|
|
|
? const Color(0xFF4C3F91) |
|
|
|
: const Color(0xFF6A5AE0), |
|
|
|
borderRadius: BorderRadius.circular(26.r), |
|
|
|
), |
|
|
|
child: Icon( |
|
|
|
_isLoading ? Icons.pause : Icons.smart_toy, |
|
|
|
size: 18.w, |
|
|
|
color: Colors.white, |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
], |
|
|
|
), |
|
|
|
Container( |
|
|
|
margin: EdgeInsets.only(top: 10.w, bottom: 20.w), |
|
|
|
@ -293,4 +328,37 @@ class _TemplateEditViewState extends State<TemplateEditView> { |
|
|
|
}); |
|
|
|
EasyLoading.dismiss(); |
|
|
|
} |
|
|
|
|
|
|
|
void _generateTemplatePrompt() { |
|
|
|
if (_isLoading || |
|
|
|
_nameController.text.isEmpty || |
|
|
|
_descController.text.isEmpty) { |
|
|
|
return; |
|
|
|
} |
|
|
|
_promptController.clear(); |
|
|
|
setState(() { |
|
|
|
_isLoading = true; |
|
|
|
}); |
|
|
|
final responseStream = _deapsoundAI.sendMessageStream( |
|
|
|
messages: [ |
|
|
|
{'role': 'system', 'content': '名称:${_nameController.text}'}, |
|
|
|
{'role': 'system', 'content': '描述:${_descController.text}'}, |
|
|
|
{ |
|
|
|
'role': 'user', |
|
|
|
'content': |
|
|
|
'请基于以上名称与描述,生成一个高质量会议总结提示词(Prompt),用于指导模型对会议记录进行结构化总结。只返回提示词文本,不要提供示例或额外解释。', |
|
|
|
}, |
|
|
|
], |
|
|
|
); |
|
|
|
_aiResponseSubscription = responseStream.listen( |
|
|
|
(chunk) { |
|
|
|
_promptController.text += chunk; |
|
|
|
}, |
|
|
|
onDone: () { |
|
|
|
setState(() { |
|
|
|
_isLoading = false; |
|
|
|
}); |
|
|
|
}, |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|