Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

chore: separate model

Nathan4c39908748fa
diff --git a/frontend/appflowy_flutter/lib/ai/widgets/prompt_input/desktop_prompt_text_field.dart b/frontend/appflowy_flutter/lib/ai/widgets/prompt_input/desktop_prompt_text_field.dart
index ba2d035183..bf21a59ad0 100644
--- a/frontend/appflowy_flutter/lib/ai/widgets/prompt_input/desktop_prompt_text_field.dart
+++ b/frontend/appflowy_flutter/lib/ai/widgets/prompt_input/desktop_prompt_text_field.dart
@@ -761,29 +761,94 @@ class _PopoverSelectModel extends StatelessWidget {
Widget build(BuildContext context) {
return BlocBuilder<SelectModelBloc, SelectModelState>(
builder: (context, state) {
- return ListView.builder(
- shrinkWrap: true,
- itemCount: state.availableModels?.models.length ?? 0,
+ if (state.availableModels == null ||
+ state.availableModels!.models.isEmpty) {
+ return const SizedBox.shrink();
+ }
+
+ // Separate models into local and cloud models
+ final localModels = state.availableModels!.models
+ .where((model) => model.isLocal)
+ .toList();
+
+ final cloudModels = state.availableModels!.models
+ .where((model) => !model.isLocal)
+ .toList();
+
+ return Padding(
padding: const EdgeInsets.fromLTRB(8, 4, 8, 12),
- itemBuilder: (context, index) {
- return _ModelItem(
- model: state.availableModels!.models[index],
- onTap: () {
- context.read<SelectModelBloc>().add(
- SelectModelEvent.selectModel(
- state.availableModels!.models[index],
- ),
- );
- onClose();
- },
- );
- },
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ // Local AI Models Section
+ if (localModels.isNotEmpty) ...[
+ _ModelSectionHeader(
+ title: LocaleKeys.chat_changeFormat_localModel.tr(),
+ ),
+ const SizedBox(height: 4),
+ ...localModels.map(
+ (model) => _ModelItem(
+ model: model,
+ onTap: () {
+ context.read<SelectModelBloc>().add(
+ SelectModelEvent.selectModel(model),
+ );
+ onClose();
+ },
+ ),
+ ),
+ const SizedBox(height: 8),
+ ],
+
+ // Cloud AI Models Section
+ if (cloudModels.isNotEmpty) ...[
+ if (localModels.isNotEmpty)
+ _ModelSectionHeader(
+ title: LocaleKeys.chat_changeFormat_cloudModel.tr(),
+ ),
+ const VSpace(4),
+ ...cloudModels.map(
+ (model) => _ModelItem(
+ model: model,
+ onTap: () {
+ context.read<SelectModelBloc>().add(
+ SelectModelEvent.selectModel(model),
+ );
+ onClose();
+ },
+ ),
+ ),
+ ],
+ ],
+ ),
);
},
);
}
}
+class _ModelSectionHeader extends StatelessWidget {
+ const _ModelSectionHeader({
+ required this.title,
+ });
+
+ final String title;
+
+ @override
+ Widget build(BuildContext context) {
+ return Padding(
+ padding: const EdgeInsets.only(top: 4, bottom: 2),
+ child: FlowyText(
+ title,
+ fontSize: 12,
+ color: Theme.of(context).hintColor,
+ fontWeight: FontWeight.w500,
+ ),
+ );
+ }
+}
+
class _ModelItem extends StatelessWidget {
const _ModelItem({
required this.model,
@@ -795,10 +860,8 @@ class _ModelItem extends StatelessWidget {
@override
Widget build(BuildContext context) {
- var modelName = model.name;
- if (model.isLocal) {
- modelName += " (${LocaleKeys.chat_changeFormat_localModel.tr()})";
- }
+ final modelName = model.name;
+
return FlowyTextButton(
modelName,
fillColor: Colors.transparent,
diff --git a/frontend/resources/translations/en.json b/frontend/resources/translations/en.json
index 12ae84cc8e..62de8be000 100644
--- a/frontend/resources/translations/en.json
+++ b/frontend/resources/translations/en.json
@@ -248,6 +248,7 @@
"blankDescription": "Format response",
"defaultDescription": "Auto mode",
"localModel": "Local Model",
+ "cloudModel": "Cloud Model",
"switchModel": "Switch model",
"textWithImageDescription": "@:chat.changeFormat.text with image",
"numberWithImageDescription": "@:chat.changeFormat.number with image",