Some checks failed
Deploy Admin Frontend / build-and-deploy (push) Failing after 1s
23 lines
615 B
TypeScript
23 lines
615 B
TypeScript
import { api } from './http-client'
|
|
|
|
interface ChatMessage {
|
|
role: 'user' | 'assistant' | 'system'
|
|
content: string
|
|
}
|
|
|
|
interface ChatResponse {
|
|
content: string
|
|
conversationId?: string
|
|
usage?: { model?: string; inputTokens?: number; outputTokens?: number }
|
|
}
|
|
|
|
export async function sendMessage(
|
|
messages: ChatMessage[],
|
|
conversationId?: string,
|
|
signal?: AbortSignal,
|
|
): Promise<ChatResponse> {
|
|
const body: Record<string, unknown> = { messages }
|
|
if (conversationId) body.conversationId = conversationId
|
|
return api.post<ChatResponse>('/admin-api/ai/chat', body, signal ? { signal } : undefined)
|
|
}
|