diff --git a/web/src/app/home/bots/components/bot-form/BotForm.tsx b/web/src/app/home/bots/components/bot-form/BotForm.tsx index 5e030021..2c76c5fc 100644 --- a/web/src/app/home/bots/components/bot-form/BotForm.tsx +++ b/web/src/app/home/bots/components/bot-form/BotForm.tsx @@ -49,6 +49,7 @@ import { } from '@/components/ui/select'; import { Switch } from '@/components/ui/switch'; import { extractI18nObject } from '@/i18n/I18nProvider'; +import { CustomApiError } from '@/app/infra/entities/common'; const getFormSchema = (t: (key: string) => string) => z.object({ @@ -241,7 +242,9 @@ export default function BotForm({ } }) .catch((err) => { - toast.error(t('bots.getBotConfigError') + err.message); + toast.error( + t('bots.getBotConfigError') + (err as CustomApiError).msg, + ); }); } else { form.reset(); @@ -384,7 +387,7 @@ export default function BotForm({ toast.success(t('bots.saveSuccess')); }) .catch((err) => { - toast.error(t('bots.saveError') + err.message); + toast.error(t('bots.saveError') + err.msg); }) .finally(() => { setIsLoading(false); @@ -410,7 +413,7 @@ export default function BotForm({ onNewBotCreated(res.uuid); }) .catch((err) => { - toast.error(t('bots.createError') + err.message); + toast.error(t('bots.createError') + err.msg); }) .finally(() => { setIsLoading(false); @@ -429,7 +432,7 @@ export default function BotForm({ toast.success(t('bots.deleteSuccess')); }) .catch((err) => { - toast.error(t('bots.deleteError') + err.message); + toast.error(t('bots.deleteError') + err.msg); }); } } diff --git a/web/src/app/home/bots/page.tsx b/web/src/app/home/bots/page.tsx index b3c0dd25..1550af53 100644 --- a/web/src/app/home/bots/page.tsx +++ b/web/src/app/home/bots/page.tsx @@ -11,6 +11,7 @@ import { toast } from 'sonner'; import { useTranslation } from 'react-i18next'; import { extractI18nObject } from '@/i18n/I18nProvider'; import BotDetailDialog from '@/app/home/bots/BotDetailDialog'; +import { CustomApiError } from '@/app/infra/entities/common'; export default function BotConfigPage() { const { t } = useTranslation(); @@ -54,10 +55,7 @@ export default function BotConfigPage() { }) .catch((err) => { console.error('get bot list error', err); - toast.error(t('bots.getBotListError') + err.message); - }) - .finally(() => { - // setIsLoading(false); + toast.error(t('bots.getBotListError') + (err as CustomApiError).msg); }); } diff --git a/web/src/app/home/components/dynamic-form/DynamicFormItemComponent.tsx b/web/src/app/home/components/dynamic-form/DynamicFormItemComponent.tsx index 16642e84..a1285f12 100644 --- a/web/src/app/home/components/dynamic-form/DynamicFormItemComponent.tsx +++ b/web/src/app/home/components/dynamic-form/DynamicFormItemComponent.tsx @@ -108,7 +108,7 @@ export default function DynamicFormItemComponent({ setLlmModels(models); }) .catch((err) => { - toast.error('Failed to get LLM model list: ' + err.message); + toast.error('Failed to get LLM model list: ' + err.msg); }); } }, [config.type]); @@ -124,7 +124,7 @@ export default function DynamicFormItemComponent({ setKnowledgeBases(resp.bases); }) .catch((err) => { - toast.error('Failed to get knowledge base list: ' + err.message); + toast.error('Failed to get knowledge base list: ' + err.msg); }); // Fetch plugin system status @@ -165,7 +165,7 @@ export default function DynamicFormItemComponent({ setBots(resp.bots); }) .catch((err) => { - toast.error('Failed to get bot list: ' + err.message); + toast.error('Failed to get bot list: ' + err.msg); }); } }, [config.type]); diff --git a/web/src/app/home/components/models-dialog/ModelsDialog.tsx b/web/src/app/home/components/models-dialog/ModelsDialog.tsx index 201e2570..9f030cd2 100644 --- a/web/src/app/home/components/models-dialog/ModelsDialog.tsx +++ b/web/src/app/home/components/models-dialog/ModelsDialog.tsx @@ -22,6 +22,7 @@ import { ProviderModels, LANGBOT_MODELS_PROVIDER_REQUESTER, } from './types'; +import { CustomApiError } from '@/app/infra/entities/common'; interface ModelsDialogProps { open: boolean; @@ -349,7 +350,8 @@ export default function ModelsDialog({ const duration = Date.now() - startTime; setTestResult({ success: true, duration }); } catch (err) { - toast.error(t('models.testError') + ': ' + (err as Error).message); + console.error('Failed to test model', err); + toast.error(t('models.testError') + ': ' + (err as CustomApiError).msg); setTestResult(null); } finally { setIsTesting(false); diff --git a/web/src/app/home/components/models-dialog/component/provider-form/ProviderForm.tsx b/web/src/app/home/components/models-dialog/component/provider-form/ProviderForm.tsx index 209f23cc..94e4b0f9 100644 --- a/web/src/app/home/components/models-dialog/component/provider-form/ProviderForm.tsx +++ b/web/src/app/home/components/models-dialog/component/provider-form/ProviderForm.tsx @@ -28,6 +28,7 @@ import { import { DialogFooter } from '@/components/ui/dialog'; import { toast } from 'sonner'; import { extractI18nObject } from '@/i18n/I18nProvider'; +import { CustomApiError } from '@/app/infra/entities/common'; const getFormSchema = (t: (key: string) => string) => z.object({ @@ -124,7 +125,7 @@ export default function ProviderForm({ } onFormSubmit(); } catch (err) { - toast.error(t('models.providerSaveError') + (err as Error).message); + toast.error(t('models.providerSaveError') + (err as CustomApiError).msg); } } diff --git a/web/src/app/home/knowledge/components/external-kb-form/ExternalKBForm.tsx b/web/src/app/home/knowledge/components/external-kb-form/ExternalKBForm.tsx index f371f860..e5bf9d24 100644 --- a/web/src/app/home/knowledge/components/external-kb-form/ExternalKBForm.tsx +++ b/web/src/app/home/knowledge/components/external-kb-form/ExternalKBForm.tsx @@ -291,7 +291,7 @@ export default function ExternalKBForm({ toast.success(t('knowledge.updateExternalSuccess')); }) .catch((err) => { - toast.error('Failed to update KB: ' + err.message); + toast.error('Failed to update KB: ' + err.msg); }); } else { // Create new KB @@ -303,7 +303,7 @@ export default function ExternalKBForm({ form.reset(); }) .catch((err) => { - toast.error('Failed to create KB: ' + err.message); + toast.error('Failed to create KB: ' + err.msg); }); } } @@ -321,7 +321,7 @@ export default function ExternalKBForm({ toast.success(t('knowledge.deleteExternalSuccess')); }) .catch((err) => { - toast.error('Failed to delete KB: ' + err.message); + toast.error('Failed to delete KB: ' + err.msg); }); } diff --git a/web/src/app/home/pipelines/components/pipeline-form/PipelineFormComponent.tsx b/web/src/app/home/pipelines/components/pipeline-form/PipelineFormComponent.tsx index 6f86d6ef..65bbc526 100644 --- a/web/src/app/home/pipelines/components/pipeline-form/PipelineFormComponent.tsx +++ b/web/src/app/home/pipelines/components/pipeline-form/PipelineFormComponent.tsx @@ -181,7 +181,7 @@ export default function PipelineFormComponent({ toast.success(t('pipelines.createSuccess')); }) .catch((err) => { - toast.error(t('pipelines.createError') + err.message); + toast.error(t('pipelines.createError') + err.msg); }); } @@ -211,7 +211,7 @@ export default function PipelineFormComponent({ toast.success(t('pipelines.saveSuccess')); }) .catch((err) => { - toast.error(t('pipelines.saveError') + err.message); + toast.error(t('pipelines.saveError') + err.msg); }); } @@ -340,7 +340,7 @@ export default function PipelineFormComponent({ toast.success(t('pipelines.deleteSuccess')); }) .catch((err) => { - toast.error(t('pipelines.deleteError') + err.message); + toast.error(t('pipelines.deleteError') + err.msg); }); } }; @@ -360,7 +360,7 @@ export default function PipelineFormComponent({ onCancel(); }) .catch((err) => { - toast.error(t('pipelines.createError') + err.message); + toast.error(t('pipelines.createError') + err.msg); }); } }; diff --git a/web/src/app/home/plugins/components/plugin-sort/PluginSortDialog.tsx b/web/src/app/home/plugins/components/plugin-sort/PluginSortDialog.tsx deleted file mode 100644 index 1c601e77..00000000 --- a/web/src/app/home/plugins/components/plugin-sort/PluginSortDialog.tsx +++ /dev/null @@ -1,214 +0,0 @@ -// 'use client'; - -// import * as React from 'react'; -// import { useState, useEffect } from 'react'; -// import { PluginCardVO } from '@/app/home/plugins/plugin-installed/PluginCardVO'; -// import { httpClient } from '@/app/infra/http/HttpClient'; -// import { PluginReorderElement } from '@/app/infra/entities/api'; -// import { toast } from 'sonner'; -// import { -// Dialog, -// DialogContent, -// DialogHeader, -// DialogTitle, -// DialogFooter, -// } from '@/components/ui/dialog'; -// import { Button } from '@/components/ui/button'; -// import { -// DndContext, -// closestCenter, -// KeyboardSensor, -// PointerSensor, -// useSensor, -// useSensors, -// DragEndEvent, -// } from '@dnd-kit/core'; -// import { -// arrayMove, -// SortableContext, -// sortableKeyboardCoordinates, -// useSortable, -// verticalListSortingStrategy, -// } from '@dnd-kit/sortable'; -// import { CSS } from '@dnd-kit/utilities'; -// import { useTranslation } from 'react-i18next'; -// import { extractI18nObject } from '@/i18n/I18nProvider'; - -// interface PluginSortDialogProps { -// open: boolean; -// onOpenChange: (open: boolean) => void; -// onSortComplete: () => void; -// } - -// function SortablePluginItem({ plugin }: { plugin: PluginCardVO }) { -// const { attributes, listeners, setNodeRef, transform, transition } = -// useSortable({ -// id: `${plugin.author}-${plugin.name}`, -// }); - -// const style = { -// transform: CSS.Transform.toString(transform), -// transition, -// }; - -// return ( -//