-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into fix_move_relationships
- Loading branch information
Showing
72 changed files
with
3,976 additions
and
1,052 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
frontend/appflowy_flutter/lib/plugins/ai_chat/application/chat_file_bloc.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import 'package:appflowy/workspace/application/settings/ai/local_llm_listener.dart'; | ||
import 'package:appflowy_backend/dispatch/dispatch.dart'; | ||
import 'package:appflowy_backend/protobuf/flowy-chat/entities.pb.dart'; | ||
import 'package:flutter_bloc/flutter_bloc.dart'; | ||
import 'package:freezed_annotation/freezed_annotation.dart'; | ||
|
||
part 'chat_file_bloc.freezed.dart'; | ||
|
||
class ChatFileBloc extends Bloc<ChatFileEvent, ChatFileState> { | ||
ChatFileBloc({ | ||
required String chatId, | ||
dynamic message, | ||
}) : listener = LocalLLMListener(), | ||
super(ChatFileState.initial(message)) { | ||
listener.start( | ||
stateCallback: (pluginState) { | ||
if (!isClosed) { | ||
add(ChatFileEvent.updateLocalAIState(pluginState)); | ||
} | ||
}, | ||
); | ||
|
||
on<ChatFileEvent>( | ||
(event, emit) async { | ||
await event.when( | ||
initial: () async { | ||
final result = await ChatEventGetPluginState().send(); | ||
result.fold( | ||
(pluginState) { | ||
if (!isClosed) { | ||
add(ChatFileEvent.updateLocalAIState(pluginState)); | ||
} | ||
}, | ||
(err) {}, | ||
); | ||
}, | ||
newFile: (String filePath) { | ||
final payload = ChatFilePB(filePath: filePath, chatId: chatId); | ||
ChatEventChatWithFile(payload).send(); | ||
}, | ||
updateLocalAIState: (PluginStatePB pluginState) { | ||
emit( | ||
state.copyWith( | ||
supportChatWithFile: | ||
pluginState.state == RunningStatePB.Running, | ||
), | ||
); | ||
}, | ||
); | ||
}, | ||
); | ||
} | ||
|
||
final LocalLLMListener listener; | ||
|
||
@override | ||
Future<void> close() async { | ||
await listener.stop(); | ||
return super.close(); | ||
} | ||
} | ||
|
||
@freezed | ||
class ChatFileEvent with _$ChatFileEvent { | ||
const factory ChatFileEvent.initial() = Initial; | ||
const factory ChatFileEvent.newFile(String filePath) = _NewFile; | ||
const factory ChatFileEvent.updateLocalAIState(PluginStatePB pluginState) = | ||
_UpdateLocalAIState; | ||
} | ||
|
||
@freezed | ||
class ChatFileState with _$ChatFileState { | ||
const factory ChatFileState({ | ||
required String text, | ||
@Default(false) bool supportChatWithFile, | ||
}) = _ChatFileState; | ||
|
||
factory ChatFileState.initial(dynamic text) { | ||
return ChatFileState( | ||
text: text is String ? text : "", | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...pflowy_flutter/lib/plugins/database/widgets/cell/desktop_grid/desktop_grid_text_cell.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.