chore: show reference sources on local ai response (#5933)

* chore: show reference sources on local ai response

* chore: clippy

* chore: clippy

* chore: update i18n

* chore: update client api
This commit is contained in:
Nathan.fooo 2024-08-12 15:43:17 +08:00 committed by GitHub
parent 55a4810d60
commit 1c638dd930
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
22 changed files with 220 additions and 102 deletions

View File

@ -10,6 +10,9 @@ import 'package:appflowy_backend/protobuf/flowy-document/entities.pb.dart';
import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart'; import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';
import 'package:nanoid/nanoid.dart'; import 'package:nanoid/nanoid.dart';
/// Indicate file source from appflowy document
const appflowySoruce = "appflowy";
List<ChatFile> fileListFromMessageMetadata( List<ChatFile> fileListFromMessageMetadata(
Map<String, dynamic>? map, Map<String, dynamic>? map,
) { ) {
@ -75,6 +78,7 @@ List<ChatMessageRefSource> messageReferenceSource(String? s) {
Log.warn("metadata is null"); Log.warn("metadata is null");
return []; return [];
} }
// [{"id":null,"name":"The Five Dysfunctions of a Team.pdf","source":"/Users/weidongfu/Desktop/The Five Dysfunctions of a Team.pdf"}]
if (metadataJson is Map<String, dynamic>) { if (metadataJson is Map<String, dynamic>) {
if (metadataJson.isNotEmpty) { if (metadataJson.isNotEmpty) {
@ -115,7 +119,7 @@ Future<List<ChatMessageMetaPB>> metadataPBFromMetadata(
name: view.name, name: view.name,
data: pb.text, data: pb.text,
dataType: ChatMessageMetaTypePB.Txt, dataType: ChatMessageMetaTypePB.Txt,
source: "appflowy", source: appflowySoruce,
), ),
); );
}, (err) { }, (err) {

View File

@ -19,8 +19,10 @@ class ChatUserMessageBloc
event.when( event.when(
initial: () { initial: () {
if (state.stream != null) { if (state.stream != null) {
if (!isClosed) {
add(ChatUserMessageEvent.updateText(state.stream!.text)); add(ChatUserMessageEvent.updateText(state.stream!.text));
} }
}
state.stream?.listen( state.stream?.listen(
onData: (text) { onData: (text) {

View File

@ -1,5 +1,6 @@
import 'package:appflowy/generated/locale_keys.g.dart'; import 'package:appflowy/generated/locale_keys.g.dart';
import 'package:appflowy/plugins/ai_chat/application/chat_entity.dart'; import 'package:appflowy/plugins/ai_chat/application/chat_entity.dart';
import 'package:appflowy/plugins/ai_chat/application/chat_message_service.dart';
import 'package:easy_localization/easy_localization.dart'; import 'package:easy_localization/easy_localization.dart';
import 'package:flowy_infra_ui/style_widget/button.dart'; import 'package:flowy_infra_ui/style_widget/button.dart';
import 'package:flowy_infra_ui/style_widget/text.dart'; import 'package:flowy_infra_ui/style_widget/text.dart';
@ -53,7 +54,13 @@ class AIMessageMetadata extends StatelessWidget {
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
), ),
), ),
onTap: () => onSelectedMetadata(m), disable: m.source != appflowySoruce,
onTap: () {
if (m.source != appflowySoruce) {
return;
}
onSelectedMetadata(m);
},
), ),
), ),
) )

View File

@ -2,18 +2,20 @@ import 'dart:async';
import 'dart:ffi'; import 'dart:ffi';
import 'dart:isolate'; import 'dart:isolate';
import 'package:appflowy/generated/locale_keys.g.dart';
import 'package:appflowy/plugins/ai_chat/application/chat_entity.dart'; import 'package:appflowy/plugins/ai_chat/application/chat_entity.dart';
import 'package:appflowy_backend/dispatch/dispatch.dart'; import 'package:appflowy_backend/dispatch/dispatch.dart';
import 'package:appflowy_backend/log.dart'; import 'package:appflowy_backend/log.dart';
import 'package:appflowy_backend/protobuf/flowy-ai/entities.pb.dart'; import 'package:appflowy_backend/protobuf/flowy-ai/entities.pb.dart';
import 'package:bloc/bloc.dart'; import 'package:bloc/bloc.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:fixnum/fixnum.dart'; import 'package:fixnum/fixnum.dart';
part 'download_model_bloc.freezed.dart'; part 'download_model_bloc.freezed.dart';
class DownloadModelBloc extends Bloc<DownloadModelEvent, DownloadModelState> { class DownloadModelBloc extends Bloc<DownloadModelEvent, DownloadModelState> {
DownloadModelBloc(LLMModelPB model) DownloadModelBloc(LLMModelPB model)
: super(DownloadModelState(model: model)) { : super(DownloadModelState.initial(model)) {
on<DownloadModelEvent>(_handleEvent); on<DownloadModelEvent>(_handleEvent);
} }
@ -99,8 +101,21 @@ class DownloadModelState with _$DownloadModelState {
@Default("") String object, @Default("") String object,
@Default(0) double percent, @Default(0) double percent,
@Default(false) bool isFinish, @Default(false) bool isFinish,
String? bigFileDownloadPrompt,
@Default(ChatLoadingState.loading()) ChatLoadingState loadingState, @Default(ChatLoadingState.loading()) ChatLoadingState loadingState,
}) = _DownloadModelState; }) = _DownloadModelState;
factory DownloadModelState.initial(LLMModelPB model) {
// bigger than 1 GB then show download big file prompt
String? bigFileDownloadPrompt;
if (model.fileSize > 1 * 1024 * 1024 * 1024) {
bigFileDownloadPrompt = LocaleKeys.settings_aiPage_keys_downloadBigFilePrompt.tr();
}
return DownloadModelState(
model: model,
bigFileDownloadPrompt: bigFileDownloadPrompt,
);
}
} }
class DownloadingStream { class DownloadingStream {

View File

@ -37,10 +37,23 @@ class DownloadingIndicator extends StatelessWidget {
color: Theme.of(context).colorScheme.surfaceContainerHighest, color: Theme.of(context).colorScheme.surfaceContainerHighest,
borderRadius: BorderRadius.circular(8), borderRadius: BorderRadius.circular(8),
), ),
child: Column( child: BlocBuilder<DownloadModelBloc, DownloadModelState>(
builder: (context, state) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
DownloadingProgressBar(onCancel: onCancel), DownloadingProgressBar(onCancel: onCancel),
if (state.bigFileDownloadPrompt != null) ...[
const VSpace(2),
Opacity(
opacity: 0.6,
child:
FlowyText(state.bigFileDownloadPrompt!, fontSize: 11),
),
], ],
],
);
},
), ),
), ),
), ),

View File

