diff --git a/src/api.ts b/src/api.ts index dc4bf75..25a81d3 100644 --- a/src/api.ts +++ b/src/api.ts @@ -111,6 +111,17 @@ export interface ChatHistoryResp { branches: Record; } +export interface AiModel { + model_name: string; + icon: string; + model_ratio: number; + completion_ratio: number; +} + +export const ModelAPI = { + list: () => api.get<{ data: AiModel[] }>('/models').then((r) => r.data.data), +}; + export const AgentAPI = { list: () => api.get('/agents').then((r) => r.data), detail: (id: string) => api.get(`/agents/${id}`).then((r) => r.data), diff --git a/src/pages/AgentEditor.tsx b/src/pages/AgentEditor.tsx index 4dd8630..0216265 100644 --- a/src/pages/AgentEditor.tsx +++ b/src/pages/AgentEditor.tsx @@ -2,7 +2,7 @@ import { useEffect, useRef, useState } from 'react'; import { Button, Form, Input, InputNumber, Modal, Upload, App as AntApp, List, Popconfirm, Tag, Switch, Select, Collapse } from 'antd'; import type { UploadFile } from 'antd/es/upload/interface'; import { useNavigate, useParams } from 'react-router-dom'; -import { Agent, AgentAPI, ImageAPI, KnowledgeStatus, SkillType, Team, TeamAPI } from '../api'; +import { Agent, AgentAPI, ImageAPI, KnowledgeStatus, SkillType, Team, TeamAPI, AiModel, ModelAPI } from '../api'; import SkillEditor from '../components/SkillEditor'; import McpPanel from '../components/McpPanel'; import ChatPreview from '../components/ChatPreview'; @@ -37,6 +37,7 @@ export default function AgentEditor() { const [agent, setAgent] = useState(null); const [saving, setSaving] = useState(false); const [teams, setTeams] = useState([]); + const [models, setModels] = useState([]); const [autoSaveStatus, setAutoSaveStatus] = useState<'saved' | 'saving' | 'error'>('saved'); const [initModalOpen, setInitModalOpen] = useState(isNew); const [selectedAvatar, setSelectedAvatar] = useState(DEFAULT_AVATAR); @@ -74,6 +75,9 @@ export default function AgentEditor() { TeamAPI.list() .then(setTeams) .catch(() => setTeams([])); + ModelAPI.list() + .then(setModels) + .catch(() => setModels([])); if (isNew) { setInitModalOpen(true); setSelectedAvatar(DEFAULT_AVATAR); @@ -475,9 +479,29 @@ export default function AgentEditor() { label="模型" className="mb-0" > - { + const inputPrice = 2 * m.model_ratio; + const outputPrice = inputPrice * m.completion_ratio; + return { + value: m.model_name, + label: ( +
+
+ {m.model_name} + {m.model_name} +
+
+ 输入: ${inputPrice.toFixed(2)}/M + 输出: ${outputPrice.toFixed(2)}/M +
+
+ ), + }; + })} />