mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-11-02 02:53:59 +00:00
chore: enable anon ai writer
This commit is contained in:
parent
57e4d269eb
commit
3a4d17f054
@ -142,7 +142,7 @@ class _AiWriterToolbarActionListState extends State<AiWriterToolbarActionList> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
if (_isAIEnabled(widget.editorState)) {
|
if (_isAIWriterEnabled(widget.editorState)) {
|
||||||
keepEditorFocusNotifier.increase();
|
keepEditorFocusNotifier.increase();
|
||||||
popoverController.show();
|
popoverController.show();
|
||||||
setState(() {
|
setState(() {
|
||||||
@ -159,7 +159,7 @@ class _AiWriterToolbarActionListState extends State<AiWriterToolbarActionList> {
|
|||||||
return widget.tooltipBuilder?.call(
|
return widget.tooltipBuilder?.call(
|
||||||
context,
|
context,
|
||||||
_aiWriterToolbarItemId,
|
_aiWriterToolbarItemId,
|
||||||
_isAIEnabled(widget.editorState)
|
_isAIWriterEnabled(widget.editorState)
|
||||||
? LocaleKeys.document_plugins_aiWriter_userQuestion.tr()
|
? LocaleKeys.document_plugins_aiWriter_userQuestion.tr()
|
||||||
: LocaleKeys.document_plugins_appflowyAIEditDisabled.tr(),
|
: LocaleKeys.document_plugins_appflowyAIEditDisabled.tr(),
|
||||||
child,
|
child,
|
||||||
@ -191,7 +191,7 @@ class ImproveWritingButton extends StatelessWidget {
|
|||||||
color: theme.iconColorTheme.primary,
|
color: theme.iconColorTheme.primary,
|
||||||
),
|
),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
if (_isAIEnabled(editorState)) {
|
if (_isAIWriterEnabled(editorState)) {
|
||||||
keepEditorFocusNotifier.increase();
|
keepEditorFocusNotifier.increase();
|
||||||
_insertAiNode(editorState, AiWriterCommand.improveWriting);
|
_insertAiNode(editorState, AiWriterCommand.improveWriting);
|
||||||
} else {
|
} else {
|
||||||
@ -205,7 +205,7 @@ class ImproveWritingButton extends StatelessWidget {
|
|||||||
return tooltipBuilder?.call(
|
return tooltipBuilder?.call(
|
||||||
context,
|
context,
|
||||||
_aiWriterToolbarItemId,
|
_aiWriterToolbarItemId,
|
||||||
_isAIEnabled(editorState)
|
_isAIWriterEnabled(editorState)
|
||||||
? LocaleKeys.document_plugins_aiWriter_improveWriting.tr()
|
? LocaleKeys.document_plugins_aiWriter_improveWriting.tr()
|
||||||
: LocaleKeys.document_plugins_appflowyAIEditDisabled.tr(),
|
: LocaleKeys.document_plugins_appflowyAIEditDisabled.tr(),
|
||||||
child,
|
child,
|
||||||
@ -240,10 +240,8 @@ void _insertAiNode(EditorState editorState, AiWriterCommand command) async {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool _isAIEnabled(EditorState editorState) {
|
bool _isAIWriterEnabled(EditorState editorState) {
|
||||||
final documentContext = editorState.document.root.context;
|
return true;
|
||||||
return documentContext == null ||
|
|
||||||
!documentContext.read<DocumentBloc>().isLocalMode;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool onlyShowInTextTypeAndExcludeTable(
|
bool onlyShowInTextTypeAndExcludeTable(
|
||||||
|
|||||||
@ -0,0 +1,34 @@
|
|||||||
|
import 'package:appflowy/generated/locale_keys.g.dart';
|
||||||
|
import 'package:appflowy/workspace/application/settings/ai/settings_ai_bloc.dart';
|
||||||
|
import 'package:appflowy/workspace/presentation/settings/pages/setting_ai_view/local_ai_setting.dart';
|
||||||
|
import 'package:appflowy/workspace/presentation/settings/shared/settings_body.dart';
|
||||||
|
import 'package:appflowy_backend/protobuf/flowy-user/protobuf.dart';
|
||||||
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
|
||||||
|
class LocalSettingsAIView extends StatelessWidget {
|
||||||
|
const LocalSettingsAIView({
|
||||||
|
super.key,
|
||||||
|
required this.userProfile,
|
||||||
|
required this.workspaceId,
|
||||||
|
});
|
||||||
|
|
||||||
|
final UserProfilePB userProfile;
|
||||||
|
final String workspaceId;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return BlocProvider<SettingsAIBloc>(
|
||||||
|
create: (_) => SettingsAIBloc(userProfile, workspaceId)
|
||||||
|
..add(const SettingsAIEvent.started()),
|
||||||
|
child: SettingsBody(
|
||||||
|
title: LocaleKeys.settings_aiPage_title.tr(),
|
||||||
|
description: "",
|
||||||
|
children: [
|
||||||
|
const LocalAISetting(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -132,7 +132,11 @@ impl ChatCloudService for LocalServerChatServiceImpl {
|
|||||||
),
|
),
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Err(FlowyError::local_ai_not_ready())
|
if self.local_ai.is_enabled() {
|
||||||
|
Err(FlowyError::local_ai_not_ready())
|
||||||
|
} else {
|
||||||
|
Err(FlowyError::local_ai_disabled())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -244,7 +248,11 @@ impl ChatCloudService for LocalServerChatServiceImpl {
|
|||||||
Err(_) => Ok(stream::once(async { Err(FlowyError::local_ai_unavailable()) }).boxed()),
|
Err(_) => Ok(stream::once(async { Err(FlowyError::local_ai_unavailable()) }).boxed()),
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Err(FlowyError::local_ai_not_ready())
|
if self.local_ai.is_enabled() {
|
||||||
|
Err(FlowyError::local_ai_not_ready())
|
||||||
|
} else {
|
||||||
|
Err(FlowyError::local_ai_disabled())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user