forked from AppFlowy-IO/AppFlowy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
style: Merge branch 'main' into feat/board-text-direction
* main: fix: integration test failed (grid row detail page: hide and show hidden fields) (AppFlowy-IO#5781) feat: ai billing (AppFlowy-IO#5741) fix: can not display rows when rows overthan 1000 (AppFlowy-IO#5777) feat: support publish database on web (AppFlowy-IO#5748) feat: publish databse to Web (AppFlowy-IO#5709) chore: update Spanish translations (AppFlowy-IO#5742) chore: update Chinese translations (AppFlowy-IO#5727) fix: Add retry for admin client sign in for test (AppFlowy-IO#5767) chore: update Hebrew translation (AppFlowy-IO#5738) chore: update German translations (AppFlowy-IO#5722) chore: update Russian translations (AppFlowy-IO#5730) chore: update build config (AppFlowy-IO#5759) chore: enable local ai and local ai chat (AppFlowy-IO#5755) chore: bump version 0.6.4 (AppFlowy-IO#5744) fix: improve color selector (AppFlowy-IO#5743) fix: reset space relationship when clearing cache (AppFlowy-IO#5737) chore: show plugin state (AppFlowy-IO#5740) chore: download llm files (AppFlowy-IO#5723) feat: optimize the read recent views speed (AppFlowy-IO#5726) chore: fix compile (AppFlowy-IO#5733)
- Loading branch information
Showing
351 changed files
with
15,306 additions
and
4,156 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
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
86 changes: 86 additions & 0 deletions
86
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,86 @@ | ||
import 'package:appflowy/workspace/application/settings/ai/local_llm_listener.dart'; | ||
import 'package:appflowy_backend/dispatch/dispatch.dart'; | ||
import 'package:appflowy_backend/log.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, | ||
}) : listener = LocalLLMListener(), | ||
super(const ChatFileState()) { | ||
listener.start( | ||
chatStateCallback: (chatState) { | ||
if (!isClosed) { | ||
add(ChatFileEvent.updateChatState(chatState)); | ||
} | ||
}, | ||
); | ||
|
||
on<ChatFileEvent>( | ||
(event, emit) async { | ||
await event.when( | ||
initial: () async { | ||
final result = await ChatEventGetLocalAIChatState().send(); | ||
result.fold( | ||
(chatState) { | ||
if (!isClosed) { | ||
add( | ||
ChatFileEvent.updateChatState(chatState), | ||
); | ||
} | ||
}, | ||
(err) { | ||
Log.error(err.toString()); | ||
}, | ||
); | ||
}, | ||
newFile: (String filePath) { | ||
final payload = ChatFilePB(filePath: filePath, chatId: chatId); | ||
ChatEventChatWithFile(payload).send(); | ||
}, | ||
updateChatState: (LocalAIChatPB chatState) { | ||
// Only user enable chat with file and the plugin is already running | ||
final supportChatWithFile = chatState.fileEnabled && | ||
chatState.pluginState.state == RunningStatePB.Running; | ||
emit( | ||
state.copyWith(supportChatWithFile: supportChatWithFile), | ||
); | ||
}, | ||
); | ||
}, | ||
); | ||
} | ||
|
||
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.updateChatState(LocalAIChatPB chatState) = | ||
_UpdateChatState; | ||
} | ||
|
||
@freezed | ||
class ChatFileState with _$ChatFileState { | ||
const factory ChatFileState({ | ||
@Default(false) bool supportChatWithFile, | ||
}) = _ChatFileState; | ||
} | ||
|
||
@freezed | ||
class LocalAIChatFileIndicator with _$LocalAIChatFileIndicator { | ||
const factory LocalAIChatFileIndicator.ready(bool isEnabled) = _Ready; | ||
const factory LocalAIChatFileIndicator.loading() = _Loading; | ||
} |
73 changes: 73 additions & 0 deletions
73
frontend/appflowy_flutter/lib/plugins/ai_chat/application/chat_input_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,73 @@ | ||
import 'dart:async'; | ||
|
||
import 'package:appflowy/workspace/application/settings/ai/local_llm_listener.dart'; | ||
import 'package:appflowy_backend/dispatch/dispatch.dart'; | ||
import 'package:appflowy_backend/log.dart'; | ||
import 'package:appflowy_backend/protobuf/flowy-chat/entities.pb.dart'; | ||
import 'package:bloc/bloc.dart'; | ||
import 'package:freezed_annotation/freezed_annotation.dart'; | ||
part 'chat_input_bloc.freezed.dart'; | ||
|
||
class ChatInputBloc extends Bloc<ChatInputEvent, ChatInputState> { | ||
ChatInputBloc() | ||
: listener = LocalLLMListener(), | ||
super(const ChatInputState(aiType: _AppFlowyAI())) { | ||
listener.start( | ||
stateCallback: (pluginState) { | ||
if (!isClosed) { | ||
add(ChatInputEvent.updateState(pluginState)); | ||
} | ||
}, | ||
); | ||
|
||
on<ChatInputEvent>(_handleEvent); | ||
} | ||
|
||
final LocalLLMListener listener; | ||
|
||
@override | ||
Future<void> close() async { | ||
await listener.stop(); | ||
return super.close(); | ||
} | ||
|
||
Future<void> _handleEvent( | ||
ChatInputEvent event, | ||
Emitter<ChatInputState> emit, | ||
) async { | ||
await event.when( | ||
started: () async { | ||
final result = await ChatEventGetLocalAIPluginState().send(); | ||
result.fold( | ||
(pluginState) { | ||
if (!isClosed) { | ||
add(ChatInputEvent.updateState(pluginState)); | ||
} | ||
}, | ||
(err) => Log.error(err.toString()), | ||
); | ||
}, | ||
updateState: (LocalAIPluginStatePB aiPluginState) { | ||
emit(const ChatInputState(aiType: _AppFlowyAI())); | ||
}, | ||
); | ||
} | ||
} | ||
|
||
@freezed | ||
class ChatInputEvent with _$ChatInputEvent { | ||
const factory ChatInputEvent.started() = _Started; | ||
const factory ChatInputEvent.updateState(LocalAIPluginStatePB aiPluginState) = | ||
_UpdatePluginState; | ||
} | ||
|
||
@freezed | ||
class ChatInputState with _$ChatInputState { | ||
const factory ChatInputState({required AIType aiType}) = _ChatInputState; | ||
} | ||
|
||
@freezed | ||
class AIType with _$AIType { | ||
const factory AIType.appflowyAI() = _AppFlowyAI; | ||
const factory AIType.localAI() = _LocalAI; | ||
} |
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.