2024-08-20 07:41:08 +08:00
import { AiExtractElementInfo } from '@/ai-model' ;
2025-03-07 17:20:18 +08:00
import { getContextFromFixture } from 'tests/evaluation' ;
2024-08-20 07:41:08 +08:00
import { describe , expect , it , vi } from 'vitest' ;
vi . setConfig ( {
testTimeout : 180 * 1000 ,
hookTimeout : 30 * 1000 ,
} ) ;
2025-01-03 21:50:25 +08:00
describe ( 'extract' , ( ) = > {
it ( 'todo' , async ( ) = > {
2025-02-10 16:36:12 +08:00
const { context } = await getContextFromFixture ( 'todo-input-with-value' ) ;
2024-08-20 07:41:08 +08:00
2025-01-03 21:50:25 +08:00
const { parseResult } = await AiExtractElementInfo ( {
2025-03-12 13:49:50 +08:00
dataQuery : 'Array<string>, task list, task name as string' ,
2025-01-03 21:50:25 +08:00
context ,
2024-08-20 07:41:08 +08:00
} ) ;
2025-03-12 13:49:50 +08:00
expect ( parseResult ) . toBeDefined ( ) ;
expect ( ( parseResult . data as string [ ] ) . length ) . toBeGreaterThanOrEqual ( 3 ) ;
// expect(parseResult).toMatchSnapshot();
2025-01-03 21:50:25 +08:00
} ) ;
2024-08-20 07:41:08 +08:00
2025-01-03 21:50:25 +08:00
it ( 'online order' , async ( ) = > {
2025-02-10 16:36:12 +08:00
const { context } = await getContextFromFixture ( 'online_order' ) ;
2024-08-20 07:41:08 +08:00
2025-01-03 21:50:25 +08:00
const { parseResult } = await AiExtractElementInfo ( {
dataQuery : '{name: string, price: string}[], 饮品名称和价格' ,
context ,
2024-08-20 07:41:08 +08:00
} ) ;
2025-01-03 21:50:25 +08:00
expect ( parseResult ) . toMatchSnapshot ( ) ;
} ) ;
2024-08-20 07:41:08 +08:00
2025-01-03 21:50:25 +08:00
it ( 'todo obj' , async ( ) = > {
2025-02-10 16:36:12 +08:00
const { context } = await getContextFromFixture ( 'todo-input-with-value' ) ;
2024-08-20 07:41:08 +08:00
2025-01-03 21:50:25 +08:00
const { parseResult } = await AiExtractElementInfo ( {
dataQuery :
2025-02-28 10:59:22 +08:00
'{checked: boolean; text: string;}[], Task list with checkbox ahead of the task name (checkbox is a round box), task name as string and `checked` is true if the task is completed. Exclude the fist row if there is no round checkbox ahead of the task name.' ,
2025-01-03 21:50:25 +08:00
context ,
2024-08-20 07:41:08 +08:00
} ) ;
2025-01-03 21:50:25 +08:00
expect ( parseResult ) . toMatchSnapshot ( ) ;
2024-08-20 07:41:08 +08:00
} ) ;
} ) ;