emojinize / frontend /src /lib /api.ts
Luturtun's picture
Replace models: new encoder + gemma-3-1b/qwen3 decoders, drop llama3
34cc2e8
Raw
History Blame Contribute Delete
843 Bytes
const BASE_URL = process.env.NEXT_PUBLIC_API_URL ?? 'http://localhost:8000'
export type Encoder = 'xlm-roberta-large'
export type Decoder = 'gemma3' | 'qwen3'
export interface AnnotationEntry {
span: string
emojis: string
}
export interface AnnotationData {
marked: string
annotations: AnnotationEntry[]
}
export interface AnnotateResponse {
valid: boolean
annotation?: AnnotationData
reason?: string
}
export async function postAnnotate(
encoder: Encoder,
decoder: Decoder,
text: string,
signal?: AbortSignal
): Promise<AnnotateResponse> {
const res = await fetch(`${BASE_URL}/api/annotate`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ encoder, decoder, text }),
signal,
})
if (!res.ok) throw new Error(`HTTP ${res.status}`)
return res.json()
}