Build and run agents you can see, understand and trust.
Python agentchatbotlarge-language-modelsllmllm-agentmcpmulti-agentmulti-modalreact-agentrealtime-agentvoice-agentvoice-assistant
feat(webui): clarify the credential sidebar with provider grouping (#1829)
Xinmin Zenga815ff6c20c9
diff --git a/examples/web_ui/frontend/src/i18n/locales/en.json b/examples/web_ui/frontend/src/i18n/locales/en.jsonindex 3d54547d6..2dab8c40b 100644--- a/examples/web_ui/frontend/src/i18n/locales/en.json+++ b/examples/web_ui/frontend/src/i18n/locales/en.json@@ -168,7 +168,6 @@"description": "Update the saved credential for this provider."},"credential": {- "addConfig": "Add configuration","noProviders": "No providers available","noConfigs": "No configurations","selectHint": "No credential selected",@@ -178,6 +177,8 @@"noModelsDescription": "This provider returned no models.","deleteEntity": "credential","subtitle": "Model API credential configuration",+ "configured": "Configured",+ "addProvider": "Add credential","reasoning": "Reasoning","maxContext": "Max. Context","maxOutput": "Max. Output",diff --git a/examples/web_ui/frontend/src/i18n/locales/zh.json b/examples/web_ui/frontend/src/i18n/locales/zh.jsonindex 9d230e92f..5b7986045 100644--- a/examples/web_ui/frontend/src/i18n/locales/zh.json+++ b/examples/web_ui/frontend/src/i18n/locales/zh.json@@ -168,7 +168,6 @@"description": "更新该提供商已保存的凭证。"},"credential": {- "addConfig": "添加配置","noProviders": "暂无可用提供商","noConfigs": "暂无配置","selectHint": "未选择凭证",@@ -178,6 +177,8 @@"noModelsDescription": "该提供商未返回任何模型。","deleteEntity": "凭证","subtitle": "模型 API 授权配置",+ "configured": "已配置",+ "addProvider": "添加凭证","reasoning": "推理模型","maxContext": "最大上下文","maxOutput": "最大输出",diff --git a/examples/web_ui/frontend/src/pages/credential/index.tsx b/examples/web_ui/frontend/src/pages/credential/index.tsxindex b7e208b17..7399bc2bb 100644--- a/examples/web_ui/frontend/src/pages/credential/index.tsx+++ b/examples/web_ui/frontend/src/pages/credential/index.tsx@@ -16,7 +16,6 @@ import {Sidebar,SidebarContent,SidebarGroup,- SidebarGroupAction,SidebarGroupContent,SidebarGroupLabel,SidebarHeader,@@ -344,6 +343,11 @@ export const CredentialPage = () => {};});+ // Split providers so the user's actual configuration leads, and the+ // (mostly empty) "add a provider" entries don't drown it out.+ const configuredGroups = groupedByType.filter((g) => g.records.length > 0);+ const totalConfigured = configuredGroups.reduce((n, g) => n + g.records.length, 0);+const handleOpenCreate = useCallback((type?: string) => {setCreateDefaultType(type);setCreateOpen(true);@@ -378,40 +382,68 @@ export const CredentialPage = () => {</EmptyHeader></Empty>) : (- groupedByType.map(({ type, title, records }) => (- <SidebarGroup key={type}>- <SidebarGroupLabel>{title}</SidebarGroupLabel>- <SidebarGroupAction- asChild- title={t('credential.addConfig')}- onClick={() => handleOpenCreate(type)}- >- <Button variant="ghost" size={'icon-sm'}>- <Plus />- </Button>- </SidebarGroupAction>+ <>+ {/* Configured credentials lead — this is what the user actually set up. */}+ {configuredGroups.length > 0 && (+ <SidebarGroup>+ <SidebarGroupLabel>+ {t('credential.configured')} ({totalConfigured})+ </SidebarGroupLabel>+ <SidebarGroupContent className="flex flex-col gap-y-4">+ {configuredGroups.map(({ type, title, records }) => (+ <div key={type}>+ <div className="px-2 pb-1.5 text-xs font-semibold text-foreground/70">+ {title}+ </div>+ <SidebarMenu className="pl-4">+ {records.map((rec) => {+ const name =+ (rec.data.name as string | undefined) ??+ rec.id;+ return (+ <SidebarMenuItem key={rec.id}>+ <SidebarMenuButton+ isActive={selectedId === rec.id}+ onClick={() =>+ setSelectedId(rec.id)+ }+ >+ <span className="min-w-0 flex-1 truncate">+ {name}+ </span>+ </SidebarMenuButton>+ </SidebarMenuItem>+ );+ })}+ </SidebarMenu>+ </div>+ ))}+ </SidebarGroupContent>+ </SidebarGroup>+ )}++ {/* Add credential — every provider is an entry point (including+ configured ones, to add more under the same provider). */}+ <SidebarGroup>+ <SidebarGroupLabel>{t('credential.addProvider')}</SidebarGroupLabel><SidebarGroupContent>- {records.length > 0 && (- <SidebarMenu>- {records.map((rec) => {- const name =- (rec.data.name as string | undefined) ?? rec.id;- return (- <SidebarMenuItem key={rec.id}>- <SidebarMenuButton- isActive={selectedId === rec.id}- onClick={() => setSelectedId(rec.id)}- >- <span className="truncate">{name}</span>- </SidebarMenuButton>- </SidebarMenuItem>- );- })}- </SidebarMenu>- )}+ <SidebarMenu>+ {groupedByType.map(({ type, title }) => (+ <SidebarMenuItem key={type}>+ <SidebarMenuButton+ onClick={() => handleOpenCreate(type)}+ >+ <Plus />+ <span className="min-w-0 flex-1 truncate">+ {title}+ </span>+ </SidebarMenuButton>+ </SidebarMenuItem>+ ))}+ </SidebarMenu></SidebarGroupContent></SidebarGroup>- ))+ </>)}</SidebarContent></Sidebar>diff --git a/src/agentscope/credential/_moonshot.py b/src/agentscope/credential/_moonshot.pyindex f0b294775..0ce5728ad 100644--- a/src/agentscope/credential/_moonshot.py+++ b/src/agentscope/credential/_moonshot.py@@ -2,7 +2,7 @@"""The Moonshot AI credential."""from typing import Literal, Type, TYPE_CHECKING-from pydantic import Field, SecretStr+from pydantic import ConfigDict, Field, SecretStrfrom ._base import CredentialBase@@ -15,6 +15,10 @@ _MOONSHOT_BASE_URL = "https://api.moonshot.cn/v1"class MoonshotCredential(CredentialBase):"""The Moonshot AI credential model."""+ model_config = ConfigDict(+ title="Moonshot API",+ )+type: Literal["moonshot_credential"] = "moonshot_credential""""The credential type."""