feat: 模型库能力默认模型UI + 前台Auto默认模型 + AGNES直连修复 + 意图识别增强

This commit is contained in:
QihuAI Design committed 2026-07-14 05:47:57 +08:00
1 parent 2847289921
commit 945eeb8ba0
4 files changed
+121 -23

No files matched your search

+20 -5
View File
@@ -307,7 +307,7 @@ const ChatPage: React.FC = () => {
const { id } = useParams<{ id?: string }>();
const navigate = useNavigate();
const [searchQuery, setSearchQuery] = useState('');
const [selectedModelId, setSelectedModelId] = useState('');
const [selectedModelId, setSelectedModelId] = useState('auto');
const [chatModels, setChatModels] = useState<any[]>([]);
const [inputValue, setInputValue] = useState('');
const [sending, setSending] = useState(false);
@@ -339,7 +339,7 @@ const ChatPage: React.FC = () => {
const models = Array.isArray(data) ? data : (data?.items || []);
setChatModels(models);
if (models.length > 0 && !selectedModelId) {
setSelectedModelId(models[0].id);
setSelectedModelId('auto');
}
}).catch(() => {
setChatModels([]);
@@ -463,8 +463,12 @@ const ChatPage: React.FC = () => {
return [...pinned.filter(c => c.title.toLowerCase().includes(q)), ...unpinned.filter(c => c.title.toLowerCase().includes(q))];
}, [conversations, searchQuery]);
// Selected model info
const selectedModel = chatModels.find(m => m.id === selectedModelId) || chatModels[0] || { id: '', name: '选择模型', status: 'free', provider_name: '' };
// Selected model info(Auto 自动:按对话意图自动匹配后台各能力默认模型)
const isAutoModel = selectedModelId === 'auto';
const AUTO_MODEL = { id: 'auto', name: 'Auto 自动', status: 'free', provider_name: '按能力智能匹配', capabilities: [], price_per_million_tokens: 0 };
const selectedModel = isAutoModel
? AUTO_MODEL
: (chatModels.find(m => m.id === selectedModelId) || chatModels[0] || AUTO_MODEL);
// Scroll to bottom when messages change
useEffect(() => {
@@ -481,7 +485,7 @@ const ChatPage: React.FC = () => {
// Handle new conversation
const handleNewConversation = async () => {
try {
const res = await chatAPI.createConversation({ title: '新对话', model_id: selectedModelId });
const res = await chatAPI.createConversation({ title: '新对话', model_id: selectedModelId === 'auto' ? (chatModels[0]?.id || '') : selectedModelId });
const newConv = unwrapData(res);
const conv: Conversation = {
id: newConv.id,
@@ -792,6 +796,17 @@ const ChatPage: React.FC = () => {
</div>
}
>
<button
key="auto"
className={`dropdown-item ${selectedModelId === 'auto' ? 'selected' : ''}`}
onClick={() => setSelectedModelId('auto')}
>
<div className="model-dropdown-item">
<span>🤖 Auto 自动</span>
<span className="model-provider-tag">按能力智能匹配</span>
<span className="model-cap-badge">智能</span>
</div>
</button>
{chatModels.filter(m => m.is_enabled !== false).map(model => (
<button
key={model.id}