diff --git a/packages/core/src/chat/chat.test.ts b/packages/core/src/chat/chat.test.ts index add00049..c0abccb8 100644 --- a/packages/core/src/chat/chat.test.ts +++ b/packages/core/src/chat/chat.test.ts @@ -14,7 +14,7 @@ describe('ChatService', () => { const team = await prisma.team.create({ data: { name: 'Test Team', - settings: { transcode: { videoStrategy: 'best_match' } }, + settings: { transcode: { videoStrategy: 'best_match' }, chatbotAgentId: 'test-agent-id' }, sandbox: { create: {} }, }, }) @@ -73,10 +73,9 @@ describe('ChatService', () => { } it('should start a new chat session and trigger workflow', async () => { - const { user, project, rootFolder, agent } = await setupBasicData() + const { user, project, rootFolder } = await setupBasicData() const { sessionId, taskId } = await chatService.startOrContinueChat(user, { - agentId: agent.id, textPrompt: 'hello world', projectId: project.id, }) @@ -117,11 +116,10 @@ describe('ChatService', () => { }) it('should continue an existing chat session', async () => { - const { user, project, agent } = await setupBasicData() + const { user, project } = await setupBasicData() // Start const { sessionId } = await chatService.startOrContinueChat(user, { - agentId: agent.id, textPrompt: 'first message', projectId: project.id, }) @@ -130,7 +128,6 @@ describe('ChatService', () => { const { sessionId: nextSessionId, taskId: nextTaskId } = await chatService.startOrContinueChat( user, { - agentId: agent.id, textPrompt: 'second message', sessionId, }, @@ -156,7 +153,7 @@ describe('ChatService', () => { }) it('should inject context of referenced assets and attached files', async () => { - const { user, project, rootFolder, agent } = await setupBasicData() + const { user, project, rootFolder } = await setupBasicData() const childFolder = await prisma.asset.create({ data: { @@ -187,7 +184,6 @@ describe('ChatService', () => { }) const { taskId } = await chatService.startOrContinueChat(user, { - agentId: agent.id, textPrompt: 'process file', projectId: project.id, assetIds: [childFolder.id], @@ -207,16 +203,14 @@ describe('ChatService', () => { }) it('should list sessions of a user', async () => { - const { user, project, agent } = await setupBasicData() + const { user, project } = await setupBasicData() await chatService.startOrContinueChat(user, { - agentId: agent.id, textPrompt: 'chat 1', projectId: project.id, }) await chatService.startOrContinueChat(user, { - agentId: agent.id, textPrompt: 'chat 2', projectId: project.id, }) @@ -226,10 +220,9 @@ describe('ChatService', () => { }) it('should list messages mapped correctly', async () => { - const { user, project, agent } = await setupBasicData() + const { user, project } = await setupBasicData() const { sessionId } = await chatService.startOrContinueChat(user, { - agentId: agent.id, textPrompt: 'hello', projectId: project.id, }) @@ -263,10 +256,9 @@ describe('ChatService', () => { }) it('should delete session and cascade', async () => { - const { user, project, agent } = await setupBasicData() + const { user, project } = await setupBasicData() const { sessionId } = await chatService.startOrContinueChat(user, { - agentId: agent.id, textPrompt: 'to delete', projectId: project.id, }) diff --git a/packages/core/src/chat/chat.ts b/packages/core/src/chat/chat.ts index 43543678..1d704fd9 100644 --- a/packages/core/src/chat/chat.ts +++ b/packages/core/src/chat/chat.ts @@ -129,7 +129,6 @@ export class ChatService { req: ChatRequest, ): Promise<{ sessionId: string; taskId: string }> { const { - agentId, textPrompt, attachedFiles = [], assetIds = [], @@ -232,21 +231,32 @@ export class ChatService { const teamId = asset.project.teamId const projectId = asset.project.id + let agentId: string + let activeSessionId = passedSessionId + + if (activeSessionId) { + const sessionExists = await tx.agentSession.findUnique({ + where: { id: activeSessionId }, + select: { id: true, agentId: true }, + }) + if (!sessionExists) throw new Error('Session not found') + agentId = sessionExists.agentId + } else { + const teamSettings = (asset.project.team.settings || {}) as Record + const settingsAgentId = teamSettings.chatbotAgentId as string | undefined + if (!settingsAgentId) { + throw new Error('No chatbot agent configured for the team') + } + agentId = settingsAgentId + } + // Ensure AI agent configuration exists const agent = await tx.agent.findUnique({ where: { id: agentId } }) if (!agent) { throw new Error(`Agent with ID "${agentId}" not found`) } - let activeSessionId = passedSessionId - - if (activeSessionId) { - const sessionExists = await tx.agentSession.findUnique({ - where: { id: activeSessionId }, - select: { id: true }, - }) - if (!sessionExists) throw new Error('Session not found') - } else { + if (!activeSessionId) { const newSession = await tx.agentSession.create({ data: { agentId, diff --git a/packages/db/src/prisma-json-types.ts b/packages/db/src/prisma-json-types.ts index 3fc60f5c..8b30f73d 100644 --- a/packages/db/src/prisma-json-types.ts +++ b/packages/db/src/prisma-json-types.ts @@ -59,6 +59,7 @@ declare global { export interface Settings { transcode: TranscodeSettings + chatbotAgentId?: string | null } // ---------------------------------------------------------------------- diff --git a/packages/dtos/src/chat.ts b/packages/dtos/src/chat.ts index 9ad1b08a..d22c5a63 100644 --- a/packages/dtos/src/chat.ts +++ b/packages/dtos/src/chat.ts @@ -3,7 +3,6 @@ import type { AgentMessage } from '@earendil-works/pi-agent-core' export const chatRequestSchema = z .object({ - agentId: z.string(), textPrompt: z.string().optional(), attachedFiles: z.array(z.string()).optional(), // Uploaded file asset IDs assetIds: z.array(z.string()).optional(), // Workspace file/folder IDs referenced diff --git a/packages/dtos/src/team.ts b/packages/dtos/src/team.ts index fd5532b5..0c164800 100644 --- a/packages/dtos/src/team.ts +++ b/packages/dtos/src/team.ts @@ -76,6 +76,10 @@ export const updateTeamSettingsRequestSchema = z.discriminatedUnion('key', [ key: z.literal('transcode.videoStrategy'), value: z.nativeEnum(VideoTranscodeStrategy), }), + z.object({ + key: z.literal('chatbotAgentId'), + value: z.string().nullable(), + }), ]) export type UpdateTeamSettingsRequest = z.infer diff --git a/packages/webui/components/breadcrumb-nav.tsx b/packages/webui/components/breadcrumb-nav.tsx index 834c0f7c..824811f1 100644 --- a/packages/webui/components/breadcrumb-nav.tsx +++ b/packages/webui/components/breadcrumb-nav.tsx @@ -18,10 +18,13 @@ import { DockToRight, DockToRightFilled, } from '@/ui/components/ui/icons' -import { usePermissions } from '@/ui/hooks/use-permissions' -import { cn } from '@/ui/lib/utils' -import { m } from '@/ui/paraglide/messages.js' -import type { AncestorFolder } from '@shumai/dtos' +import { useQuery } from '@tanstack/react-query' +import { + Tooltip, + TooltipContent, + TooltipProvider, + TooltipTrigger, +} from '@/ui/components/ui/tooltip' import { Link, useNavigate } from '@tanstack/react-router' import { Check, @@ -33,6 +36,10 @@ import { List, Bot, } from 'lucide-react' +import { usePermissions } from '@/ui/hooks/use-permissions' +import { cn } from '@/ui/lib/utils' +import { m } from '@/ui/paraglide/messages.js' +import type { AncestorFolder } from '@shumai/dtos' interface BreadcrumbNavProps { teamId: string @@ -107,6 +114,21 @@ export function BreadcrumbNav({ const navigate = useNavigate() const { canEdit } = usePermissions(projectId) + const { data: teamSettings } = useQuery({ + queryKey: ['teams', teamId, 'settings'], + queryFn: async () => { + const res = await client.api.teams[':teamId'].settings.$get({ + param: { teamId }, + }) + if (!res.ok) throw new Error('failed to fetch settings') + return res.json() + }, + enabled: !!teamId && !isPublic, + }) + + const isChatbotDisabled = + !isPublic && !(teamSettings as { chatbotAgentId?: string | null })?.chatbotAgentId + const handleVersionClick = (versionId: string) => { if (!fileId) return if (isPublic && shareId) { @@ -444,22 +466,41 @@ export function BreadcrumbNav({ {/* Chatbot Toggle Button */} {!isPublic && onChatbotToggle && ( - + + + + + + + + +

+ {isChatbotDisabled + ? m.configure_chatbot_agent_first() + : isChatbotOpen + ? m.hide_chatbot() + : m.show_chatbot()} +

+
+
+
)} diff --git a/packages/webui/components/settings/AgentsSettings.tsx b/packages/webui/components/settings/AgentsSettings.tsx index 960d8203..e0f85000 100644 --- a/packages/webui/components/settings/AgentsSettings.tsx +++ b/packages/webui/components/settings/AgentsSettings.tsx @@ -2,6 +2,13 @@ import { client } from '@/ui/api/client' import { Card, CardContent } from '@/ui/components/ui/card' import { Button } from '@/ui/components/ui/button' import { Badge } from '@/ui/components/ui/badge' +import { + Select, + SelectContent, + SelectItem, + SelectTrigger, + SelectValue, +} from '@/ui/components/ui/select' import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query' import { Loader2, @@ -16,7 +23,7 @@ import { } from 'lucide-react' import { useState } from 'react' import { toast } from 'sonner' -import { AgentInfo, AgentType, ThinkingLevel } from '@shumai/dtos' +import { AgentInfo, AgentType, ThinkingLevel, UpdateTeamSettingsRequest } from '@shumai/dtos' import { AgentFormDialog } from './AgentFormDialog' import { DropdownMenu, @@ -143,6 +150,35 @@ export function AgentsSettings({ teamId }: AgentsSettingsProps) { }, }) + const { data: teamSettings } = useQuery({ + queryKey: ['teams', teamId, 'settings'], + queryFn: async () => { + const res = await client.api.teams[':teamId'].settings.$get({ + param: { teamId }, + }) + if (!res.ok) throw new Error('failed to fetch team settings') + return res.json() + }, + }) + + const updateSettingsMutation = useMutation({ + mutationFn: async (params: UpdateTeamSettingsRequest) => { + const res = await client.api.teams[':teamId'].settings.$patch({ + param: { teamId }, + json: params, + }) + if (!res.ok) throw new Error('failed to update settings') + return res.json() + }, + onSuccess: () => { + queryClient.invalidateQueries({ queryKey: ['teams', teamId, 'settings'] }) + toast.success(m.settings_saved()) + }, + onError: (err) => { + toast.error(err.message) + }, + }) + const toggleSection = (type: string) => { setExpandedSections((prev) => ({ ...prev, @@ -213,6 +249,55 @@ export function AgentsSettings({ teamId }: AgentsSettingsProps) { )} + + {/* Global Chatbot Agent Configuration Card */} + + +
+
+

+ + {m.global_chatbot()} +

+

+ {m.global_chatbot_description()} +

+
+
+ {agents.filter((a) => a.type === 'chat' && a.enabled).length === 0 ? ( +
+ {m.no_chat_agents_warning()} +
+ ) : ( + + )} +
+
+
+
{AGENT_TYPES.map((section) => { const typeAgents = agents.filter((a) => a.type === section.type) const Icon = section.icon diff --git a/packages/webui/messages/en.json b/packages/webui/messages/en.json index ae702d97..460d50cb 100644 --- a/packages/webui/messages/en.json +++ b/packages/webui/messages/en.json @@ -833,5 +833,11 @@ "history": "History", "send": "Send", "no_history_sessions": "No chat history found.", - "delete_session_confirm": "Are you sure you want to delete this chat session?" + "delete_session_confirm": "Are you sure you want to delete this chat session?", + "configure_chatbot_agent_first": "Please configure a chatbot agent in team settings first.", + "global_chatbot": "Global Chatbot", + "global_chatbot_description": "Select the agent that handles conversation inside the global chatbot sidebar.", + "select_chatbot_agent": "Select chatbot agent", + "no_chat_agents_warning": "No chat agents found. Please create a Chat Agent below first.", + "settings_saved": "Settings saved successfully" } diff --git a/packages/webui/messages/zh.json b/packages/webui/messages/zh.json index b29daa0f..f7c88b8e 100644 --- a/packages/webui/messages/zh.json +++ b/packages/webui/messages/zh.json @@ -833,5 +833,11 @@ "history": "历史记录", "send": "发送", "no_history_sessions": "暂无历史会话记录", - "delete_session_confirm": "您确定要删除此会话记录吗?" + "delete_session_confirm": "您确定要删除此会话记录吗?", + "configure_chatbot_agent_first": "请先在团队设置中配置聊天机器人智能体。", + "global_chatbot": "全局聊天机器人", + "global_chatbot_description": "选择在全局聊天机器人边栏中进行对话的智能体。", + "select_chatbot_agent": "选择聊天机器人智能体", + "no_chat_agents_warning": "未找到聊天智能体。请先在下方创建聊天智能体。", + "settings_saved": "设置保存成功" } diff --git a/packages/webui/paraglide/messages/_index.d.ts b/packages/webui/paraglide/messages/_index.d.ts index 61e28f70..c131843a 100644 --- a/packages/webui/paraglide/messages/_index.d.ts +++ b/packages/webui/paraglide/messages/_index.d.ts @@ -780,4 +780,10 @@ export * from "./history.js"; export * from "./send.js"; export * from "./no_history_sessions.js"; export * from "./delete_session_confirm.js"; +export * from "./configure_chatbot_agent_first.js"; +export * from "./global_chatbot.js"; +export * from "./global_chatbot_description.js"; +export * from "./select_chatbot_agent.js"; +export * from "./no_chat_agents_warning.js"; +export * from "./settings_saved.js"; export type LocalizedString = import("../runtime.js").LocalizedString; diff --git a/packages/webui/paraglide/messages/_index.js b/packages/webui/paraglide/messages/_index.js index 620ae19e..8b6f5c42 100644 --- a/packages/webui/paraglide/messages/_index.js +++ b/packages/webui/paraglide/messages/_index.js @@ -781,4 +781,10 @@ export * from './shumai_agent.js' export * from './history.js' export * from './send.js' export * from './no_history_sessions.js' -export * from './delete_session_confirm.js' \ No newline at end of file +export * from './delete_session_confirm.js' +export * from './configure_chatbot_agent_first.js' +export * from './global_chatbot.js' +export * from './global_chatbot_description.js' +export * from './select_chatbot_agent.js' +export * from './no_chat_agents_warning.js' +export * from './settings_saved.js' \ No newline at end of file diff --git a/packages/webui/paraglide/messages/configure_chatbot_agent_first.d.ts b/packages/webui/paraglide/messages/configure_chatbot_agent_first.d.ts new file mode 100644 index 00000000..b90f6ac4 --- /dev/null +++ b/packages/webui/paraglide/messages/configure_chatbot_agent_first.d.ts @@ -0,0 +1,16 @@ +/** +* | output | +* | --- | +* | "Please configure a chatbot agent in team settings first." | +* +* @param {Configure_Chatbot_Agent_FirstInputs} inputs +* @param {{ locale?: "en" | "zh" }} options +* @returns {LocalizedString} +*/ +export const configure_chatbot_agent_first: ((inputs?: Configure_Chatbot_Agent_FirstInputs, options?: { + locale?: "en" | "zh"; +}) => LocalizedString) & import("../runtime.js").MessageMetadata; +export type LocalizedString = import("../runtime.js").LocalizedString; +export type Configure_Chatbot_Agent_FirstInputs = {}; diff --git a/packages/webui/paraglide/messages/configure_chatbot_agent_first.js b/packages/webui/paraglide/messages/configure_chatbot_agent_first.js new file mode 100644 index 00000000..673bc3c2 --- /dev/null +++ b/packages/webui/paraglide/messages/configure_chatbot_agent_first.js @@ -0,0 +1,29 @@ +/* eslint-disable */ +import { getLocale, experimentalStaticLocale } from '../runtime.js'; + +/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */ + +/** @typedef {{}} Configure_Chatbot_Agent_FirstInputs */ + +const en_configure_chatbot_agent_first = /** @type {(inputs: Configure_Chatbot_Agent_FirstInputs) => LocalizedString} */ () => { + return /** @type {LocalizedString} */ (`Please configure a chatbot agent in team settings first.`) +}; + +const zh_configure_chatbot_agent_first = /** @type {(inputs: Configure_Chatbot_Agent_FirstInputs) => LocalizedString} */ () => { + return /** @type {LocalizedString} */ (`请先在团队设置中配置聊天机器人智能体。`) +}; + +/** +* | output | +* | --- | +* | "Please configure a chatbot agent in team settings first." | +* +* @param {Configure_Chatbot_Agent_FirstInputs} inputs +* @param {{ locale?: "en" | "zh" }} options +* @returns {LocalizedString} +*/ +export const configure_chatbot_agent_first = /** @type {((inputs?: Configure_Chatbot_Agent_FirstInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata} */ ((inputs = {}, options = {}) => { + const locale = experimentalStaticLocale ?? options.locale ?? getLocale() + if (locale === "en") return en_configure_chatbot_agent_first(inputs) + return zh_configure_chatbot_agent_first(inputs) +}); \ No newline at end of file diff --git a/packages/webui/paraglide/messages/global_chatbot.d.ts b/packages/webui/paraglide/messages/global_chatbot.d.ts new file mode 100644 index 00000000..3a913369 --- /dev/null +++ b/packages/webui/paraglide/messages/global_chatbot.d.ts @@ -0,0 +1,16 @@ +/** +* | output | +* | --- | +* | "Global Chatbot" | +* +* @param {Global_ChatbotInputs} inputs +* @param {{ locale?: "en" | "zh" }} options +* @returns {LocalizedString} +*/ +export const global_chatbot: ((inputs?: Global_ChatbotInputs, options?: { + locale?: "en" | "zh"; +}) => LocalizedString) & import("../runtime.js").MessageMetadata; +export type LocalizedString = import("../runtime.js").LocalizedString; +export type Global_ChatbotInputs = {}; diff --git a/packages/webui/paraglide/messages/global_chatbot.js b/packages/webui/paraglide/messages/global_chatbot.js new file mode 100644 index 00000000..5b9c327b --- /dev/null +++ b/packages/webui/paraglide/messages/global_chatbot.js @@ -0,0 +1,29 @@ +/* eslint-disable */ +import { getLocale, experimentalStaticLocale } from '../runtime.js'; + +/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */ + +/** @typedef {{}} Global_ChatbotInputs */ + +const en_global_chatbot = /** @type {(inputs: Global_ChatbotInputs) => LocalizedString} */ () => { + return /** @type {LocalizedString} */ (`Global Chatbot`) +}; + +const zh_global_chatbot = /** @type {(inputs: Global_ChatbotInputs) => LocalizedString} */ () => { + return /** @type {LocalizedString} */ (`全局聊天机器人`) +}; + +/** +* | output | +* | --- | +* | "Global Chatbot" | +* +* @param {Global_ChatbotInputs} inputs +* @param {{ locale?: "en" | "zh" }} options +* @returns {LocalizedString} +*/ +export const global_chatbot = /** @type {((inputs?: Global_ChatbotInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata} */ ((inputs = {}, options = {}) => { + const locale = experimentalStaticLocale ?? options.locale ?? getLocale() + if (locale === "en") return en_global_chatbot(inputs) + return zh_global_chatbot(inputs) +}); \ No newline at end of file diff --git a/packages/webui/paraglide/messages/global_chatbot_description.d.ts b/packages/webui/paraglide/messages/global_chatbot_description.d.ts new file mode 100644 index 00000000..5e79dd02 --- /dev/null +++ b/packages/webui/paraglide/messages/global_chatbot_description.d.ts @@ -0,0 +1,16 @@ +/** +* | output | +* | --- | +* | "Select the agent that handles conversation inside the global chatbot sidebar." | +* +* @param {Global_Chatbot_DescriptionInputs} inputs +* @param {{ locale?: "en" | "zh" }} options +* @returns {LocalizedString} +*/ +export const global_chatbot_description: ((inputs?: Global_Chatbot_DescriptionInputs, options?: { + locale?: "en" | "zh"; +}) => LocalizedString) & import("../runtime.js").MessageMetadata; +export type LocalizedString = import("../runtime.js").LocalizedString; +export type Global_Chatbot_DescriptionInputs = {}; diff --git a/packages/webui/paraglide/messages/global_chatbot_description.js b/packages/webui/paraglide/messages/global_chatbot_description.js new file mode 100644 index 00000000..76de80f0 --- /dev/null +++ b/packages/webui/paraglide/messages/global_chatbot_description.js @@ -0,0 +1,29 @@ +/* eslint-disable */ +import { getLocale, experimentalStaticLocale } from '../runtime.js'; + +/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */ + +/** @typedef {{}} Global_Chatbot_DescriptionInputs */ + +const en_global_chatbot_description = /** @type {(inputs: Global_Chatbot_DescriptionInputs) => LocalizedString} */ () => { + return /** @type {LocalizedString} */ (`Select the agent that handles conversation inside the global chatbot sidebar.`) +}; + +const zh_global_chatbot_description = /** @type {(inputs: Global_Chatbot_DescriptionInputs) => LocalizedString} */ () => { + return /** @type {LocalizedString} */ (`选择在全局聊天机器人边栏中进行对话的智能体。`) +}; + +/** +* | output | +* | --- | +* | "Select the agent that handles conversation inside the global chatbot sidebar." | +* +* @param {Global_Chatbot_DescriptionInputs} inputs +* @param {{ locale?: "en" | "zh" }} options +* @returns {LocalizedString} +*/ +export const global_chatbot_description = /** @type {((inputs?: Global_Chatbot_DescriptionInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata} */ ((inputs = {}, options = {}) => { + const locale = experimentalStaticLocale ?? options.locale ?? getLocale() + if (locale === "en") return en_global_chatbot_description(inputs) + return zh_global_chatbot_description(inputs) +}); \ No newline at end of file diff --git a/packages/webui/paraglide/messages/no_chat_agents_warning.d.ts b/packages/webui/paraglide/messages/no_chat_agents_warning.d.ts new file mode 100644 index 00000000..9c6dc575 --- /dev/null +++ b/packages/webui/paraglide/messages/no_chat_agents_warning.d.ts @@ -0,0 +1,16 @@ +/** +* | output | +* | --- | +* | "No chat agents found. Please create a Chat Agent below first." | +* +* @param {No_Chat_Agents_WarningInputs} inputs +* @param {{ locale?: "en" | "zh" }} options +* @returns {LocalizedString} +*/ +export const no_chat_agents_warning: ((inputs?: No_Chat_Agents_WarningInputs, options?: { + locale?: "en" | "zh"; +}) => LocalizedString) & import("../runtime.js").MessageMetadata; +export type LocalizedString = import("../runtime.js").LocalizedString; +export type No_Chat_Agents_WarningInputs = {}; diff --git a/packages/webui/paraglide/messages/no_chat_agents_warning.js b/packages/webui/paraglide/messages/no_chat_agents_warning.js new file mode 100644 index 00000000..abaebf4b --- /dev/null +++ b/packages/webui/paraglide/messages/no_chat_agents_warning.js @@ -0,0 +1,29 @@ +/* eslint-disable */ +import { getLocale, experimentalStaticLocale } from '../runtime.js'; + +/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */ + +/** @typedef {{}} No_Chat_Agents_WarningInputs */ + +const en_no_chat_agents_warning = /** @type {(inputs: No_Chat_Agents_WarningInputs) => LocalizedString} */ () => { + return /** @type {LocalizedString} */ (`No chat agents found. Please create a Chat Agent below first.`) +}; + +const zh_no_chat_agents_warning = /** @type {(inputs: No_Chat_Agents_WarningInputs) => LocalizedString} */ () => { + return /** @type {LocalizedString} */ (`未找到聊天智能体。请先在下方创建聊天智能体。`) +}; + +/** +* | output | +* | --- | +* | "No chat agents found. Please create a Chat Agent below first." | +* +* @param {No_Chat_Agents_WarningInputs} inputs +* @param {{ locale?: "en" | "zh" }} options +* @returns {LocalizedString} +*/ +export const no_chat_agents_warning = /** @type {((inputs?: No_Chat_Agents_WarningInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata} */ ((inputs = {}, options = {}) => { + const locale = experimentalStaticLocale ?? options.locale ?? getLocale() + if (locale === "en") return en_no_chat_agents_warning(inputs) + return zh_no_chat_agents_warning(inputs) +}); \ No newline at end of file diff --git a/packages/webui/paraglide/messages/select_chatbot_agent.d.ts b/packages/webui/paraglide/messages/select_chatbot_agent.d.ts new file mode 100644 index 00000000..5a79a654 --- /dev/null +++ b/packages/webui/paraglide/messages/select_chatbot_agent.d.ts @@ -0,0 +1,16 @@ +/** +* | output | +* | --- | +* | "Select chatbot agent" | +* +* @param {Select_Chatbot_AgentInputs} inputs +* @param {{ locale?: "en" | "zh" }} options +* @returns {LocalizedString} +*/ +export const select_chatbot_agent: ((inputs?: Select_Chatbot_AgentInputs, options?: { + locale?: "en" | "zh"; +}) => LocalizedString) & import("../runtime.js").MessageMetadata; +export type LocalizedString = import("../runtime.js").LocalizedString; +export type Select_Chatbot_AgentInputs = {}; diff --git a/packages/webui/paraglide/messages/select_chatbot_agent.js b/packages/webui/paraglide/messages/select_chatbot_agent.js new file mode 100644 index 00000000..60996507 --- /dev/null +++ b/packages/webui/paraglide/messages/select_chatbot_agent.js @@ -0,0 +1,29 @@ +/* eslint-disable */ +import { getLocale, experimentalStaticLocale } from '../runtime.js'; + +/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */ + +/** @typedef {{}} Select_Chatbot_AgentInputs */ + +const en_select_chatbot_agent = /** @type {(inputs: Select_Chatbot_AgentInputs) => LocalizedString} */ () => { + return /** @type {LocalizedString} */ (`Select chatbot agent`) +}; + +const zh_select_chatbot_agent = /** @type {(inputs: Select_Chatbot_AgentInputs) => LocalizedString} */ () => { + return /** @type {LocalizedString} */ (`选择聊天机器人智能体`) +}; + +/** +* | output | +* | --- | +* | "Select chatbot agent" | +* +* @param {Select_Chatbot_AgentInputs} inputs +* @param {{ locale?: "en" | "zh" }} options +* @returns {LocalizedString} +*/ +export const select_chatbot_agent = /** @type {((inputs?: Select_Chatbot_AgentInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata} */ ((inputs = {}, options = {}) => { + const locale = experimentalStaticLocale ?? options.locale ?? getLocale() + if (locale === "en") return en_select_chatbot_agent(inputs) + return zh_select_chatbot_agent(inputs) +}); \ No newline at end of file diff --git a/packages/webui/paraglide/messages/settings_saved.d.ts b/packages/webui/paraglide/messages/settings_saved.d.ts new file mode 100644 index 00000000..c2376844 --- /dev/null +++ b/packages/webui/paraglide/messages/settings_saved.d.ts @@ -0,0 +1,16 @@ +/** +* | output | +* | --- | +* | "Settings saved successfully" | +* +* @param {Settings_SavedInputs} inputs +* @param {{ locale?: "en" | "zh" }} options +* @returns {LocalizedString} +*/ +export const settings_saved: ((inputs?: Settings_SavedInputs, options?: { + locale?: "en" | "zh"; +}) => LocalizedString) & import("../runtime.js").MessageMetadata; +export type LocalizedString = import("../runtime.js").LocalizedString; +export type Settings_SavedInputs = {}; diff --git a/packages/webui/paraglide/messages/settings_saved.js b/packages/webui/paraglide/messages/settings_saved.js new file mode 100644 index 00000000..ee681b7e --- /dev/null +++ b/packages/webui/paraglide/messages/settings_saved.js @@ -0,0 +1,29 @@ +/* eslint-disable */ +import { getLocale, experimentalStaticLocale } from '../runtime.js'; + +/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */ + +/** @typedef {{}} Settings_SavedInputs */ + +const en_settings_saved = /** @type {(inputs: Settings_SavedInputs) => LocalizedString} */ () => { + return /** @type {LocalizedString} */ (`Settings saved successfully`) +}; + +const zh_settings_saved = /** @type {(inputs: Settings_SavedInputs) => LocalizedString} */ () => { + return /** @type {LocalizedString} */ (`设置保存成功`) +}; + +/** +* | output | +* | --- | +* | "Settings saved successfully" | +* +* @param {Settings_SavedInputs} inputs +* @param {{ locale?: "en" | "zh" }} options +* @returns {LocalizedString} +*/ +export const settings_saved = /** @type {((inputs?: Settings_SavedInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata} */ ((inputs = {}, options = {}) => { + const locale = experimentalStaticLocale ?? options.locale ?? getLocale() + if (locale === "en") return en_settings_saved(inputs) + return zh_settings_saved(inputs) +}); \ No newline at end of file diff --git a/packages/webui/stores/chatbot.ts b/packages/webui/stores/chatbot.ts index 117ab708..abddd162 100644 --- a/packages/webui/stores/chatbot.ts +++ b/packages/webui/stores/chatbot.ts @@ -146,7 +146,6 @@ export const useChatbotStore = create((set) => ({ try { const res = await client.api.chat.$post({ json: { - agentId: 'default', textPrompt: text, assetIds, sessionId: state.currentSessionId || undefined,