api changes

main_production_copilot
Sikander Saleem 14 hours ago
parent 8adec58b38
commit d387f17fad

@ -100,7 +100,7 @@ class CopilotProvider extends ChangeNotifier {
notifyListeners();
}
Future<void> sendText(String query) async {
Future<void> sendText(String query, String language) async {
if (isStreaming || query.trim().isEmpty) return; // prevent invalid duplicate sends
sessionId ??= _generateSessionId();
@ -117,6 +117,8 @@ class CopilotProvider extends ChangeNotifier {
body: {
"sessionId": sessionId!,
"isAudio": "false",
"langId": "$language",
'isFromMobile': 'true',
"query": query,
},
);
@ -126,7 +128,7 @@ class CopilotProvider extends ChangeNotifier {
}
}
Future<void> sendAudio(File audioFile) async {
Future<void> sendAudio(File audioFile, String language) async {
if (isStreaming) return;
sessionId ??= _generateSessionId();
final humanAudioMsg = CopilotMessage(id: UniqueKey().toString(), role: CopilotRole.user, localAudioPath: audioFile.path, timestamp: DateTime.now());
@ -143,6 +145,8 @@ class CopilotProvider extends ChangeNotifier {
fields: {
"sessionId": sessionId!,
"isAudio": "true",
"langId": "$language",
'isFromMobile': 'true',
},
fileFieldName: "AudioFile",
file: audioFile,

@ -71,7 +71,7 @@ class _CopilotChatPageState extends State<CopilotChatPage> {
final text = _textController.text.trim();
if (text.isEmpty) return;
_textController.clear();
context.read<CopilotProvider>().sendText(text);
context.read<CopilotProvider>().sendText(text, context.settingProvider.language!);
_scrollToBottom();
}
@ -101,7 +101,7 @@ class _CopilotChatPageState extends State<CopilotChatPage> {
void _sendRecording() async {
if (_recordedFilePath == null) return;
final file = File(_recordedFilePath!);
context.read<CopilotProvider>().sendAudio(file);
context.read<CopilotProvider>().sendAudio(file, context.settingProvider.language!);
await _recordedPlayerController.stopPlayer();
_recorderController.reset();
_recordedFilePath = null;

Loading…
Cancel
Save