added multimedia support and STT. STT and photos are have bugs but are functional. file upload is conceptualized but will require additional backend work. video is on hold for now.
This commit is contained in:
@@ -1,9 +1,32 @@
|
||||
class Chat {
|
||||
final String content;
|
||||
final bool role;
|
||||
int chatType = 0;
|
||||
|
||||
// Most basic chat, text from server or from user.
|
||||
Chat(this.content, this.role);
|
||||
Chat(this.content, this.role, this.chatType);
|
||||
|
||||
// TODO: Overload constructors to allow for multimedia.
|
||||
// A chat with an included image.
|
||||
Chat.image(this.content, this.role, this.chatType);
|
||||
|
||||
// A chat with an included file.
|
||||
Chat.file(this.content, this.role, this.chatType);
|
||||
}
|
||||
|
||||
// TODO: Add proper filetype support. File should either be parsed on-device, or uploaded to the server.
|
||||
// TODO: Implement dynamic pathing based upon filetypes.
|
||||
enum Filetype {
|
||||
pdf,
|
||||
doc,
|
||||
docx,
|
||||
pages,
|
||||
note,
|
||||
todo,
|
||||
cal,
|
||||
calendar,
|
||||
event,
|
||||
contact,
|
||||
mp3,
|
||||
mp4,
|
||||
wav,
|
||||
}
|
||||
@@ -1,3 +1,6 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:app/components/util/backend.dart';
|
||||
import 'package:app/theme.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'chat.dart';
|
||||
@@ -29,10 +32,20 @@ class ChatBubbleWidget extends StatelessWidget{
|
||||
),
|
||||
color: c.role ? AppTheme.darkest : AppTheme.dark,
|
||||
),
|
||||
child: Text(
|
||||
c.content,
|
||||
style: AppTheme.bodyMedium,
|
||||
),
|
||||
child:
|
||||
// TODO: Properly display filetypes in the thread.
|
||||
c.chatType == 0 ? Text(
|
||||
c.content,
|
||||
style: AppTheme.bodyMedium,
|
||||
)
|
||||
: c.chatType == 1 ? Image(image: Backend.convertFromBase64(c.content))
|
||||
: c.chatType == 2 ? const Icon(
|
||||
Icons.file_copy,
|
||||
) : const Text("null"),
|
||||
// Text(
|
||||
// c.content,
|
||||
// style: AppTheme.bodyMedium,
|
||||
// ),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import 'package:app/util/backend.dart';
|
||||
import 'package:app/components/util/backend.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'chat.dart';
|
||||
|
||||
@@ -6,10 +6,12 @@ class Conversation with ChangeNotifier {
|
||||
int conversationID;
|
||||
String conversationLabel;
|
||||
String conversationSubLabel;
|
||||
bool history = true;
|
||||
// History is disabled by default. This means chats are auto-deleted once the user exits that conversation.
|
||||
// TODO: Fix history, very, verry strange behavior when disabled.
|
||||
bool history = true; // History is disabled by default. This means chats are auto-deleted once the user exits that conversation.\
|
||||
bool conversationContext = true; // The prior prompts and responses are used as additional context for the next prompt and response.
|
||||
late bool stream = false; // Update the UI with a stream of characters as received from the server, or as one text.
|
||||
var lastAccessTime = DateTime.timestamp(); // Used to sort conversations based on most recent usage.
|
||||
|
||||
List<Chat> chats = [];
|
||||
|
||||
Conversation(this.conversationID, this.conversationLabel, this.conversationSubLabel);
|
||||
@@ -23,11 +25,13 @@ class Conversation with ChangeNotifier {
|
||||
void toggleStream() => stream = !stream;
|
||||
|
||||
void add(Chat message) {
|
||||
lastAccessTime = DateTime.timestamp();
|
||||
chats.add(message);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void loadChats() {
|
||||
lastAccessTime = DateTime.timestamp();
|
||||
Backend.loadConversation;
|
||||
chats = Backend.loadedChats;
|
||||
}
|
||||
@@ -41,10 +45,12 @@ class Conversation with ChangeNotifier {
|
||||
}
|
||||
|
||||
List<Chat> getChats() {
|
||||
lastAccessTime = DateTime.timestamp();
|
||||
return chats;
|
||||
}
|
||||
|
||||
void setLabels(String cLabel, String cSubLabel) {
|
||||
lastAccessTime = DateTime.timestamp();
|
||||
conversationLabel = cLabel;
|
||||
conversationSubLabel = cSubLabel;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'package:app/components/conversation_thread/chat_bubble_model.dart';
|
||||
import 'package:app/components/conversation_thread/chat.dart';
|
||||
import 'package:app/components/conversation_thread/conversation.dart';
|
||||
import 'package:app/util/backend.dart';
|
||||
import 'package:app/components/util/backend.dart';
|
||||
|
||||
import 'package:app/components/prompt_box/prompt_box_widget.dart';
|
||||
import 'package:flutterflow_ui/flutterflow_ui.dart';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import 'package:app/components/conversation_thread/conversation.dart';
|
||||
import 'package:app/util/backend.dart';
|
||||
import 'package:app/components/util/backend.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '/components/conversation_thread/chat_bubble_widget.dart';
|
||||
@@ -50,6 +50,7 @@ class _ConversationThreadWidgetState extends State<ConversationThreadWidget> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// TODO: Add a scrollbar
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
height: double.infinity,
|
||||
|
||||
Reference in New Issue
Block a user