@ -121,8 +121,8 @@ class _SettingsPlanViewState extends State<SettingsPlanView> {
priceInfo: LocaleKeys priceInfo: LocaleKeys
.settings_planPage_planUsage_addons_aiMax_priceInfo .settings_planPage_planUsage_addons_aiMax_priceInfo
.tr(), .tr(),
billingInfo: LocaleKeys recommend: LocaleKeys
.settings_planPage_planUsage_addons_aiMax_billingInfo .settings_planPage_planUsage_addons_aiMax_recommend
.tr( .tr(
args: [SubscriptionPlanPB.AiMax.priceMonthBilling], args: [SubscriptionPlanPB.AiMax.priceMonthBilling],
), ),
@ -160,8 +160,8 @@ class _SettingsPlanViewState extends State<SettingsPlanView> {
priceInfo: LocaleKeys priceInfo: LocaleKeys
.settings_planPage_planUsage_addons_aiOnDevice_priceInfo .settings_planPage_planUsage_addons_aiOnDevice_priceInfo
.tr(), .tr(),
billingInfo: LocaleKeys recommend: LocaleKeys
.settings_planPage_planUsage_addons_aiOnDevice_billingInfo .settings_planPage_planUsage_addons_aiOnDevice_recommend
.tr( .tr(
args: [ args: [
SubscriptionPlanPB.AiLocal.priceMonthBilling, SubscriptionPlanPB.AiLocal.priceMonthBilling,
@ -654,7 +654,7 @@ class _AddOnBox extends StatelessWidget {
required this.description, required this.description,
required this.price, required this.price,
required this.priceInfo, required this.priceInfo,
required this.billingInfo, required this.recommend,
required this.buttonText, required this.buttonText,
required this.isActive, required this.isActive,
required this.plan, required this.plan,
@ -664,7 +664,7 @@ class _AddOnBox extends StatelessWidget {
final String description; final String description;
final String price; final String price;
final String priceInfo; final String priceInfo;
final String billingInfo; final String recommend;
final String buttonText; final String buttonText;
final bool isActive; final bool isActive;
final SubscriptionPlanPB plan; final SubscriptionPlanPB plan;
@ -717,7 +717,7 @@ class _AddOnBox extends StatelessWidget {
children: [ children: [
Expanded( Expanded(
child: FlowyText( child: FlowyText(
billingInfo, recommend,
color: AFThemeExtension.of(context).secondaryTextColor, color: AFThemeExtension.of(context).secondaryTextColor,
fontSize: 11, fontSize: 11,
maxLines: 2, maxLines: 2,

View File

@ -172,7 +172,7 @@ checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da"
[[package]] [[package]]
name = "app-error" name = "app-error"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=6a44490daccb101c8b855443d2d6ded0fb752016#6a44490daccb101c8b855443d2d6ded0fb752016" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=7878a018a18553e3d8201e572a0c066c14ba3b35#7878a018a18553e3d8201e572a0c066c14ba3b35"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bincode", "bincode",
@ -192,7 +192,7 @@ dependencies = [
[[package]] [[package]]
name = "appflowy-ai-client" name = "appflowy-ai-client"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=6a44490daccb101c8b855443d2d6ded0fb752016#6a44490daccb101c8b855443d2d6ded0fb752016" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=7878a018a18553e3d8201e572a0c066c14ba3b35#7878a018a18553e3d8201e572a0c066c14ba3b35"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bytes", "bytes",
@ -207,7 +207,7 @@ dependencies = [
[[package]] [[package]]
name = "appflowy-local-ai" name = "appflowy-local-ai"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-LocalAI?rev=65802795ad8778de11c45b5af65d05c973709613#65802795ad8778de11c45b5af65d05c973709613" source = "git+https://github.com/AppFlowy-IO/AppFlowy-LocalAI?rev=6f064efe232268f8d396edbb4b84d57fbb640f13#6f064efe232268f8d396edbb4b84d57fbb640f13"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"appflowy-plugin", "appflowy-plugin",
@ -226,7 +226,7 @@ dependencies = [
[[package]] [[package]]
name = "appflowy-plugin" name = "appflowy-plugin"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-LocalAI?rev=65802795ad8778de11c45b5af65d05c973709613#65802795ad8778de11c45b5af65d05c973709613" source = "git+https://github.com/AppFlowy-IO/AppFlowy-LocalAI?rev=6f064efe232268f8d396edbb4b84d57fbb640f13#6f064efe232268f8d396edbb4b84d57fbb640f13"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"cfg-if", "cfg-if",
@ -826,7 +826,7 @@ dependencies = [
[[package]] [[package]]
name = "client-api" name = "client-api"
version = "0.2.0" version = "0.2.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=6a44490daccb101c8b855443d2d6ded0fb752016#6a44490daccb101c8b855443d2d6ded0fb752016" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=7878a018a18553e3d8201e572a0c066c14ba3b35#7878a018a18553e3d8201e572a0c066c14ba3b35"
dependencies = [ dependencies = [
"again", "again",
"anyhow", "anyhow",
@ -876,7 +876,7 @@ dependencies = [
[[package]] [[package]]
name = "client-api-entity" name = "client-api-entity"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=6a44490daccb101c8b855443d2d6ded0fb752016#6a44490daccb101c8b855443d2d6ded0fb752016" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=7878a018a18553e3d8201e572a0c066c14ba3b35#7878a018a18553e3d8201e572a0c066c14ba3b35"
dependencies = [ dependencies = [
"collab-entity", "collab-entity",
"collab-rt-entity", "collab-rt-entity",
@ -888,7 +888,7 @@ dependencies = [
[[package]] [[package]]
name = "client-websocket" name = "client-websocket"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=6a44490daccb101c8b855443d2d6ded0fb752016#6a44490daccb101c8b855443d2d6ded0fb752016" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=7878a018a18553e3d8201e572a0c066c14ba3b35#7878a018a18553e3d8201e572a0c066c14ba3b35"
dependencies = [ dependencies = [
"futures-channel", "futures-channel",
"futures-util", "futures-util",
@ -994,7 +994,7 @@ dependencies = [
"collab", "collab",
"collab-entity", "collab-entity",
"collab-plugins", "collab-plugins",
"dashmap", "dashmap 5.5.3",
"getrandom 0.2.10", "getrandom 0.2.10",
"js-sys", "js-sys",
"lazy_static", "lazy_static",
@ -1132,7 +1132,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-rt-entity" name = "collab-rt-entity"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=6a44490daccb101c8b855443d2d6ded0fb752016#6a44490daccb101c8b855443d2d6ded0fb752016" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=7878a018a18553e3d8201e572a0c066c14ba3b35#7878a018a18553e3d8201e572a0c066c14ba3b35"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bincode", "bincode",
@ -1157,7 +1157,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-rt-protocol" name = "collab-rt-protocol"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=6a44490daccb101c8b855443d2d6ded0fb752016#6a44490daccb101c8b855443d2d6ded0fb752016" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=7878a018a18553e3d8201e572a0c066c14ba3b35#7878a018a18553e3d8201e572a0c066c14ba3b35"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"async-trait", "async-trait",
@ -1421,7 +1421,7 @@ dependencies = [
"cssparser-macros", "cssparser-macros",
"dtoa-short", "dtoa-short",
"itoa 1.0.6", "itoa 1.0.6",
"phf 0.8.0", "phf 0.11.2",
"smallvec", "smallvec",
] ]
@ -1523,6 +1523,20 @@ dependencies = [
"parking_lot_core 0.9.8", "parking_lot_core 0.9.8",
] ]
[[package]]
name = "dashmap"
version = "6.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "804c8821570c3f8b70230c2ba75ffa5c0f9a4189b9a432b6656c536712acae28"
dependencies = [
"cfg-if",
"crossbeam-utils",
"hashbrown 0.14.3",
"lock_api",
"once_cell",
"parking_lot_core 0.9.8",
]
[[package]] [[package]]
name = "data-encoding" name = "data-encoding"
version = "2.4.0" version = "2.4.0"
@ -1532,7 +1546,7 @@ checksum = "c2e66c9d817f1720209181c316d28635c050fa304f9c79e47a520882661b7308"
[[package]] [[package]]
name = "database-entity" name = "database-entity"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=6a44490daccb101c8b855443d2d6ded0fb752016#6a44490daccb101c8b855443d2d6ded0fb752016" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=7878a018a18553e3d8201e572a0c066c14ba3b35#7878a018a18553e3d8201e572a0c066c14ba3b35"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"app-error", "app-error",
@ -1960,13 +1974,14 @@ dependencies = [
"appflowy-plugin", "appflowy-plugin",
"base64 0.21.5", "base64 0.21.5",
"bytes", "bytes",
"dashmap", "dashmap 6.0.1",
"flowy-ai-pub", "flowy-ai-pub",
"flowy-codegen", "flowy-codegen",
"flowy-derive", "flowy-derive",
"flowy-error", "flowy-error",
"flowy-notification", "flowy-notification",
"flowy-sqlite", "flowy-sqlite",
"flowy-storage-pub",
"futures", "futures",
"futures-util", "futures-util",
"lib-dispatch", "lib-dispatch",
@ -2131,7 +2146,7 @@ dependencies = [
"collab-integrate", "collab-integrate",
"collab-plugins", "collab-plugins",
"csv", "csv",
"dashmap", "dashmap 6.0.1",
"fancy-regex 0.11.0", "fancy-regex 0.11.0",
"flowy-codegen", "flowy-codegen",
"flowy-database-pub", "flowy-database-pub",
@ -2181,7 +2196,7 @@ dependencies = [
name = "flowy-derive" name = "flowy-derive"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"dashmap", "dashmap 6.0.1",
"flowy-ast", "flowy-ast",
"flowy-codegen", "flowy-codegen",
"lazy_static", "lazy_static",
@ -2203,7 +2218,7 @@ dependencies = [
"collab-entity", "collab-entity",
"collab-integrate", "collab-integrate",
"collab-plugins", "collab-plugins",
"dashmap", "dashmap 6.0.1",
"flowy-codegen", "flowy-codegen",
"flowy-derive", "flowy-derive",
"flowy-document-pub", "flowy-document-pub",
@ -2340,7 +2355,7 @@ name = "flowy-notification"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"bytes", "bytes",
"dashmap", "dashmap 6.0.1",
"flowy-codegen", "flowy-codegen",
"flowy-derive", "flowy-derive",
"lazy_static", "lazy_static",
@ -2483,6 +2498,7 @@ dependencies = [
"async-trait", "async-trait",
"bytes", "bytes",
"chrono", "chrono",
"dashmap 6.0.1",
"flowy-codegen", "flowy-codegen",
"flowy-derive", "flowy-derive",
"flowy-error", "flowy-error",
@ -2515,6 +2531,7 @@ dependencies = [
"serde", "serde",
"serde_json", "serde_json",
"tokio", "tokio",
"tracing",
] ]
[[package]] [[package]]
@ -3051,7 +3068,7 @@ dependencies = [
[[package]] [[package]]
name = "gotrue" name = "gotrue"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=6a44490daccb101c8b855443d2d6ded0fb752016#6a44490daccb101c8b855443d2d6ded0fb752016" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=7878a018a18553e3d8201e572a0c066c14ba3b35#7878a018a18553e3d8201e572a0c066c14ba3b35"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"futures-util", "futures-util",
@ -3068,7 +3085,7 @@ dependencies = [
[[package]] [[package]]
name = "gotrue-entity" name = "gotrue-entity"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=6a44490daccb101c8b855443d2d6ded0fb752016#6a44490daccb101c8b855443d2d6ded0fb752016" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=7878a018a18553e3d8201e572a0c066c14ba3b35#7878a018a18553e3d8201e572a0c066c14ba3b35"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"app-error", "app-error",
@ -3500,7 +3517,7 @@ dependencies = [
[[package]] [[package]]
name = "infra" name = "infra"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=6a44490daccb101c8b855443d2d6ded0fb752016#6a44490daccb101c8b855443d2d6ded0fb752016" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=7878a018a18553e3d8201e572a0c066c14ba3b35#7878a018a18553e3d8201e572a0c066c14ba3b35"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bytes", "bytes",
@ -6098,7 +6115,7 @@ dependencies = [
[[package]] [[package]]
name = "shared-entity" name = "shared-entity"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=6a44490daccb101c8b855443d2d6ded0fb752016#6a44490daccb101c8b855443d2d6ded0fb752016" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=7878a018a18553e3d8201e572a0c066c14ba3b35#7878a018a18553e3d8201e572a0c066c14ba3b35"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"app-error", "app-error",

View File

@ -53,7 +53,7 @@ collab-user = { version = "0.2" }
# Run the script: # Run the script:
# scripts/tool/update_client_api_rev.sh new_rev_id # scripts/tool/update_client_api_rev.sh new_rev_id
# ⚠️⚠️⚠️️ # ⚠️⚠️⚠️️
client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "6a44490daccb101c8b855443d2d6ded0fb752016" } client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "7878a018a18553e3d8201e572a0c066c14ba3b35" }
[dependencies] [dependencies]
serde_json.workspace = true serde_json.workspace = true
@ -128,5 +128,5 @@ collab-user = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-
# To update the commit ID, run: # To update the commit ID, run:
# scripts/tool/update_local_ai_rev.sh new_rev_id # scripts/tool/update_local_ai_rev.sh new_rev_id
# ⚠️⚠️⚠️️ # ⚠️⚠️⚠️️
appflowy-local-ai = { version = "0.1", git = "https://github.com/AppFlowy-IO/AppFlowy-LocalAI", rev = "65802795ad8778de11c45b5af65d05c973709613" } appflowy-local-ai = { version = "0.1", git = "https://github.com/AppFlowy-IO/AppFlowy-LocalAI", rev = "6f064efe232268f8d396edbb4b84d57fbb640f13" }
appflowy-plugin = { version = "0.1", git = "https://github.com/AppFlowy-IO/AppFlowy-LocalAI", rev = "65802795ad8778de11c45b5af65d05c973709613" } appflowy-plugin = { version = "0.1", git = "https://github.com/AppFlowy-IO/AppFlowy-LocalAI", rev = "6f064efe232268f8d396edbb4b84d57fbb640f13" }

View File

@ -163,7 +163,7 @@ checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da"
[[package]] [[package]]
name = "app-error" name = "app-error"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=6a44490daccb101c8b855443d2d6ded0fb752016#6a44490daccb101c8b855443d2d6ded0fb752016" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=7878a018a18553e3d8201e572a0c066c14ba3b35#7878a018a18553e3d8201e572a0c066c14ba3b35"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bincode", "bincode",
@ -183,7 +183,7 @@ dependencies = [
[[package]] [[package]]
name = "appflowy-ai-client" name = "appflowy-ai-client"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=6a44490daccb101c8b855443d2d6ded0fb752016#6a44490daccb101c8b855443d2d6ded0fb752016" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=7878a018a18553e3d8201e572a0c066c14ba3b35#7878a018a18553e3d8201e572a0c066c14ba3b35"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bytes", "bytes",
@ -198,7 +198,7 @@ dependencies = [
[[package]] [[package]]
name = "appflowy-local-ai" name = "appflowy-local-ai"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-LocalAI?rev=65802795ad8778de11c45b5af65d05c973709613#65802795ad8778de11c45b5af65d05c973709613" source = "git+https://github.com/AppFlowy-IO/AppFlowy-LocalAI?rev=6f064efe232268f8d396edbb4b84d57fbb640f13#6f064efe232268f8d396edbb4b84d57fbb640f13"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"appflowy-plugin", "appflowy-plugin",
@ -217,7 +217,7 @@ dependencies = [
[[package]] [[package]]
name = "appflowy-plugin" name = "appflowy-plugin"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-LocalAI?rev=65802795ad8778de11c45b5af65d05c973709613#65802795ad8778de11c45b5af65d05c973709613" source = "git+https://github.com/AppFlowy-IO/AppFlowy-LocalAI?rev=6f064efe232268f8d396edbb4b84d57fbb640f13#6f064efe232268f8d396edbb4b84d57fbb640f13"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"cfg-if", "cfg-if",
@ -800,7 +800,7 @@ dependencies = [
[[package]] [[package]]
name = "client-api" name = "client-api"
version = "0.2.0" version = "0.2.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=6a44490daccb101c8b855443d2d6ded0fb752016#6a44490daccb101c8b855443d2d6ded0fb752016" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=7878a018a18553e3d8201e572a0c066c14ba3b35#7878a018a18553e3d8201e572a0c066c14ba3b35"
dependencies = [ dependencies = [
"again", "again",
"anyhow", "anyhow",
@ -850,7 +850,7 @@ dependencies = [
[[package]] [[package]]
name = "client-api-entity" name = "client-api-entity"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=6a44490daccb101c8b855443d2d6ded0fb752016#6a44490daccb101c8b855443d2d6ded0fb752016" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=7878a018a18553e3d8201e572a0c066c14ba3b35#7878a018a18553e3d8201e572a0c066c14ba3b35"
dependencies = [ dependencies = [
"collab-entity", "collab-entity",
"collab-rt-entity", "collab-rt-entity",
@ -862,7 +862,7 @@ dependencies = [
[[package]] [[package]]
name = "client-websocket" name = "client-websocket"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=6a44490daccb101c8b855443d2d6ded0fb752016#6a44490daccb101c8b855443d2d6ded0fb752016" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=7878a018a18553e3d8201e572a0c066c14ba3b35#7878a018a18553e3d8201e572a0c066c14ba3b35"
dependencies = [ dependencies = [
"futures-channel", "futures-channel",
"futures-util", "futures-util",
@ -977,7 +977,7 @@ dependencies = [
"collab", "collab",
"collab-entity", "collab-entity",
"collab-plugins", "collab-plugins",
"dashmap", "dashmap 5.5.3",
"getrandom 0.2.12", "getrandom 0.2.12",
"js-sys", "js-sys",
"lazy_static", "lazy_static",
@ -1115,7 +1115,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-rt-entity" name = "collab-rt-entity"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=6a44490daccb101c8b855443d2d6ded0fb752016#6a44490daccb101c8b855443d2d6ded0fb752016" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=7878a018a18553e3d8201e572a0c066c14ba3b35#7878a018a18553e3d8201e572a0c066c14ba3b35"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bincode", "bincode",
@ -1140,7 +1140,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-rt-protocol" name = "collab-rt-protocol"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=6a44490daccb101c8b855443d2d6ded0fb752016#6a44490daccb101c8b855443d2d6ded0fb752016" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=7878a018a18553e3d8201e572a0c066c14ba3b35#7878a018a18553e3d8201e572a0c066c14ba3b35"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"async-trait", "async-trait",
@ -1411,7 +1411,7 @@ dependencies = [
"cssparser-macros", "cssparser-macros",
"dtoa-short", "dtoa-short",
"itoa 1.0.10", "itoa 1.0.10",
"phf 0.8.0", "phf 0.11.2",
"smallvec", "smallvec",
] ]
@ -1513,6 +1513,20 @@ dependencies = [
"parking_lot_core 0.9.9", "parking_lot_core 0.9.9",
] ]
[[package]]
name = "dashmap"
version = "6.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "804c8821570c3f8b70230c2ba75ffa5c0f9a4189b9a432b6656c536712acae28"
dependencies = [
"cfg-if",
"crossbeam-utils",
"hashbrown 0.14.3",
"lock_api",
"once_cell",
"parking_lot_core 0.9.9",
]
[[package]] [[package]]
name = "data-encoding" name = "data-encoding"
version = "2.5.0" version = "2.5.0"
@ -1522,7 +1536,7 @@ checksum = "7e962a19be5cfc3f3bf6dd8f61eb50107f356ad6270fbb3ed41476571db78be5"
[[package]] [[package]]
name = "database-entity" name = "database-entity"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=6a44490daccb101c8b855443d2d6ded0fb752016#6a44490daccb101c8b855443d2d6ded0fb752016" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=7878a018a18553e3d8201e572a0c066c14ba3b35#7878a018a18553e3d8201e572a0c066c14ba3b35"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"app-error", "app-error",
@ -1990,13 +2004,14 @@ dependencies = [
"appflowy-plugin", "appflowy-plugin",
"base64 0.21.7", "base64 0.21.7",
"bytes", "bytes",
"dashmap", "dashmap 6.0.1",
"flowy-ai-pub", "flowy-ai-pub",
"flowy-codegen", "flowy-codegen",
"flowy-derive", "flowy-derive",
"flowy-error", "flowy-error",
"flowy-notification", "flowy-notification",
"flowy-sqlite", "flowy-sqlite",
"flowy-storage-pub",
"futures", "futures",
"futures-util", "futures-util",
"lib-dispatch", "lib-dispatch",
@ -2161,7 +2176,7 @@ dependencies = [
"collab-integrate", "collab-integrate",
"collab-plugins", "collab-plugins",
"csv", "csv",
"dashmap", "dashmap 6.0.1",
"fancy-regex 0.11.0", "fancy-regex 0.11.0",
"flowy-codegen", "flowy-codegen",
"flowy-database-pub", "flowy-database-pub",
@ -2211,7 +2226,7 @@ dependencies = [
name = "flowy-derive" name = "flowy-derive"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"dashmap", "dashmap 6.0.1",
"flowy-ast", "flowy-ast",
"flowy-codegen", "flowy-codegen",
"lazy_static", "lazy_static",
@ -2233,7 +2248,7 @@ dependencies = [
"collab-entity", "collab-entity",
"collab-integrate", "collab-integrate",
"collab-plugins", "collab-plugins",
"dashmap", "dashmap 6.0.1",
"flowy-codegen", "flowy-codegen",
"flowy-derive", "flowy-derive",
"flowy-document-pub", "flowy-document-pub",
@ -2370,7 +2385,7 @@ name = "flowy-notification"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"bytes", "bytes",
"dashmap", "dashmap 6.0.1",
"flowy-codegen", "flowy-codegen",
"flowy-derive", "flowy-derive",
"lazy_static", "lazy_static",
@ -2513,6 +2528,7 @@ dependencies = [
"async-trait", "async-trait",
"bytes", "bytes",
"chrono", "chrono",
"dashmap 6.0.1",
"flowy-codegen", "flowy-codegen",
"flowy-derive", "flowy-derive",
"flowy-error", "flowy-error",
@ -2545,6 +2561,7 @@ dependencies = [
"serde", "serde",
"serde_json", "serde_json",
"tokio", "tokio",
"tracing",
] ]
[[package]] [[package]]
@ -3118,7 +3135,7 @@ dependencies = [
[[package]] [[package]]
name = "gotrue" name = "gotrue"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=6a44490daccb101c8b855443d2d6ded0fb752016#6a44490daccb101c8b855443d2d6ded0fb752016" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=7878a018a18553e3d8201e572a0c066c14ba3b35#7878a018a18553e3d8201e572a0c066c14ba3b35"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"futures-util", "futures-util",
@ -3135,7 +3152,7 @@ dependencies = [
[[package]] [[package]]
name = "gotrue-entity" name = "gotrue-entity"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=6a44490daccb101c8b855443d2d6ded0fb752016#6a44490daccb101c8b855443d2d6ded0fb752016" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=7878a018a18553e3d8201e572a0c066c14ba3b35#7878a018a18553e3d8201e572a0c066c14ba3b35"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"app-error", "app-error",
@ -3572,7 +3589,7 @@ dependencies = [
[[package]] [[package]]
name = "infra" name = "infra"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=6a44490daccb101c8b855443d2d6ded0fb752016#6a44490daccb101c8b855443d2d6ded0fb752016" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=7878a018a18553e3d8201e572a0c066c14ba3b35#7878a018a18553e3d8201e572a0c066c14ba3b35"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bytes", "bytes",
@ -6162,7 +6179,7 @@ dependencies = [
[[package]] [[package]]
name = "shared-entity" name = "shared-entity"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=6a44490daccb101c8b855443d2d6ded0fb752016#6a44490daccb101c8b855443d2d6ded0fb752016" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=7878a018a18553e3d8201e572a0c066c14ba3b35#7878a018a18553e3d8201e572a0c066c14ba3b35"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"app-error", "app-error",

View File

@ -52,7 +52,7 @@ collab-user = { version = "0.2" }
# Run the script: # Run the script:
# scripts/tool/update_client_api_rev.sh new_rev_id # scripts/tool/update_client_api_rev.sh new_rev_id
# ⚠️⚠️⚠️️ # ⚠️⚠️⚠️️
client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "6a44490daccb101c8b855443d2d6ded0fb752016" } client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "7878a018a18553e3d8201e572a0c066c14ba3b35" }
[dependencies] [dependencies]
serde_json.workspace = true serde_json.workspace = true
@ -128,6 +128,6 @@ collab-user = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-
# To update the commit ID, run: # To update the commit ID, run:
# scripts/tool/update_local_ai_rev.sh new_rev_id # scripts/tool/update_local_ai_rev.sh new_rev_id
# ⚠️⚠️⚠️️ # ⚠️⚠️⚠️️
appflowy-local-ai = { version = "0.1", git = "https://github.com/AppFlowy-IO/AppFlowy-LocalAI", rev = "65802795ad8778de11c45b5af65d05c973709613" } appflowy-local-ai = { version = "0.1", git = "https://github.com/AppFlowy-IO/AppFlowy-LocalAI", rev = "6f064efe232268f8d396edbb4b84d57fbb640f13" }
appflowy-plugin = { version = "0.1", git = "https://github.com/AppFlowy-IO/AppFlowy-LocalAI", rev = "65802795ad8778de11c45b5af65d05c973709613" } appflowy-plugin = { version = "0.1", git = "https://github.com/AppFlowy-IO/AppFlowy-LocalAI", rev = "6f064efe232268f8d396edbb4b84d57fbb640f13" }

View File

@ -666,6 +666,7 @@
"downloadLLMPrompt": "Download {}", "downloadLLMPrompt": "Download {}",
"downloadAppFlowyOfflineAI": "Downloading AI offline package will enable AI to run on your device. Do you want to continue?", "downloadAppFlowyOfflineAI": "Downloading AI offline package will enable AI to run on your device. Do you want to continue?",
"downloadLLMPromptDetail": "Downloading {} local model will take up to {} of storage. Do you want to continue?", "downloadLLMPromptDetail": "Downloading {} local model will take up to {} of storage. Do you want to continue?",
"downloadBigFilePrompt": "It may take around 10 minutes to complete the download",
"downloadAIModelButton": "Download", "downloadAIModelButton": "Download",
"downloadingModel": "Downloading", "downloadingModel": "Downloading",
"localAILoaded": "Local AI Model successfully added and ready to use", "localAILoaded": "Local AI Model successfully added and ready to use",
@ -735,15 +736,15 @@
"title": "AI Max", "title": "AI Max",
"description": "Unlimited AI responses powered by GPT-4o, Claude 3.5 Sonnet, and more", "description": "Unlimited AI responses powered by GPT-4o, Claude 3.5 Sonnet, and more",
"price": "{}", "price": "{}",
"priceInfo": "per user per month", "priceInfo": "per user per month billed annually",
"billingInfo": "billed annually or {} billed monthly" "recommend": ""
}, },
"aiOnDevice": { "aiOnDevice": {
"title": "AI On-device for Mac", "title": "AI On-device for Mac",
"description": "Run Mistral 7B, LLAMA 3, and more local models on your machine", "description": "Run Mistral 7B, LLAMA 3, and more local models on your machine",
"price": "{}", "price": "{}",
"priceInfo": "per user per month", "priceInfo": "per user per month billed annually",
"billingInfo": "billed annually or {} billed monthly" "recommend": "Recommend M1 or newer"
} }
}, },
"deal": { "deal": {

View File

@ -163,7 +163,7 @@ checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da"
[[package]] [[package]]
name = "app-error" name = "app-error"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=6a44490daccb101c8b855443d2d6ded0fb752016#6a44490daccb101c8b855443d2d6ded0fb752016" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=7878a018a18553e3d8201e572a0c066c14ba3b35#7878a018a18553e3d8201e572a0c066c14ba3b35"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bincode", "bincode",
@ -183,7 +183,7 @@ dependencies = [
[[package]] [[package]]
name = "appflowy-ai-client" name = "appflowy-ai-client"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=6a44490daccb101c8b855443d2d6ded0fb752016#6a44490daccb101c8b855443d2d6ded0fb752016" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=7878a018a18553e3d8201e572a0c066c14ba3b35#7878a018a18553e3d8201e572a0c066c14ba3b35"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bytes", "bytes",
@ -198,7 +198,7 @@ dependencies = [
[[package]] [[package]]
name = "appflowy-local-ai" name = "appflowy-local-ai"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-LocalAI?rev=65802795ad8778de11c45b5af65d05c973709613#65802795ad8778de11c45b5af65d05c973709613" source = "git+https://github.com/AppFlowy-IO/AppFlowy-LocalAI?rev=6f064efe232268f8d396edbb4b84d57fbb640f13#6f064efe232268f8d396edbb4b84d57fbb640f13"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"appflowy-plugin", "appflowy-plugin",
@ -217,7 +217,7 @@ dependencies = [
[[package]] [[package]]
name = "appflowy-plugin" name = "appflowy-plugin"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-LocalAI?rev=65802795ad8778de11c45b5af65d05c973709613#65802795ad8778de11c45b5af65d05c973709613" source = "git+https://github.com/AppFlowy-IO/AppFlowy-LocalAI?rev=6f064efe232268f8d396edbb4b84d57fbb640f13#6f064efe232268f8d396edbb4b84d57fbb640f13"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"cfg-if", "cfg-if",
@ -718,7 +718,7 @@ dependencies = [
[[package]] [[package]]
name = "client-api" name = "client-api"
version = "0.2.0" version = "0.2.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=6a44490daccb101c8b855443d2d6ded0fb752016#6a44490daccb101c8b855443d2d6ded0fb752016" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=7878a018a18553e3d8201e572a0c066c14ba3b35#7878a018a18553e3d8201e572a0c066c14ba3b35"
dependencies = [ dependencies = [
"again", "again",
"anyhow", "anyhow",
@ -768,7 +768,7 @@ dependencies = [
[[package]] [[package]]
name = "client-api-entity" name = "client-api-entity"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=6a44490daccb101c8b855443d2d6ded0fb752016#6a44490daccb101c8b855443d2d6ded0fb752016" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=7878a018a18553e3d8201e572a0c066c14ba3b35#7878a018a18553e3d8201e572a0c066c14ba3b35"
dependencies = [ dependencies = [
"collab-entity", "collab-entity",
"collab-rt-entity", "collab-rt-entity",
@ -780,7 +780,7 @@ dependencies = [
[[package]] [[package]]
name = "client-websocket" name = "client-websocket"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=6a44490daccb101c8b855443d2d6ded0fb752016#6a44490daccb101c8b855443d2d6ded0fb752016" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=7878a018a18553e3d8201e572a0c066c14ba3b35#7878a018a18553e3d8201e572a0c066c14ba3b35"
dependencies = [ dependencies = [
"futures-channel", "futures-channel",
"futures-util", "futures-util",
@ -993,7 +993,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-rt-entity" name = "collab-rt-entity"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=6a44490daccb101c8b855443d2d6ded0fb752016#6a44490daccb101c8b855443d2d6ded0fb752016" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=7878a018a18553e3d8201e572a0c066c14ba3b35#7878a018a18553e3d8201e572a0c066c14ba3b35"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bincode", "bincode",
@ -1018,7 +1018,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-rt-protocol" name = "collab-rt-protocol"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=6a44490daccb101c8b855443d2d6ded0fb752016#6a44490daccb101c8b855443d2d6ded0fb752016" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=7878a018a18553e3d8201e572a0c066c14ba3b35#7878a018a18553e3d8201e572a0c066c14ba3b35"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"async-trait", "async-trait",
@ -1370,7 +1370,7 @@ checksum = "c2e66c9d817f1720209181c316d28635c050fa304f9c79e47a520882661b7308"
[[package]] [[package]]
name = "database-entity" name = "database-entity"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=6a44490daccb101c8b855443d2d6ded0fb752016#6a44490daccb101c8b855443d2d6ded0fb752016" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=7878a018a18553e3d8201e572a0c066c14ba3b35#7878a018a18553e3d8201e572a0c066c14ba3b35"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"app-error", "app-error",
@ -2747,7 +2747,7 @@ dependencies = [
[[package]] [[package]]
name = "gotrue" name = "gotrue"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=6a44490daccb101c8b855443d2d6ded0fb752016#6a44490daccb101c8b855443d2d6ded0fb752016" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=7878a018a18553e3d8201e572a0c066c14ba3b35#7878a018a18553e3d8201e572a0c066c14ba3b35"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"futures-util", "futures-util",
@ -2764,7 +2764,7 @@ dependencies = [
[[package]] [[package]]
name = "gotrue-entity" name = "gotrue-entity"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=6a44490daccb101c8b855443d2d6ded0fb752016#6a44490daccb101c8b855443d2d6ded0fb752016" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=7878a018a18553e3d8201e572a0c066c14ba3b35#7878a018a18553e3d8201e572a0c066c14ba3b35"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"app-error", "app-error",
@ -3129,7 +3129,7 @@ dependencies = [
[[package]] [[package]]
name = "infra" name = "infra"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=6a44490daccb101c8b855443d2d6ded0fb752016#6a44490daccb101c8b855443d2d6ded0fb752016" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=7878a018a18553e3d8201e572a0c066c14ba3b35#7878a018a18553e3d8201e572a0c066c14ba3b35"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bytes", "bytes",
@ -5338,7 +5338,7 @@ dependencies = [
[[package]] [[package]]
name = "shared-entity" name = "shared-entity"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=6a44490daccb101c8b855443d2d6ded0fb752016#6a44490daccb101c8b855443d2d6ded0fb752016" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=7878a018a18553e3d8201e572a0c066c14ba3b35#7878a018a18553e3d8201e572a0c066c14ba3b35"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"app-error", "app-error",

View File

@ -100,8 +100,8 @@ dashmap = "6.0.1"
# Run the script.add_workspace_members: # Run the script.add_workspace_members:
# scripts/tool/update_client_api_rev.sh new_rev_id # scripts/tool/update_client_api_rev.sh new_rev_id
# ⚠️⚠️⚠️️ # ⚠️⚠️⚠️️
client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "6a44490daccb101c8b855443d2d6ded0fb752016" } client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "7878a018a18553e3d8201e572a0c066c14ba3b35" }
client-api-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "6a44490daccb101c8b855443d2d6ded0fb752016" } client-api-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "7878a018a18553e3d8201e572a0c066c14ba3b35" }
[profile.dev] [profile.dev]
opt-level = 0 opt-level = 0
@ -148,5 +148,5 @@ collab-user = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-
# To update the commit ID, run: # To update the commit ID, run:
# scripts/tool/update_local_ai_rev.sh new_rev_id # scripts/tool/update_local_ai_rev.sh new_rev_id
# ⚠️⚠️⚠️️ # ⚠️⚠️⚠️️
appflowy-local-ai = { version = "0.1", git = "https://github.com/AppFlowy-IO/AppFlowy-LocalAI", rev = "65802795ad8778de11c45b5af65d05c973709613" } appflowy-local-ai = { version = "0.1", git = "https://github.com/AppFlowy-IO/AppFlowy-LocalAI", rev = "6f064efe232268f8d396edbb4b84d57fbb640f13" }
appflowy-plugin = { version = "0.1", git = "https://github.com/AppFlowy-IO/AppFlowy-LocalAI", rev = "65802795ad8778de11c45b5af65d05c973709613" } appflowy-plugin = { version = "0.1", git = "https://github.com/AppFlowy-IO/AppFlowy-LocalAI", rev = "6f064efe232268f8d396edbb4b84d57fbb640f13" }

View File

@ -12,6 +12,8 @@ use flowy_error::FlowyError;
use futures::stream::BoxStream; use futures::stream::BoxStream;
use lib_infra::async_trait::async_trait; use lib_infra::async_trait::async_trait;
use lib_infra::future::FutureResult; use lib_infra::future::FutureResult;
use serde_json::Value;
use std::collections::HashMap;
use std::path::Path; use std::path::Path;
pub type ChatMessageStream = BoxStream<'static, Result<ChatMessage, AppResponseError>>; pub type ChatMessageStream = BoxStream<'static, Result<ChatMessage, AppResponseError>>;
@ -85,6 +87,7 @@ pub trait ChatCloudService: Send + Sync + 'static {
workspace_id: &str, workspace_id: &str,
file_path: &Path, file_path: &Path,
chat_id: &str, chat_id: &str,
metadata: Option<HashMap<String, Value>>,
) -> Result<(), FlowyError>; ) -> Result<(), FlowyError>;
async fn get_local_ai_config(&self, workspace_id: &str) -> Result<LocalAIConfig, FlowyError>; async fn get_local_ai_config(&self, workspace_id: &str) -> Result<LocalAIConfig, FlowyError>;

View File

@ -513,6 +513,7 @@ impl Chat {
&self.user_service.workspace_id()?, &self.user_service.workspace_id()?,
&file_path, &file_path,
&self.chat_id, &self.chat_id,
None,
) )
.await?; .await?;

View File

@ -357,6 +357,7 @@ impl LocalAIController {
} }
let mut index_metadata = HashMap::new(); let mut index_metadata = HashMap::new();
index_metadata.insert("id".to_string(), json!(&metadata.id));
index_metadata.insert("name".to_string(), json!(&metadata.name)); index_metadata.insert("name".to_string(), json!(&metadata.name));
index_metadata.insert("at_name".to_string(), json!(format!("@{}", &metadata.name))); index_metadata.insert("at_name".to_string(), json!(format!("@{}", &metadata.name)));
index_metadata.insert("source".to_string(), json!(&metadata.source)); index_metadata.insert("source".to_string(), json!(&metadata.source));

View File

@ -359,6 +359,10 @@ impl LocalAIResourceController {
let cloned_model_name = model_name.clone(); let cloned_model_name = model_name.clone();
let progress = Arc::new(move |downloaded, total_size| { let progress = Arc::new(move |downloaded, total_size| {
let progress = (downloaded as f64 / total_size as f64).clamp(0.0, 1.0); let progress = (downloaded as f64 / total_size as f64).clamp(0.0, 1.0);
if plugin_progress_tx.receiver_count() == 0 {
return;
}
if let Err(err) = if let Err(err) =
plugin_progress_tx.send(format!("{}:progress:{}", cloned_model_name, progress)) plugin_progress_tx.send(format!("{}:progress:{}", cloned_model_name, progress))
{ {

View File

@ -1,39 +1,62 @@
use appflowy_plugin::error::PluginError; use appflowy_plugin::error::PluginError;
use bytes::Bytes;
use flowy_ai_pub::cloud::QuestionStreamValue; use flowy_ai_pub::cloud::QuestionStreamValue;
use flowy_error::FlowyError; use flowy_error::FlowyError;
use futures::{ready, Stream}; use futures::{ready, Stream};
use pin_project::pin_project; use pin_project::pin_project;
use serde_json::Value;
use std::pin::Pin; use std::pin::Pin;
use std::task::{Context, Poll}; use std::task::{Context, Poll};
use tracing::error;
pub const STEAM_METADATA_KEY: &str = "0";
pub const STEAM_ANSWER_KEY: &str = "1";
#[pin_project] #[pin_project]
pub struct LocalAIStreamAdaptor { pub struct QuestionStream {
stream: Pin<Box<dyn Stream<Item = Result<Bytes, PluginError>> + Send>>, stream: Pin<Box<dyn Stream<Item = Result<Value, PluginError>> + Send>>,
buffer: Vec<u8>, buffer: Vec<u8>,
} }
impl LocalAIStreamAdaptor { impl QuestionStream {
pub fn new<S>(stream: S) -> Self pub fn new<S>(stream: S) -> Self
where where
S: Stream<Item = Result<Bytes, PluginError>> + Send + 'static, S: Stream<Item = Result<Value, PluginError>> + Send + 'static,
{ {
LocalAIStreamAdaptor { QuestionStream {
stream: Box::pin(stream), stream: Box::pin(stream),
buffer: Vec::new(), buffer: Vec::new(),
} }
} }
} }
impl Stream for LocalAIStreamAdaptor { impl Stream for QuestionStream {
type Item = Result<QuestionStreamValue, FlowyError>; type Item = Result<QuestionStreamValue, FlowyError>;
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> { fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
let this = self.project(); let this = self.project();
match ready!(this.stream.as_mut().poll_next(cx)) { match ready!(this.stream.as_mut().poll_next(cx)) {
Some(Ok(bytes)) => match String::from_utf8(bytes.to_vec()) { Some(Ok(value)) => match value {
Ok(s) => Poll::Ready(Some(Ok(QuestionStreamValue::Answer { value: s }))), Value::Object(mut value) => {
Err(err) => Poll::Ready(Some(Err(FlowyError::internal().with_context(err)))), if let Some(metadata) = value.remove(STEAM_METADATA_KEY) {
return Poll::Ready(Some(Ok(QuestionStreamValue::Metadata { value: metadata })));
}
if let Some(answer) = value
.remove(STEAM_ANSWER_KEY)
.and_then(|s| s.as_str().map(ToString::to_string))
{
return Poll::Ready(Some(Ok(QuestionStreamValue::Answer { value: answer })));
}
error!("Invalid streaming value: {:?}", value);
Poll::Ready(None)
},
_ => {
error!("Unexpected JSON value type: {:?}", value);
Poll::Ready(None)
},
}, },
Some(Err(err)) => Poll::Ready(Some(Err(FlowyError::local_ai().with_context(err)))), Some(Err(err)) => Poll::Ready(Some(Err(FlowyError::local_ai().with_context(err)))),
None => Poll::Ready(None), None => Poll::Ready(None),

View File

@ -4,6 +4,7 @@ use crate::local_ai::local_llm_chat::LocalAIController;
use crate::notification::{make_notification, ChatNotification, APPFLOWY_AI_NOTIFICATION_KEY}; use crate::notification::{make_notification, ChatNotification, APPFLOWY_AI_NOTIFICATION_KEY};
use crate::persistence::{select_single_message, ChatMessageTable}; use crate::persistence::{select_single_message, ChatMessageTable};
use appflowy_plugin::error::PluginError; use appflowy_plugin::error::PluginError;
use std::collections::HashMap;
use flowy_ai_pub::cloud::{ use flowy_ai_pub::cloud::{
ChatCloudService, ChatMessage, ChatMessageMetadata, ChatMessageType, CompletionType, ChatCloudService, ChatMessage, ChatMessageMetadata, ChatMessageType, CompletionType,
@ -15,11 +16,11 @@ use futures::{stream, Sink, StreamExt, TryStreamExt};
use lib_infra::async_trait::async_trait; use lib_infra::async_trait::async_trait;
use lib_infra::future::FutureResult; use lib_infra::future::FutureResult;
use crate::local_ai::stream_util::LocalAIStreamAdaptor; use crate::local_ai::stream_util::QuestionStream;
use crate::stream_message::StreamMessage; use crate::stream_message::StreamMessage;
use flowy_storage_pub::storage::StorageService; use flowy_storage_pub::storage::StorageService;
use futures_util::SinkExt; use futures_util::SinkExt;
use serde_json::json; use serde_json::{json, Value};
use std::path::Path; use std::path::Path;
use std::sync::{Arc, Weak}; use std::sync::{Arc, Weak};
use tracing::trace; use tracing::trace;
@ -157,7 +158,7 @@ impl ChatCloudService for AICloudServiceMiddleware {
.stream_question(chat_id, &row.content, json!([])) .stream_question(chat_id, &row.content, json!([]))
.await .await
{ {
Ok(stream) => Ok(LocalAIStreamAdaptor::new(stream).boxed()), Ok(stream) => Ok(QuestionStream::new(stream).boxed()),
Err(err) => { Err(err) => {
self.handle_plugin_error(err); self.handle_plugin_error(err);
Ok(stream::once(async { Err(FlowyError::local_ai_unavailable()) }).boxed()) Ok(stream::once(async { Err(FlowyError::local_ai_unavailable()) }).boxed())
@ -284,18 +285,19 @@ impl ChatCloudService for AICloudServiceMiddleware {
workspace_id: &str, workspace_id: &str,
file_path: &Path, file_path: &Path,
chat_id: &str, chat_id: &str,
metadata: Option<HashMap<String, Value>>,
) -> Result<(), FlowyError> { ) -> Result<(), FlowyError> {
if self.local_llm_controller.is_running() { if self.local_llm_controller.is_running() {
self self
.local_llm_controller .local_llm_controller
.index_file(chat_id, Some(file_path.to_path_buf()), None, None) .index_file(chat_id, Some(file_path.to_path_buf()), None, metadata)
.await .await
.map_err(|err| FlowyError::local_ai().with_context(err))?; .map_err(|err| FlowyError::local_ai().with_context(err))?;
Ok(()) Ok(())
} else { } else {
self self
.cloud_service .cloud_service
.index_file(workspace_id, file_path, chat_id) .index_file(workspace_id, file_path, chat_id, metadata)
.await .await
} }
} }

View File

@ -1,5 +1,6 @@
use client_api::entity::search_dto::SearchDocumentResponseItem; use client_api::entity::search_dto::SearchDocumentResponseItem;
use flowy_search_pub::cloud::SearchCloudService; use flowy_search_pub::cloud::SearchCloudService;
use std::collections::HashMap;
use std::path::Path; use std::path::Path;
use std::sync::Arc; use std::sync::Arc;
@ -12,6 +13,7 @@ use collab::core::origin::{CollabClient, CollabOrigin};
use collab::preclude::CollabPlugin; use collab::preclude::CollabPlugin;
use collab_entity::CollabType; use collab_entity::CollabType;
use collab_plugins::cloud_storage::postgres::SupabaseDBPlugin; use collab_plugins::cloud_storage::postgres::SupabaseDBPlugin;
use serde_json::Value;
use tokio_stream::wrappers::WatchStream; use tokio_stream::wrappers::WatchStream;
use tracing::{debug, info}; use tracing::{debug, info};
@ -719,11 +721,12 @@ impl ChatCloudService for ServerProvider {
workspace_id: &str, workspace_id: &str,
file_path: &Path, file_path: &Path,
chat_id: &str, chat_id: &str,
metadata: Option<HashMap<String, Value>>,
) -> Result<(), FlowyError> { ) -> Result<(), FlowyError> {
self self
.get_server()? .get_server()?
.chat_service() .chat_service()
.index_file(workspace_id, file_path, chat_id) .index_file(workspace_id, file_path, chat_id, metadata)
.await .await
} }

View File

@ -15,7 +15,8 @@ use futures_util::{StreamExt, TryStreamExt};
use lib_infra::async_trait::async_trait; use lib_infra::async_trait::async_trait;
use lib_infra::future::FutureResult; use lib_infra::future::FutureResult;
use lib_infra::util::{get_operating_system, OperatingSystem}; use lib_infra::util::{get_operating_system, OperatingSystem};
use serde_json::json; use serde_json::{json, Value};
use std::collections::HashMap;
use std::path::Path; use std::path::Path;
pub(crate) struct AFCloudChatCloudServiceImpl<T> { pub(crate) struct AFCloudChatCloudServiceImpl<T> {
@ -182,6 +183,7 @@ where
_workspace_id: &str, _workspace_id: &str,
_file_path: &Path, _file_path: &Path,
_chat_id: &str, _chat_id: &str,
_metadata: Option<HashMap<String, Value>>,
) -> Result<(), FlowyError> { ) -> Result<(), FlowyError> {
return Err( return Err(
FlowyError::not_support() FlowyError::not_support()

View File

@ -6,6 +6,8 @@ use flowy_ai_pub::cloud::{
use flowy_error::FlowyError; use flowy_error::FlowyError;
use lib_infra::async_trait::async_trait; use lib_infra::async_trait::async_trait;
use lib_infra::future::FutureResult; use lib_infra::future::FutureResult;
use serde_json::Value;
use std::collections::HashMap;
use std::path::Path; use std::path::Path;
pub(crate) struct DefaultChatCloudServiceImpl; pub(crate) struct DefaultChatCloudServiceImpl;
@ -96,6 +98,7 @@ impl ChatCloudService for DefaultChatCloudServiceImpl {
_workspace_id: &str, _workspace_id: &str,
_file_path: &Path, _file_path: &Path,
_chat_id: &str, _chat_id: &str,
_metadata: Option<HashMap<String, Value>>,
) -> Result<(), FlowyError> { ) -> Result<(), FlowyError> {
Err(FlowyError::not_support().with_context("indexing file is not supported in local server.")) Err(FlowyError::not_support().with_context("indexing file is not supported in local server."))
} }