You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1234 lines
28 KiB
1234 lines
28 KiB
<script setup lang="ts">
|
|
import { marked } from 'marked'
|
|
|
|
interface ModelOption {
|
|
id: number
|
|
name: string
|
|
modelId: string
|
|
type: string
|
|
maxTokens: number | null
|
|
}
|
|
|
|
interface ProviderWithModels {
|
|
id: number
|
|
name: string
|
|
parseMode: string
|
|
status: string
|
|
models: ModelOption[]
|
|
}
|
|
|
|
const { $toast } = useNuxtApp()
|
|
|
|
const { data: modelsData, refresh: refreshModels } = await useHttpFetch('/api/llm/chat/models', {
|
|
getCachedData: () => undefined,
|
|
})
|
|
|
|
const { data: enabledToolsData, refresh: refreshTools } = await useHttpFetch('/api/llm/chat/tools', {
|
|
getCachedData: () => undefined,
|
|
})
|
|
|
|
interface EnabledTool {
|
|
slug: string
|
|
name: string
|
|
type: string
|
|
description: string
|
|
}
|
|
|
|
const enabledTools = computed<EnabledTool[]>(() => (enabledToolsData.value as any) ?? [])
|
|
|
|
onActivated(() => {
|
|
refreshModels()
|
|
refreshTools()
|
|
})
|
|
|
|
const providers = computed<ProviderWithModels[]>(() => (modelsData.value as any) ?? [])
|
|
|
|
const allModels = computed(() => {
|
|
const result: (ModelOption & { providerName: string; providerId: number })[] = []
|
|
for (const p of providers.value) {
|
|
for (const m of p.models) {
|
|
result.push({ ...m, providerName: p.name, providerId: p.id })
|
|
}
|
|
}
|
|
return result
|
|
})
|
|
|
|
const selectedModelId = ref<number | null>(null)
|
|
const systemPrompt = ref('')
|
|
const enableThinking = ref(false)
|
|
const enableTools = ref(false)
|
|
const chatContainer = ref<HTMLElement | null>(null)
|
|
|
|
const selectedModel = computed(() => {
|
|
if (!selectedModelId.value) return null
|
|
return allModels.value.find(m => m.id === selectedModelId.value) ?? null
|
|
})
|
|
|
|
const { messages, isLoading, errorMessage, sendMessage, stopGeneration, clearChat, respondToApproval } = useLlmChat({
|
|
modelId: () => selectedModelId.value,
|
|
systemPrompt: () => systemPrompt.value,
|
|
enableThinking: () => enableThinking.value,
|
|
enableTools: () => enableTools.value,
|
|
})
|
|
|
|
const inputMessage = ref('')
|
|
const collapsedReasoning = ref<Set<string>>(new Set())
|
|
|
|
marked.setOptions({ breaks: true, gfm: true })
|
|
|
|
function renderMarkdown(text: string): string {
|
|
if (!text) return ''
|
|
try {
|
|
return marked.parse(text, { async: false }) as string
|
|
} catch {
|
|
return text
|
|
}
|
|
}
|
|
|
|
function toggleReasoning(partId: string) {
|
|
if (collapsedReasoning.value.has(partId)) {
|
|
collapsedReasoning.value.delete(partId)
|
|
} else {
|
|
collapsedReasoning.value.add(partId)
|
|
}
|
|
collapsedReasoning.value = new Set(collapsedReasoning.value)
|
|
}
|
|
|
|
watch(messages, () => {
|
|
nextTick(() => {
|
|
if (chatContainer.value) {
|
|
chatContainer.value.scrollTop = chatContainer.value.scrollHeight
|
|
}
|
|
})
|
|
}, { deep: true })
|
|
|
|
watch(errorMessage, (val) => {
|
|
if (val) {
|
|
$toast.error(val)
|
|
}
|
|
})
|
|
|
|
async function handleSend() {
|
|
const text = inputMessage.value.trim()
|
|
if (!text || !selectedModelId.value || isLoading.value) return
|
|
inputMessage.value = ''
|
|
await sendMessage(text)
|
|
}
|
|
|
|
function handleKeydown(e: KeyboardEvent) {
|
|
if (e.key === 'Enter' && !e.shiftKey) {
|
|
e.preventDefault()
|
|
handleSend()
|
|
}
|
|
}
|
|
|
|
function modelTypeLabel(type: string) {
|
|
const map: Record<string, string> = { text: '文本', vision: '视觉', multimodal: '多模态' }
|
|
return map[type] ?? type
|
|
}
|
|
|
|
function modelTypeClass(type: string) {
|
|
const map: Record<string, string> = { text: 'type-text', vision: 'type-vision', multimodal: 'type-multimodal' }
|
|
return map[type] ?? 'type-text'
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<ClientOnly>
|
|
<div class="llm-test-page">
|
|
<header class="page-header">
|
|
<div class="header-left">
|
|
<h1 class="page-title">模型测试</h1>
|
|
<p class="page-desc">选择已配置的模型进行对话测试,验证模型连接和响应效果</p>
|
|
</div>
|
|
</header>
|
|
|
|
<div class="test-layout">
|
|
<div class="sidebar-panel">
|
|
<div class="panel-section">
|
|
<label class="panel-label">选择模型</label>
|
|
<select v-model="selectedModelId" class="model-select">
|
|
<option :value="null" disabled>请选择模型</option>
|
|
<optgroup v-for="p in providers" :key="p.id" :label="p.name">
|
|
<option v-for="m in p.models" :key="m.id" :value="m.id">
|
|
{{ m.name }} ({{ m.modelId }})
|
|
</option>
|
|
</optgroup>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="panel-section">
|
|
<label class="panel-label">系统提示词</label>
|
|
<textarea
|
|
v-model="systemPrompt"
|
|
class="system-prompt-input"
|
|
placeholder="设定模型的角色和行为..."
|
|
rows="3"
|
|
></textarea>
|
|
</div>
|
|
|
|
<div class="panel-section">
|
|
<label class="panel-label thinking-toggle">
|
|
<span>思考模式</span>
|
|
<button
|
|
:class="['toggle-switch', { active: enableThinking }]"
|
|
@click="enableThinking = !enableThinking"
|
|
>
|
|
<span class="toggle-knob"></span>
|
|
</button>
|
|
</label>
|
|
<p class="panel-hint">启用后,支持推理的模型会展示思考过程(仅对支持推理的模型有效,如 DeepSeek-R1、o1 等)</p>
|
|
</div>
|
|
|
|
<div class="panel-section">
|
|
<label class="panel-label thinking-toggle">
|
|
<span>工具调用</span>
|
|
<button
|
|
:class="['toggle-switch', { active: enableTools }]"
|
|
@click="enableTools = !enableTools"
|
|
>
|
|
<span class="toggle-knob"></span>
|
|
</button>
|
|
</label>
|
|
<p class="panel-hint">启用后,模型可调用已注册的 Agent 工具(如 fetch 网页抓取)来辅助回答</p>
|
|
<div v-if="enableTools && enabledTools.length > 0" class="enabled-tools-list">
|
|
<div v-for="t in enabledTools" :key="t.slug" class="enabled-tool-item">
|
|
<span :class="['tool-type-badge', `type-${t.type}`]">{{ t.type }}</span>
|
|
<span class="enabled-tool-name">{{ t.name }}</span>
|
|
</div>
|
|
</div>
|
|
<p v-else-if="enableTools && enabledTools.length === 0" class="panel-hint panel-hint-warn">
|
|
当前没有已启用的工具,请在 Agent 工具管理中启用至少一个工具
|
|
</p>
|
|
</div>
|
|
|
|
<div v-if="selectedModel" class="model-info-card">
|
|
<div class="model-info-header">
|
|
<span class="model-info-name">{{ selectedModel.name }}</span>
|
|
<span :class="['model-type-badge', modelTypeClass(selectedModel.type)]">{{ modelTypeLabel(selectedModel.type) }}</span>
|
|
</div>
|
|
<div class="model-info-meta">
|
|
<span class="meta-item">
|
|
<Icon name="lucide:cpu" />
|
|
{{ selectedModel.modelId }}
|
|
</span>
|
|
<span class="meta-item">
|
|
<Icon name="lucide:server" />
|
|
{{ selectedModel.providerName }}
|
|
</span>
|
|
<span v-if="selectedModel.maxTokens" class="meta-item">
|
|
<Icon name="lucide:arrow-up-right" />
|
|
{{ selectedModel.maxTokens.toLocaleString() }} tokens
|
|
</span>
|
|
</div>
|
|
</div>
|
|
|
|
<div v-if="allModels.length === 0" class="empty-hint">
|
|
暂无可用模型,请先在<a href="/settings/llm-config" class="link">模型配置</a>中添加
|
|
</div>
|
|
|
|
<div class="panel-section panel-actions">
|
|
<button class="btn-secondary" :disabled="messages.length === 0" @click="clearChat">
|
|
<Icon name="lucide:trash-2" />
|
|
清空对话
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="chat-panel">
|
|
<div v-if="!selectedModelId" class="chat-empty">
|
|
<div class="chat-empty-icon">
|
|
<Icon name="lucide:message-square-text" />
|
|
</div>
|
|
<p>选择一个模型开始对话测试</p>
|
|
</div>
|
|
|
|
<template v-else>
|
|
<div ref="chatContainer" class="chat-messages">
|
|
<div v-if="messages.length === 0" class="chat-welcome">
|
|
<div class="welcome-icon">
|
|
<Icon name="lucide:sparkles" />
|
|
</div>
|
|
<p class="welcome-text">开始与 {{ selectedModel?.name ?? '模型' }} 对话</p>
|
|
<p class="welcome-hint">输入消息测试模型连接和响应效果</p>
|
|
</div>
|
|
|
|
<template v-for="msg in messages" :key="msg.id">
|
|
<!-- User message: right-aligned bubble -->
|
|
<BoChatBubble
|
|
v-if="msg.role === 'user'"
|
|
role="user"
|
|
:content="msg.content"
|
|
/>
|
|
|
|
<!-- Assistant message: single panel with avatar + chain -->
|
|
<div v-else class="assistant-panel">
|
|
<div class="assistant-avatar">
|
|
<Icon name="lucide:bot" />
|
|
</div>
|
|
<div class="assistant-body">
|
|
<!-- Loading placeholder -->
|
|
<div v-if="isLoading && !msg.parts?.length" class="assistant-loading">
|
|
<span class="loading-dot" />
|
|
<span class="loading-dot" />
|
|
<span class="loading-dot" />
|
|
</div>
|
|
|
|
<template v-for="part in msg.parts" :key="part.id">
|
|
<!-- Reasoning part -->
|
|
<div v-if="part.type === 'reasoning'" class="reasoning-part">
|
|
<div class="reasoning-header" @click="toggleReasoning(part.id)">
|
|
<Icon name="lucide:brain" class="reasoning-icon" />
|
|
<span class="reasoning-title">思考</span>
|
|
<span v-if="part.reasoningLoading" class="reasoning-status">思考中...</span>
|
|
<Icon
|
|
:name="collapsedReasoning.has(part.id) ? 'lucide:chevron-right' : 'lucide:chevron-down'"
|
|
class="reasoning-toggle"
|
|
/>
|
|
</div>
|
|
<div v-show="!collapsedReasoning.has(part.id)" class="reasoning-content">
|
|
{{ part.text }}
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Tool call part -->
|
|
<div v-else-if="part.type === 'tool-call'" class="tool-call-item">
|
|
<div class="tool-call-header">
|
|
<Icon name="lucide:wrench" class="tool-icon" />
|
|
<span class="tool-name">{{ part.toolName }}</span>
|
|
<span :class="['tool-state', part.state]">
|
|
<template v-if="part.state === 'call'">调用中...</template>
|
|
<template v-else-if="part.state === 'approval-requested'">
|
|
{{ part.isAutomaticApproval ? '自动批准中...' : '等待审批' }}
|
|
</template>
|
|
<template v-else-if="part.state === 'approval-responded'">
|
|
{{ part.approved ? '已批准' : '已拒绝' }}
|
|
</template>
|
|
<template v-else>完成</template>
|
|
</span>
|
|
</div>
|
|
<div v-if="part.args" class="tool-args">
|
|
<span class="tool-label">参数:</span>
|
|
<code>{{ JSON.stringify(part.args) }}</code>
|
|
</div>
|
|
|
|
<!-- Approval request UI (only for manual approvals) -->
|
|
<div v-if="part.state === 'approval-requested' && !part.isAutomaticApproval" class="tool-approval-actions">
|
|
<button
|
|
class="btn-approve"
|
|
:disabled="isLoading"
|
|
@click="respondToApproval(part.toolCallId, true)"
|
|
>
|
|
<Icon name="lucide:check" />
|
|
批准执行
|
|
</button>
|
|
<button
|
|
class="btn-deny"
|
|
:disabled="isLoading"
|
|
@click="respondToApproval(part.toolCallId, false)"
|
|
>
|
|
<Icon name="lucide:x" />
|
|
拒绝
|
|
</button>
|
|
</div>
|
|
|
|
<!-- Approval responded info -->
|
|
<div v-if="part.state === 'approval-responded' && part.approvalReason" class="tool-approval-reason">
|
|
<span class="tool-label">拒绝原因:</span>
|
|
<span>{{ part.approvalReason }}</span>
|
|
</div>
|
|
|
|
<div v-if="part.result !== undefined" class="tool-result">
|
|
<span class="tool-label">结果:</span>
|
|
<pre>{{ typeof part.result === 'string' ? part.result.slice(0, 500) : JSON.stringify(part.result, null, 2)?.slice(0, 500) }}</pre>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Text part -->
|
|
<div v-else-if="part.type === 'text'" class="assistant-text markdown-body" v-html="renderMarkdown(part.text || '')">
|
|
</div>
|
|
</template>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</div>
|
|
|
|
<div v-if="errorMessage" class="chat-error">
|
|
<Icon name="lucide:alert-circle" />
|
|
{{ errorMessage }}
|
|
</div>
|
|
|
|
<div class="chat-input-area">
|
|
<div class="input-wrapper">
|
|
<textarea
|
|
v-model="inputMessage"
|
|
class="chat-input"
|
|
placeholder="输入消息... (Enter 发送, Shift+Enter 换行)"
|
|
rows="1"
|
|
:disabled="isLoading"
|
|
@keydown="handleKeydown"
|
|
></textarea>
|
|
<div class="input-actions">
|
|
<button
|
|
v-if="isLoading"
|
|
class="btn-stop"
|
|
@click="stopGeneration"
|
|
>
|
|
<Icon name="lucide:square" />
|
|
停止
|
|
</button>
|
|
<button
|
|
v-else
|
|
class="btn-send"
|
|
:disabled="!inputMessage.trim() || !selectedModelId"
|
|
@click="handleSend"
|
|
>
|
|
<Icon name="lucide:send" />
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</ClientOnly>
|
|
</template>
|
|
|
|
<style scoped>
|
|
.llm-test-page {
|
|
padding: 40px;
|
|
height: 100%;
|
|
display: flex;
|
|
flex-direction: column;
|
|
}
|
|
|
|
.page-header {
|
|
margin-bottom: 24px;
|
|
}
|
|
|
|
.page-title {
|
|
font-family: var(--font-display);
|
|
font-size: 32px;
|
|
font-weight: 400;
|
|
color: var(--color-ink);
|
|
letter-spacing: -0.3px;
|
|
margin: 0 0 8px 0;
|
|
}
|
|
|
|
.page-desc {
|
|
font-size: 14px;
|
|
color: var(--color-muted);
|
|
margin: 0;
|
|
}
|
|
|
|
.test-layout {
|
|
display: flex;
|
|
gap: 20px;
|
|
flex: 1;
|
|
min-height: 0;
|
|
max-height: calc(100vh - 200px);
|
|
}
|
|
|
|
.sidebar-panel {
|
|
width: 280px;
|
|
flex-shrink: 0;
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 16px;
|
|
}
|
|
|
|
.panel-section {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 8px;
|
|
}
|
|
|
|
.panel-label {
|
|
font-size: 13px;
|
|
font-weight: 500;
|
|
color: var(--color-body-strong);
|
|
}
|
|
|
|
.model-select {
|
|
width: 100%;
|
|
padding: 10px 14px;
|
|
background: var(--color-surface-card);
|
|
border: 1px solid var(--color-hairline);
|
|
border-radius: 8px;
|
|
font-size: 14px;
|
|
color: var(--color-ink);
|
|
cursor: pointer;
|
|
transition: all 0.15s ease;
|
|
}
|
|
|
|
.model-select:focus {
|
|
outline: none;
|
|
border-color: var(--color-primary);
|
|
box-shadow: 0 0 0 3px rgba(204, 120, 92, 0.15);
|
|
}
|
|
|
|
.system-prompt-input {
|
|
width: 100%;
|
|
padding: 10px 14px;
|
|
background: var(--color-surface-card);
|
|
border: 1px solid var(--color-hairline);
|
|
border-radius: 8px;
|
|
font-size: 13px;
|
|
color: var(--color-ink);
|
|
resize: vertical;
|
|
line-height: 1.5;
|
|
font-family: inherit;
|
|
min-height: 60px;
|
|
}
|
|
|
|
.system-prompt-input:focus {
|
|
outline: none;
|
|
border-color: var(--color-primary);
|
|
box-shadow: 0 0 0 3px rgba(204, 120, 92, 0.15);
|
|
}
|
|
|
|
.system-prompt-input::placeholder {
|
|
color: var(--color-muted);
|
|
}
|
|
|
|
.thinking-toggle {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
}
|
|
|
|
.toggle-switch {
|
|
position: relative;
|
|
width: 36px;
|
|
height: 20px;
|
|
background: var(--color-hairline);
|
|
border: none;
|
|
border-radius: 10px;
|
|
cursor: pointer;
|
|
transition: background 0.2s ease;
|
|
padding: 0;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.toggle-switch.active {
|
|
background: var(--color-primary);
|
|
}
|
|
|
|
.toggle-knob {
|
|
position: absolute;
|
|
top: 2px;
|
|
left: 2px;
|
|
width: 16px;
|
|
height: 16px;
|
|
background: #fff;
|
|
border-radius: 50%;
|
|
transition: transform 0.2s ease;
|
|
}
|
|
|
|
.toggle-switch.active .toggle-knob {
|
|
transform: translateX(16px);
|
|
}
|
|
|
|
.panel-hint {
|
|
font-size: 12px;
|
|
color: var(--color-muted);
|
|
margin: 0;
|
|
line-height: 1.4;
|
|
}
|
|
|
|
.model-info-card {
|
|
background: var(--color-surface-card);
|
|
border-radius: 10px;
|
|
padding: 14px 16px;
|
|
}
|
|
|
|
.model-info-header {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
margin-bottom: 8px;
|
|
}
|
|
|
|
.model-info-name {
|
|
font-size: 14px;
|
|
font-weight: 500;
|
|
color: var(--color-ink);
|
|
}
|
|
|
|
.model-type-badge {
|
|
display: inline-block;
|
|
padding: 2px 8px;
|
|
border-radius: 9999px;
|
|
font-size: 11px;
|
|
font-weight: 500;
|
|
}
|
|
|
|
.type-text {
|
|
background: rgba(93, 184, 166, 0.15);
|
|
color: var(--color-accent-teal);
|
|
}
|
|
|
|
.type-vision {
|
|
background: rgba(232, 165, 90, 0.15);
|
|
color: var(--color-accent-amber);
|
|
}
|
|
|
|
.type-multimodal {
|
|
background: rgba(204, 120, 92, 0.15);
|
|
color: var(--color-primary);
|
|
}
|
|
|
|
.model-info-meta {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 4px;
|
|
}
|
|
|
|
.meta-item {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
gap: 4px;
|
|
font-size: 12px;
|
|
color: var(--color-muted);
|
|
}
|
|
|
|
.meta-item :deep(svg) {
|
|
width: 13px;
|
|
height: 13px;
|
|
}
|
|
|
|
.empty-hint {
|
|
font-size: 13px;
|
|
color: var(--color-muted);
|
|
line-height: 1.5;
|
|
}
|
|
|
|
.link {
|
|
color: var(--color-primary);
|
|
text-decoration: none;
|
|
}
|
|
|
|
.link:hover {
|
|
text-decoration: underline;
|
|
}
|
|
|
|
.panel-actions {
|
|
margin-top: auto;
|
|
}
|
|
|
|
.btn-secondary {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
gap: 6px;
|
|
padding: 8px 14px;
|
|
font-size: 13px;
|
|
font-weight: 500;
|
|
color: var(--color-body-strong);
|
|
background: var(--color-surface-soft);
|
|
border: 1px solid var(--color-hairline);
|
|
border-radius: 8px;
|
|
cursor: pointer;
|
|
transition: all 0.15s ease;
|
|
width: 100%;
|
|
justify-content: center;
|
|
}
|
|
|
|
.btn-secondary:hover:not(:disabled) {
|
|
background: var(--color-hairline);
|
|
}
|
|
|
|
.btn-secondary:disabled {
|
|
opacity: 0.4;
|
|
cursor: not-allowed;
|
|
}
|
|
|
|
.btn-secondary :deep(svg) {
|
|
width: 14px;
|
|
height: 14px;
|
|
}
|
|
|
|
.chat-panel {
|
|
flex: 1;
|
|
display: flex;
|
|
flex-direction: column;
|
|
background: var(--color-surface-card);
|
|
border-radius: 12px;
|
|
overflow: hidden;
|
|
min-width: 0;
|
|
}
|
|
|
|
.chat-empty {
|
|
flex: 1;
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
justify-content: center;
|
|
gap: 12px;
|
|
color: var(--color-muted);
|
|
}
|
|
|
|
.chat-empty-icon :deep(svg) {
|
|
width: 48px;
|
|
height: 48px;
|
|
opacity: 0.3;
|
|
}
|
|
|
|
.chat-empty p {
|
|
font-size: 14px;
|
|
margin: 0;
|
|
}
|
|
|
|
.chat-messages {
|
|
flex: 1;
|
|
overflow-y: auto;
|
|
padding: 20px;
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 16px;
|
|
}
|
|
|
|
.chat-welcome {
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
justify-content: center;
|
|
flex: 1;
|
|
gap: 8px;
|
|
}
|
|
|
|
.welcome-icon :deep(svg) {
|
|
width: 40px;
|
|
height: 40px;
|
|
color: var(--color-primary);
|
|
opacity: 0.6;
|
|
}
|
|
|
|
.welcome-text {
|
|
font-size: 16px;
|
|
font-weight: 500;
|
|
color: var(--color-ink);
|
|
margin: 0;
|
|
}
|
|
|
|
.welcome-hint {
|
|
font-size: 13px;
|
|
color: var(--color-muted);
|
|
margin: 0;
|
|
}
|
|
|
|
.chat-error {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 6px;
|
|
padding: 8px 16px;
|
|
background: rgba(198, 69, 69, 0.1);
|
|
color: var(--color-error);
|
|
font-size: 13px;
|
|
}
|
|
|
|
.chat-error :deep(svg) {
|
|
width: 14px;
|
|
height: 14px;
|
|
}
|
|
|
|
.chat-input-area {
|
|
padding: 16px 20px;
|
|
border-top: 1px solid var(--color-hairline);
|
|
background: var(--color-canvas);
|
|
}
|
|
|
|
.input-wrapper {
|
|
display: flex;
|
|
align-items: flex-end;
|
|
gap: 8px;
|
|
background: var(--color-surface-card);
|
|
border: 1px solid var(--color-hairline);
|
|
border-radius: 10px;
|
|
padding: 8px 12px;
|
|
transition: all 0.15s ease;
|
|
}
|
|
|
|
.input-wrapper:focus-within {
|
|
border-color: var(--color-primary);
|
|
box-shadow: 0 0 0 3px rgba(204, 120, 92, 0.15);
|
|
}
|
|
|
|
.chat-input {
|
|
flex: 1;
|
|
border: none;
|
|
background: transparent;
|
|
font-size: 14px;
|
|
color: var(--color-ink);
|
|
resize: none;
|
|
outline: none;
|
|
min-height: 24px;
|
|
max-height: 120px;
|
|
line-height: 1.5;
|
|
font-family: inherit;
|
|
}
|
|
|
|
.chat-input::placeholder {
|
|
color: var(--color-muted);
|
|
}
|
|
|
|
.chat-input:disabled {
|
|
opacity: 0.5;
|
|
}
|
|
|
|
.input-actions {
|
|
display: flex;
|
|
align-items: center;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.btn-send {
|
|
width: 32px;
|
|
height: 32px;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
background: var(--color-primary);
|
|
color: var(--color-on-primary);
|
|
border: none;
|
|
border-radius: 8px;
|
|
cursor: pointer;
|
|
transition: background 0.15s ease;
|
|
}
|
|
|
|
.btn-send:hover:not(:disabled) {
|
|
background: var(--color-primary-active);
|
|
}
|
|
|
|
.btn-send:disabled {
|
|
opacity: 0.4;
|
|
cursor: not-allowed;
|
|
}
|
|
|
|
.btn-send :deep(svg) {
|
|
width: 16px;
|
|
height: 16px;
|
|
}
|
|
|
|
.btn-stop {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
gap: 4px;
|
|
padding: 6px 12px;
|
|
font-size: 12px;
|
|
font-weight: 500;
|
|
color: var(--color-error);
|
|
background: rgba(198, 69, 69, 0.1);
|
|
border: 1px solid rgba(198, 69, 69, 0.2);
|
|
border-radius: 6px;
|
|
cursor: pointer;
|
|
transition: all 0.15s ease;
|
|
}
|
|
|
|
.btn-stop:hover {
|
|
background: rgba(198, 69, 69, 0.2);
|
|
}
|
|
|
|
.btn-stop :deep(svg) {
|
|
width: 12px;
|
|
height: 12px;
|
|
}
|
|
|
|
.assistant-panel {
|
|
display: flex;
|
|
gap: 12px;
|
|
align-items: flex-start;
|
|
}
|
|
|
|
.assistant-avatar {
|
|
flex-shrink: 0;
|
|
width: 32px;
|
|
height: 32px;
|
|
border-radius: 8px;
|
|
background: var(--color-primary);
|
|
color: #fff;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
}
|
|
|
|
.assistant-avatar :deep(svg) {
|
|
width: 18px;
|
|
height: 18px;
|
|
}
|
|
|
|
.assistant-body {
|
|
flex: 1;
|
|
min-width: 0;
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 8px;
|
|
}
|
|
|
|
.assistant-text {
|
|
background: var(--color-surface-card);
|
|
border: 1px solid var(--color-hairline);
|
|
border-radius: 12px;
|
|
padding: 12px 16px;
|
|
color: var(--color-ink);
|
|
font-size: 14px;
|
|
line-height: 1.7;
|
|
word-break: break-word;
|
|
}
|
|
|
|
.assistant-text :deep(p) {
|
|
margin: 0 0 8px;
|
|
}
|
|
|
|
.assistant-text :deep(p:last-child) {
|
|
margin-bottom: 0;
|
|
}
|
|
|
|
.assistant-text :deep(pre) {
|
|
background: var(--color-surface-2, #f6f8fa);
|
|
border-radius: 8px;
|
|
padding: 12px;
|
|
overflow-x: auto;
|
|
margin: 8px 0;
|
|
}
|
|
|
|
.assistant-text :deep(code) {
|
|
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
|
|
font-size: 13px;
|
|
}
|
|
|
|
.assistant-text :deep(pre code) {
|
|
background: none;
|
|
padding: 0;
|
|
}
|
|
|
|
.assistant-text :deep(:not(pre) > code) {
|
|
background: var(--color-surface-2, #f6f8fa);
|
|
padding: 2px 6px;
|
|
border-radius: 4px;
|
|
}
|
|
|
|
.assistant-text :deep(ul),
|
|
.assistant-text :deep(ol) {
|
|
margin: 8px 0;
|
|
padding-left: 24px;
|
|
}
|
|
|
|
.assistant-text :deep(li) {
|
|
margin: 4px 0;
|
|
}
|
|
|
|
.assistant-text :deep(blockquote) {
|
|
border-left: 3px solid var(--color-hairline);
|
|
margin: 8px 0;
|
|
padding: 4px 12px;
|
|
color: var(--color-ink-soft, #666);
|
|
}
|
|
|
|
.assistant-text :deep(h1),
|
|
.assistant-text :deep(h2),
|
|
.assistant-text :deep(h3),
|
|
.assistant-text :deep(h4) {
|
|
margin: 12px 0 8px;
|
|
font-weight: 600;
|
|
}
|
|
|
|
.assistant-text :deep(a) {
|
|
color: var(--color-primary, #0969da);
|
|
text-decoration: none;
|
|
}
|
|
|
|
.assistant-text :deep(table) {
|
|
border-collapse: collapse;
|
|
margin: 8px 0;
|
|
width: 100%;
|
|
}
|
|
|
|
.assistant-text :deep(th),
|
|
.assistant-text :deep(td) {
|
|
border: 1px solid var(--color-hairline);
|
|
padding: 6px 12px;
|
|
text-align: left;
|
|
}
|
|
|
|
.assistant-loading {
|
|
display: flex;
|
|
gap: 4px;
|
|
padding: 12px 16px;
|
|
}
|
|
|
|
.loading-dot {
|
|
width: 6px;
|
|
height: 6px;
|
|
border-radius: 50%;
|
|
background: var(--color-muted);
|
|
animation: bounce-dot 1.4s infinite ease-in-out both;
|
|
}
|
|
|
|
.loading-dot:nth-child(1) { animation-delay: -0.32s; }
|
|
.loading-dot:nth-child(2) { animation-delay: -0.16s; }
|
|
|
|
@keyframes bounce-dot {
|
|
0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
|
|
40% { transform: scale(1); opacity: 1; }
|
|
}
|
|
|
|
.reasoning-part {
|
|
background: var(--color-surface-soft);
|
|
border: 1px solid var(--color-hairline);
|
|
border-radius: 8px;
|
|
padding: 10px 14px;
|
|
font-size: 13px;
|
|
}
|
|
|
|
.reasoning-header {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 6px;
|
|
cursor: pointer;
|
|
user-select: none;
|
|
}
|
|
|
|
.reasoning-icon :deep(svg) {
|
|
width: 14px;
|
|
height: 14px;
|
|
color: var(--color-primary);
|
|
}
|
|
|
|
.reasoning-title {
|
|
font-weight: 500;
|
|
color: var(--color-ink);
|
|
font-size: 12px;
|
|
}
|
|
|
|
.reasoning-status {
|
|
font-size: 11px;
|
|
color: var(--color-muted);
|
|
}
|
|
|
|
.reasoning-toggle :deep(svg) {
|
|
width: 14px;
|
|
height: 14px;
|
|
color: var(--color-muted);
|
|
margin-left: auto;
|
|
}
|
|
|
|
.reasoning-content {
|
|
margin-top: 8px;
|
|
padding-top: 8px;
|
|
border-top: 1px solid var(--color-hairline);
|
|
color: var(--color-muted);
|
|
font-size: 12px;
|
|
line-height: 1.6;
|
|
white-space: pre-wrap;
|
|
max-height: 300px;
|
|
overflow-y: auto;
|
|
}
|
|
|
|
.tool-call-item {
|
|
background: var(--color-surface-soft);
|
|
border: 1px solid var(--color-hairline);
|
|
border-radius: 8px;
|
|
padding: 10px 14px;
|
|
font-size: 12px;
|
|
}
|
|
|
|
.tool-call-header {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 6px;
|
|
margin-bottom: 6px;
|
|
}
|
|
|
|
.tool-icon :deep(svg) {
|
|
width: 14px;
|
|
height: 14px;
|
|
color: var(--color-primary);
|
|
}
|
|
|
|
.tool-name {
|
|
font-weight: 500;
|
|
color: var(--color-ink);
|
|
}
|
|
|
|
.tool-state {
|
|
margin-left: auto;
|
|
font-size: 11px;
|
|
padding: 2px 8px;
|
|
border-radius: 9999px;
|
|
}
|
|
|
|
.tool-state.call {
|
|
background: rgba(232, 165, 90, 0.15);
|
|
color: var(--color-accent-amber);
|
|
}
|
|
|
|
.tool-state.result {
|
|
background: rgba(93, 184, 166, 0.15);
|
|
color: var(--color-accent-teal);
|
|
}
|
|
|
|
.tool-state.approval-requested {
|
|
background: rgba(232, 165, 90, 0.15);
|
|
color: #b06000;
|
|
}
|
|
|
|
.tool-state.approval-responded {
|
|
background: rgba(93, 184, 166, 0.15);
|
|
color: var(--color-accent-teal);
|
|
}
|
|
|
|
.tool-approval-actions {
|
|
display: flex;
|
|
gap: 8px;
|
|
margin-top: 8px;
|
|
}
|
|
|
|
.btn-approve,
|
|
.btn-deny {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 4px;
|
|
padding: 6px 14px;
|
|
font-size: 12px;
|
|
font-weight: 500;
|
|
border: none;
|
|
border-radius: 6px;
|
|
cursor: pointer;
|
|
transition: all 0.15s ease;
|
|
}
|
|
|
|
.btn-approve {
|
|
background: rgba(93, 184, 166, 0.15);
|
|
color: var(--color-accent-teal);
|
|
}
|
|
|
|
.btn-approve:hover:not(:disabled) {
|
|
background: rgba(93, 184, 166, 0.25);
|
|
}
|
|
|
|
.btn-deny {
|
|
background: rgba(198, 69, 69, 0.1);
|
|
color: var(--color-error);
|
|
}
|
|
|
|
.btn-deny:hover:not(:disabled) {
|
|
background: rgba(198, 69, 69, 0.2);
|
|
}
|
|
|
|
.btn-approve:disabled,
|
|
.btn-deny:disabled {
|
|
opacity: 0.5;
|
|
cursor: not-allowed;
|
|
}
|
|
|
|
.btn-approve :deep(svg),
|
|
.btn-deny :deep(svg) {
|
|
width: 14px;
|
|
height: 14px;
|
|
}
|
|
|
|
.tool-approval-reason {
|
|
margin-top: 6px;
|
|
font-size: 11px;
|
|
color: var(--color-error);
|
|
}
|
|
|
|
.tool-args,
|
|
.tool-result {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 4px;
|
|
}
|
|
|
|
.tool-label {
|
|
font-size: 11px;
|
|
color: var(--color-muted);
|
|
}
|
|
|
|
.tool-args code {
|
|
font-family: var(--font-mono, monospace);
|
|
font-size: 11px;
|
|
color: var(--color-body-strong);
|
|
background: var(--color-surface-card);
|
|
padding: 4px 8px;
|
|
border-radius: 4px;
|
|
word-break: break-all;
|
|
}
|
|
|
|
.tool-result pre {
|
|
font-family: var(--font-mono, monospace);
|
|
font-size: 11px;
|
|
color: var(--color-body-strong);
|
|
background: var(--color-surface-card);
|
|
padding: 8px;
|
|
border-radius: 4px;
|
|
margin: 0;
|
|
white-space: pre-wrap;
|
|
word-break: break-all;
|
|
max-height: 200px;
|
|
overflow-y: auto;
|
|
}
|
|
|
|
@media (max-width: 768px) {
|
|
.llm-test-page {
|
|
padding: 24px;
|
|
}
|
|
|
|
.test-layout {
|
|
flex-direction: column;
|
|
max-height: none;
|
|
}
|
|
|
|
.sidebar-panel {
|
|
width: 100%;
|
|
}
|
|
|
|
.chat-panel {
|
|
min-height: 500px;
|
|
}
|
|
}
|
|
|
|
.enabled-tools-list {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 6px;
|
|
margin-top: 8px;
|
|
}
|
|
|
|
.enabled-tool-item {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
padding: 4px 8px;
|
|
background: var(--color-surface-card);
|
|
border-radius: 6px;
|
|
font-size: 12px;
|
|
}
|
|
|
|
.enabled-tool-name {
|
|
color: var(--color-text);
|
|
font-weight: 500;
|
|
}
|
|
|
|
.tool-type-badge {
|
|
display: inline-block;
|
|
padding: 2px 8px;
|
|
border-radius: 4px;
|
|
font-size: 11px;
|
|
font-weight: 600;
|
|
white-space: nowrap;
|
|
}
|
|
|
|
.type-fetch { background: #e8f0fe; color: #1a56db; }
|
|
.type-calculator { background: #f3e8ff; color: #7c3aed; }
|
|
.type-datetime { background: #fef3c7; color: #b45309; }
|
|
.type-uuid { background: #d1fae5; color: #059669; }
|
|
.type-base64 { background: #ffe4e6; color: #e11d48; }
|
|
.type-json-formatter { background: #e0f2fe; color: #0369a1; }
|
|
.type-regex-tester { background: #fce7f3; color: #be185d; }
|
|
|
|
.panel-hint-warn {
|
|
color: #e11d48;
|
|
}
|
|
</style>
|
|
|