50 lines
1.7 KiB
TypeScript
50 lines
1.7 KiB
TypeScript
/**
|
|
* Dictation: `POST /api/voice/split` turns a spoken sentence into one string per item,
|
|
* each written the way the web app's item parser (`apps/web/src/lib/natural-input`)
|
|
* reads typed text. The API only splits and normalizes; quantities are read by that
|
|
* parser, so these examples live here, where both workspaces can reach them: the API
|
|
* shows them to the model and the web tests check the parser reads them as expected.
|
|
*/
|
|
|
|
/** Body of `POST /api/voice/split`. */
|
|
export type VoiceSplitRequest = { text: string }
|
|
|
|
/** Response of `POST /api/voice/split`. */
|
|
export type VoiceSplitResponse = { items: string[] }
|
|
|
|
/** Longest transcript the API reads; the rest is cut off. */
|
|
export const VOICE_TEXT_MAX_LENGTH = 500
|
|
|
|
/** Most items one dictation can add. */
|
|
export const VOICE_MAX_ITEMS = 30
|
|
|
|
/** Longest item string kept from one dictation. */
|
|
export const VOICE_ITEM_MAX_LENGTH = 100
|
|
|
|
/**
|
|
* Few-shot examples for the model: what was said and the items it should answer with.
|
|
* Every item string is copied verbatim from the parser's tests (`parse-item.test.ts`).
|
|
*/
|
|
export const VOICE_SPLIT_EXAMPLES: { said: string; items: string[] }[] = [
|
|
{
|
|
said: 'dos pascualinas y un kilo y medio de papas',
|
|
items: ['2 pascualinas', '1,5 kg de papas'],
|
|
},
|
|
{
|
|
said: 'cuatrocientos de jamón feteado fino y una lata de atún',
|
|
items: ['400 de jamon. Feteado fino', '1 lata de atun'],
|
|
},
|
|
{
|
|
said: 'queso crema solo si hay marca tregar y seis yogures',
|
|
items: ['Queso crema. Solo si hay marca Tregar', '6 unidades de yogur'],
|
|
},
|
|
{
|
|
said: 'cuatrocientos gramos de queso y leche descremada',
|
|
items: ['400g de queso', 'Leche (descremada)'],
|
|
},
|
|
{
|
|
said: 'azúcar leche y café',
|
|
items: ['Azúcar', 'Leche', 'Café'],
|
|
},
|
|
]
|