16 lines
453 B
TypeScript
16 lines
453 B
TypeScript
|
|
import { api } from './http-client'
|
|||
|
|
|
|||
|
|
interface ChatMessage {
|
|||
|
|
role: 'user' | 'assistant' | 'system'
|
|||
|
|
content: string
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
interface ChatResponse {
|
|||
|
|
content: string
|
|||
|
|
usage?: { model?: string; inputTokens?: number; outputTokens?: number }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
export async function sendMessage(messages: ChatMessage[]): Promise<string> {
|
|||
|
|
const data = await api.post<ChatResponse>('/admin-api/ai/chat', { messages })
|
|||
|
|
return data.content || '(无回复内容)'
|
|||
|
|
}
|