Browse Source

修改ai回复

newdev_shunjiawei
tanlongsheng 2 years ago
parent
commit
a5c063276d
  1. 17
      lib/data/services/deapsound_ai_service.dart

17
lib/data/services/deapsound_ai_service.dart

@ -22,14 +22,25 @@ class DeapsoundAIService implements AiService {
final client = http.Client();
final url = Uri.parse('https://www.deapsound.com/ai/funcchat');
List contextsList = [];
String msg = '';
for (var i = 0; i < messages.length; i++) {
Map item = messages[i];
if (i < messages.length - 1) {
if (item['role'] == 'user') {
contextsList.add(item['content']);
}
} else {
msg = item['content'];
}
}
final headers = {
'Content-Type': 'application/json',
'Authorization': apiKey,
};
final requestBody = {
"msg": messages.last['content'],
};
final requestBody = {"contexts": contextsList, "msg": msg};
try {
final request = http.Request('POST', url)

Loading…
Cancel
Save