mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-09-27 03:46:39 +08:00
style(assistant): compact model picker in header
This commit is contained in:
@@ -205,14 +205,44 @@ function AssistantPanel({ storageKey }: { storageKey: string }) {
|
||||
<header className="flex items-center gap-2 border-b p-3">
|
||||
<MessageCircle className="size-5 text-primary" />
|
||||
<div className="min-w-0 flex-1">
|
||||
<h2 className="font-semibold">{t('assistant.title')}</h2>
|
||||
<h2 className="truncate font-semibold">{t('assistant.title')}</h2>
|
||||
<p className="truncate text-xs text-muted-foreground">
|
||||
{t('assistant.subtitle')}
|
||||
</p>
|
||||
</div>
|
||||
{open && (
|
||||
<div
|
||||
className="w-28 min-w-0 shrink-0"
|
||||
title={t('assistant.modelHint')}
|
||||
>
|
||||
<DynamicFormItemComponent
|
||||
config={{
|
||||
id: 'assistant-model',
|
||||
name: 'assistant-model',
|
||||
type: DynamicFormItemType.LLM_MODEL_SELECTOR,
|
||||
default: '',
|
||||
required: false,
|
||||
label: { en_US: 'Assistant model', zh_Hans: '助手模型' },
|
||||
}}
|
||||
field={{
|
||||
name: 'assistant-model',
|
||||
value: modelUuid,
|
||||
onChange: setModelUuid,
|
||||
onBlur: () => {},
|
||||
ref: () => {},
|
||||
disabled:
|
||||
busy ||
|
||||
(!!conversation && conversation.status !== 'ready'),
|
||||
}}
|
||||
requiredModelAbility="func_call"
|
||||
compactModelSelector
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="size-7 shrink-0"
|
||||
disabled={busy}
|
||||
onClick={reset}
|
||||
aria-label={t('assistant.newChat')}
|
||||
@@ -222,39 +252,13 @@ function AssistantPanel({ storageKey }: { storageKey: string }) {
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="size-7 shrink-0"
|
||||
onClick={() => setOpen(false)}
|
||||
aria-label={t('assistant.close')}
|
||||
>
|
||||
<X />
|
||||
</Button>
|
||||
</header>
|
||||
{open && (
|
||||
<div className="space-y-1 border-b px-3 py-2">
|
||||
<span className="text-xs text-muted-foreground">
|
||||
{t('assistant.modelHint')}
|
||||
</span>
|
||||
<DynamicFormItemComponent
|
||||
config={{
|
||||
id: 'assistant-model',
|
||||
name: 'assistant-model',
|
||||
type: DynamicFormItemType.LLM_MODEL_SELECTOR,
|
||||
default: '',
|
||||
required: false,
|
||||
label: { en_US: 'Assistant model', zh_Hans: '助手模型' },
|
||||
}}
|
||||
field={{
|
||||
name: 'assistant-model',
|
||||
value: modelUuid,
|
||||
onChange: setModelUuid,
|
||||
onBlur: () => {},
|
||||
ref: () => {},
|
||||
disabled:
|
||||
busy || (!!conversation && conversation.status !== 'ready'),
|
||||
}}
|
||||
requiredModelAbility="func_call"
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
<div
|
||||
className="flex-1 space-y-3 overflow-y-auto p-4"
|
||||
aria-live="polite"
|
||||
|
||||
@@ -89,6 +89,7 @@ export default function DynamicFormItemComponent({
|
||||
setFormValue,
|
||||
systemContext,
|
||||
requiredModelAbility,
|
||||
compactModelSelector = false,
|
||||
}: {
|
||||
config: IDynamicFormItemSchema;
|
||||
field: ControllerRenderProps<any, any>;
|
||||
@@ -97,6 +98,7 @@ export default function DynamicFormItemComponent({
|
||||
setFormValue?: (name: string, value: unknown) => void;
|
||||
systemContext?: Record<string, unknown>;
|
||||
requiredModelAbility?: string;
|
||||
compactModelSelector?: boolean;
|
||||
}) {
|
||||
const [llmModels, setLlmModels] = useState<LLMModel[]>([]);
|
||||
const [embeddingModels, setEmbeddingModels] = useState<EmbeddingModel[]>([]);
|
||||
@@ -468,7 +470,14 @@ export default function DynamicFormItemComponent({
|
||||
onValueChange={field.onChange}
|
||||
disabled={field.disabled}
|
||||
>
|
||||
<SelectTrigger className="min-w-0 bg-[#ffffff] dark:bg-[#2a2a2e]">
|
||||
<SelectTrigger
|
||||
aria-label={t('models.selectModel')}
|
||||
className={
|
||||
compactModelSelector
|
||||
? 'w-full min-w-0 gap-1 border-0 bg-transparent px-1 text-xs text-muted-foreground shadow-none hover:bg-muted data-[size=default]:h-7 [&_[data-slot=select-value]_svg]:hidden'
|
||||
: 'min-w-0 bg-[#ffffff] dark:bg-[#2a2a2e]'
|
||||
}
|
||||
>
|
||||
<SelectValue placeholder={t('models.selectModel')} />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
@@ -605,7 +614,7 @@ export default function DynamicFormItemComponent({
|
||||
type="button"
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="h-9 w-9 shrink-0"
|
||||
className={compactModelSelector ? 'hidden' : 'h-9 w-9 shrink-0'}
|
||||
onClick={() => {
|
||||
setSettingsSection('models');
|
||||
setModelsDialogOpen(true);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
const enUS = {
|
||||
assistant: {
|
||||
modelHint:
|
||||
'Assistant model · Space recommendation by default; changes apply to your next message',
|
||||
modelHint: 'Switch assistant model for your next message',
|
||||
details: 'View raw data',
|
||||
found: 'Found {{count}} items',
|
||||
completed: 'Completed',
|
||||
@@ -29,8 +28,8 @@ const enUS = {
|
||||
knowledge_bases: 'Find knowledge bases',
|
||||
knowledge_engines: 'Find knowledge engines',
|
||||
},
|
||||
title: 'Workspace assistant · Experimental',
|
||||
subtitle: 'Build with your Space model',
|
||||
title: 'Workspace assistant',
|
||||
subtitle: 'Build and manage your apps',
|
||||
newChat: 'New conversation',
|
||||
close: 'Close',
|
||||
welcome:
|
||||
@@ -43,7 +42,7 @@ const enUS = {
|
||||
decline: 'Decline',
|
||||
working: 'Working…',
|
||||
modelUnavailable:
|
||||
'The Space model is unavailable. Check your Space account and model access in Settings, then start a new conversation.',
|
||||
'Model unavailable. Check its configuration and access, then start a new conversation.',
|
||||
error:
|
||||
'This turn did not complete. Check the resource results before starting a new conversation; changes are not retried automatically.',
|
||||
running:
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
const jaJP = {
|
||||
assistant: {
|
||||
modelHint:
|
||||
'アシスタントモデル · 既定は Space 推奨。変更は次のメッセージから適用',
|
||||
modelHint: '次のメッセージからモデルを切り替え',
|
||||
details: '元のデータを見る',
|
||||
found: '{{count}} 件見つかりました',
|
||||
completed: '完了',
|
||||
@@ -29,8 +28,8 @@ const jaJP = {
|
||||
knowledge_bases: 'ナレッジベース検索',
|
||||
knowledge_engines: 'エンジン検索',
|
||||
},
|
||||
title: 'ワークスペースアシスタント · 実験版',
|
||||
subtitle: 'Space モデルでアプリを構築',
|
||||
title: 'ワークスペースアシスタント',
|
||||
subtitle: 'アプリを構築・管理',
|
||||
newChat: '新しい会話',
|
||||
close: '閉じる',
|
||||
welcome:
|
||||
@@ -43,7 +42,7 @@ const jaJP = {
|
||||
decline: '拒否',
|
||||
working: '処理中…',
|
||||
modelUnavailable:
|
||||
'Space モデルを利用できません。設定でログインとモデルの権限を確認して、新しい会話を開始してください。',
|
||||
'モデルを利用できません。設定と権限を確認して、新しい会話を開始してください。',
|
||||
error:
|
||||
'処理が完了しませんでした。新しい会話の前にリソースを確認してください。変更は自動で再試行されません。',
|
||||
running:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const zhHans = {
|
||||
assistant: {
|
||||
modelHint: '助手模型 · 默认使用 Space 推荐模型,切换从下一条消息生效',
|
||||
modelHint: '切换助手模型,从下一条消息生效',
|
||||
details: '查看原始数据',
|
||||
found: '找到 {{count}} 项',
|
||||
completed: '已完成',
|
||||
@@ -26,8 +26,8 @@ const zhHans = {
|
||||
knowledge_bases: '查询知识库',
|
||||
knowledge_engines: '查询知识引擎',
|
||||
},
|
||||
title: '工作区助手 · 实验版',
|
||||
subtitle: '使用 Space 模型构建应用',
|
||||
title: '工作区助手',
|
||||
subtitle: '构建和管理你的应用',
|
||||
newChat: '新对话',
|
||||
close: '关闭',
|
||||
welcome:
|
||||
@@ -40,7 +40,7 @@ const zhHans = {
|
||||
decline: '拒绝',
|
||||
working: '正在处理…',
|
||||
modelUnavailable:
|
||||
'Space 模型暂不可用。请在设置中检查 Space 登录和模型权限,然后开启新对话。',
|
||||
'模型暂不可用。请检查模型配置和访问权限,然后开启新对话。',
|
||||
error:
|
||||
'本轮未完成。请先检查资源和操作结果,再开启新对话;系统不会自动重试变更。',
|
||||
running:
|
||||
|
||||
Reference in New Issue
Block a user