Skip to content

Commit

Permalink
added clear icon button to the voice-chat appbar to clear the chat bu…
Browse files Browse the repository at this point in the history
…bble list. Also repaired the voice chat null error in api_services_voice.dart with a valid api key the voice chat should be working well
  • Loading branch information
aivan2798 committed Oct 23, 2023
1 parent af1432e commit 4c4bc01
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/constants/api_consts.dart
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
String BASE_URL = "https://api.openai.com/v1";
String API_KEY = "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";
String API_KEY ="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";
21 changes: 21 additions & 0 deletions lib/screens/voice_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ scroolMethod() {
}

class _VoiceScreenState extends State<VoiceScreen> {

void clearChat()
{
setState(() {
messages.clear();
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
Expand All @@ -50,6 +57,7 @@ class _VoiceScreenState extends State<VoiceScreen> {
speechToText.listen(onResult: (result) {
setState(() {
text = result.recognizedWords;

});
});
});
Expand Down Expand Up @@ -107,6 +115,18 @@ class _VoiceScreenState extends State<VoiceScreen> {
),
),
]),
actions: [
IconButton(onPressed: ()
{
// chatProvider.clearMessages();
clearChat();
print("all cleared");
},
icon: Icon(Icons.clear_all_rounded)),



],

backgroundColor: Colors.orange[200],
shape: const RoundedRectangleBorder(
Expand Down Expand Up @@ -245,6 +265,7 @@ Widget chatBubble({required chattext, required ChatMessageType? type}) {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
CircleAvatar(

backgroundColor: Colors.white,
child: Image.asset(
AssetsManager.userImage,
Expand Down
4 changes: 2 additions & 2 deletions lib/services/api_services_voice.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class ApiSercivesVoice {
headers: header,
body: jsonEncode( {
"model": "text-davinci-003",
"promt": '$message',
"prompt": '$message',
"temperature": 0,
"max_tokens":100,
"top_p": 1,
Expand All @@ -29,7 +29,7 @@ class ApiSercivesVoice {
"stop": ["Human ", "AI"]
})
);

print(res.body);
if (res.statusCode==200) {
var data = jsonDecode(res.body.toString());
var msg = data ['choices'] [ 0]['text'];
Expand Down

1 comment on commit 4c4bc01

@aivan2798
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

edited the voice chat ui

Please sign in to comment.