@@ -7,8 +7,6 @@ import { useUserStore } from '@/stores/user'
77 * 权限要求: 任何已登录用户(普通用户、管理员、超级管理员)
88 */
99
10-
11-
1210// =============================================================================
1311// === 智能体聊天分组 ===
1412// =============================================================================
@@ -21,11 +19,11 @@ export const agentApi = {
2119 * @returns {Promise } - 聊天响应流
2220 */
2321 sendAgentMessage : ( agentId , data , options = { } ) => {
24- const { signal, headers : extraHeaders , ...restOptions } = options || { } ;
22+ const { signal, headers : extraHeaders , ...restOptions } = options || { }
2523 const baseHeaders = {
2624 'Content-Type' : 'application/json' ,
2725 ...useUserStore ( ) . getAuthHeaders ( )
28- } ;
26+ }
2927
3028 return fetch ( `/api/chat/agent/${ agentId } ` , {
3129 method : 'POST' ,
@@ -71,15 +69,17 @@ export const agentApi = {
7169 * @param {string } threadId - 会话ID
7270 * @returns {Promise } - 历史消息
7371 */
74- getAgentHistory : ( agentId , threadId ) => apiGet ( `/api/chat/agent/${ agentId } /history?thread_id=${ threadId } ` ) ,
72+ getAgentHistory : ( agentId , threadId ) =>
73+ apiGet ( `/api/chat/agent/${ agentId } /history?thread_id=${ threadId } ` ) ,
7574
7675 /**
7776 * 获取指定会话的 AgentState
7877 * @param {string } agentId - 智能体ID
7978 * @param {string } threadId - 会话ID
8079 * @returns {Promise } - AgentState
8180 */
82- getAgentState : ( agentId , threadId ) => apiGet ( `/api/chat/agent/${ agentId } /state?thread_id=${ threadId } ` ) ,
81+ getAgentState : ( agentId , threadId ) =>
82+ apiGet ( `/api/chat/agent/${ agentId } /state?thread_id=${ threadId } ` ) ,
8383
8484 /**
8585 * Submit feedback for a message
@@ -111,7 +111,8 @@ export const agentApi = {
111111 * @param {Array } models - 选中的模型列表
112112 * @returns {Promise } - 更新结果
113113 */
114- updateProviderModels : ( provider , models ) => apiPost ( `/api/chat/models/update?model_provider=${ provider } ` , models ) ,
114+ updateProviderModels : ( provider , models ) =>
115+ apiPost ( `/api/chat/models/update?model_provider=${ provider } ` , models ) ,
115116
116117 /**
117118 * 获取智能体配置
@@ -130,8 +131,8 @@ export const agentApi = {
130131 * @returns {Promise } - 保存结果
131132 */
132133 saveAgentConfig : async ( agentName , config , options = { } ) => {
133- const queryParams = new URLSearchParams ( options ) . toString ( ) ;
134- const url = `/api/chat/agent/${ agentName } /config` + ( queryParams ? `?${ queryParams } ` : '' ) ;
134+ const queryParams = new URLSearchParams ( options ) . toString ( )
135+ const url = `/api/chat/agent/${ agentName } /config` + ( queryParams ? `?${ queryParams } ` : '' )
135136 return apiAdminPost ( url , config )
136137 } ,
137138
@@ -152,11 +153,11 @@ export const agentApi = {
152153 * @returns {Promise } - 恢复响应流
153154 */
154155 resumeAgentChat : ( agentId , data , options = { } ) => {
155- const { signal, headers : extraHeaders , ...restOptions } = options || { } ;
156+ const { signal, headers : extraHeaders , ...restOptions } = options || { }
156157 const baseHeaders = {
157158 'Content-Type' : 'application/json' ,
158159 ...useUserStore ( ) . getAuthHeaders ( )
159- } ;
160+ }
160161
161162 return fetch ( `/api/chat/agent/${ agentId } /resume` , {
162163 method : 'POST' ,
@@ -171,7 +172,6 @@ export const agentApi = {
171172 }
172173}
173174
174-
175175// =============================================================================
176176// === 多模态图片支持分组 ===
177177// =============================================================================
@@ -183,16 +183,19 @@ export const multimodalApi = {
183183 * @returns {Promise } - 上传结果
184184 */
185185 uploadImage : ( file ) => {
186- const formData = new FormData ( ) ;
187- formData . append ( 'file' , file ) ;
188-
189- return apiRequest ( '/api/chat/image/upload' , {
190- method : 'POST' ,
191- body : formData ,
192- } , true ) ;
193- } ,
186+ const formData = new FormData ( )
187+ formData . append ( 'file' , file )
194188
195- } ;
189+ return apiRequest (
190+ '/api/chat/image/upload' ,
191+ {
192+ method : 'POST' ,
193+ body : formData
194+ } ,
195+ true
196+ )
197+ }
198+ }
196199
197200// =============================================================================
198201// === 对话线程分组 ===
@@ -205,8 +208,8 @@ export const threadApi = {
205208 * @returns {Promise } - 对话线程列表
206209 */
207210 getThreads : ( agentId ) => {
208- const url = `/api/chat/threads?agent_id=${ agentId } ` ;
209- return apiGet ( url ) ;
211+ const url = `/api/chat/threads?agent_id=${ agentId } `
212+ return apiGet ( url )
210213 } ,
211214
212215 /**
@@ -216,11 +219,12 @@ export const threadApi = {
216219 * @param {Object } metadata - 元数据
217220 * @returns {Promise } - 创建结果
218221 */
219- createThread : ( agentId , title , metadata ) => apiPost ( '/api/chat/thread' , {
220- agent_id : agentId ,
221- title : title || '新的对话' ,
222- metadata : metadata || { }
223- } ) ,
222+ createThread : ( agentId , title , metadata ) =>
223+ apiPost ( '/api/chat/thread' , {
224+ agent_id : agentId ,
225+ title : title || '新的对话' ,
226+ metadata : metadata || { }
227+ } ) ,
224228
225229 /**
226230 * 更新对话线程
@@ -229,10 +233,11 @@ export const threadApi = {
229233 * @param {string } description - 对话描述
230234 * @returns {Promise } - 更新结果
231235 */
232- updateThread : ( threadId , title , description ) => apiPut ( `/api/chat/thread/${ threadId } ` , {
233- title,
234- description
235- } ) ,
236+ updateThread : ( threadId , title , description ) =>
237+ apiPut ( `/api/chat/thread/${ threadId } ` , {
238+ title,
239+ description
240+ } ) ,
236241
237242 /**
238243 * 删除对话线程
@@ -269,5 +274,6 @@ export const threadApi = {
269274 * @param {string } fileId
270275 * @returns {Promise }
271276 */
272- deleteThreadAttachment : ( threadId , fileId ) => apiDelete ( `/api/chat/thread/${ threadId } /attachments/${ fileId } ` )
273- } ;
277+ deleteThreadAttachment : ( threadId , fileId ) =>
278+ apiDelete ( `/api/chat/thread/${ threadId } /attachments/${ fileId } ` )
279+ }
0 commit comments