Skip to content

Commit

Permalink
Merge branch 'main' into refactor_crate_structures
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasXu0 committed Dec 30, 2024
2 parents ebec797 + 38c2937 commit d1cd008
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -272,15 +272,19 @@ class ChatBloc extends Bloc<ChatEvent, ChatState> {

// 3 mean message response from AI
if (pb.authorType == 3 && answerStreamMessageId.isNotEmpty) {
temporaryMessageIDMap[pb.messageId.toString()] =
answerStreamMessageId;
temporaryMessageIDMap.putIfAbsent(
pb.messageId.toString(),
() => answerStreamMessageId,
);
answerStreamMessageId = '';
}

// 1 mean message response from User
if (pb.authorType == 1 && questionStreamMessageId.isNotEmpty) {
temporaryMessageIDMap[pb.messageId.toString()] =
questionStreamMessageId;
temporaryMessageIDMap.putIfAbsent(
pb.messageId.toString(),
() => questionStreamMessageId,
);
questionStreamMessageId = '';
}

Expand Down Expand Up @@ -422,8 +426,9 @@ class ChatBloc extends Bloc<ChatEvent, ChatState> {
(question) {
if (!isClosed) {
final streamAnswer = _createAnswerStreamMessage(
answerStream!,
question.messageId,
stream: answerStream!,
questionMessageId: question.messageId,
fakeQuestionMessageId: questionStreamMessage.id,
);

lastSentMessage = question;
Expand Down Expand Up @@ -479,8 +484,8 @@ class ChatBloc extends Bloc<ChatEvent, ChatState> {
(success) {
if (!isClosed) {
final streamAnswer = _createAnswerStreamMessage(
answerStream!,
answerMessageId - 1,
stream: answerStream!,
questionMessageId: answerMessageId - 1,
).copyWith(id: answerMessageIdString);

add(ChatEvent.receiveMessage(streamAnswer));
Expand All @@ -491,11 +496,14 @@ class ChatBloc extends Bloc<ChatEvent, ChatState> {
);
}

Message _createAnswerStreamMessage(
AnswerStream stream,
Int64 questionMessageId,
) {
answerStreamMessageId = (questionMessageId + 1).toString();
Message _createAnswerStreamMessage({
required AnswerStream stream,
required Int64 questionMessageId,
String? fakeQuestionMessageId,
}) {
answerStreamMessageId = fakeQuestionMessageId == null
? (questionMessageId + 1).toString()
: "${fakeQuestionMessageId}_ans";

return TextMessage(
id: answerStreamMessageId,
Expand Down
3 changes: 2 additions & 1 deletion frontend/scripts/docker-buildfiles/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ RUN dart pub global activate protoc_plugin 21.1.2
# Install build dependencies for AppFlowy using pacman
RUN sudo pacman -S --needed --noconfirm jemalloc git libkeybinder3 sqlite clang rsync libnotify rocksdb zstd mpv
RUN sudo ln -s /usr/bin/sha1sum /usr/bin/shasum
RUN source ~/.cargo/env && cargo install cargo-make cargo-binstall --locked
RUN source ~/.cargo/env && cargo install cargo-make --version 0.37.18 --locked
RUN source ~/.cargo/env && cargo install cargo-binstall --version 1.10.17 --locked
RUN source ~/.cargo/env && cargo binstall duckscript_cli --locked -y

# Build AppFlowy
Expand Down

0 comments on commit d1cd008

Please sign in to comment.