-
Notifications
You must be signed in to change notification settings - Fork 2
feat: add integration tests for skill-driven extraction functionality #127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,7 @@ import { config } from "dotenv"; | |
| config({ path: ".env.test" }); | ||
|
|
||
| import { VlmRun } from "../../../src/index"; | ||
| import { SkillInfo } from "../../../src/client/types"; | ||
| import { SkillInfo, PredictionResponse } from "../../../src/client/types"; | ||
|
|
||
| jest.setTimeout(60000); | ||
|
|
||
|
|
@@ -379,4 +379,65 @@ describe("Integration: Skills", () => { | |
| expect(result.download_url.length).toBeGreaterThan(0); | ||
| }); | ||
| }); | ||
|
|
||
| describe("create() and document.generate() — skill-driven extraction", () => { | ||
| const testFilePath = "tests/integration/assets/google_invoice.pdf"; | ||
|
|
||
| it("should create a skill and use it for batch document generation via file_id", async () => { | ||
| const skill = await client.skills.create({ | ||
| prompt: INVOICE_SKILL_PROMPT, | ||
| jsonSchema: INVOICE_SCHEMA, | ||
| name: `invoice-doc-generate-${Date.now()}`, | ||
| description: | ||
| "Invoice skill for document generation integration test.", | ||
| }); | ||
|
|
||
| expect(skill).toBeTruthy(); | ||
| expect(skill.id).toBeDefined(); | ||
| expect(skill.name).toBeDefined(); | ||
|
|
||
| const uploadedFile = await client.files.upload({ | ||
| filePath: testFilePath, | ||
| purpose: "vision", | ||
| checkDuplicate: true, | ||
| }); | ||
|
|
||
| expect(uploadedFile).toHaveProperty("id"); | ||
|
|
||
| const result: PredictionResponse = await client.document.generate({ | ||
| fileId: uploadedFile.id, | ||
| model: "vlm-1", | ||
| domain: "document.invoice", | ||
| batch: true, | ||
| config: { | ||
| skills: [ | ||
| { | ||
| skill_name: skill.name, | ||
| version: skill.version, | ||
| }, | ||
| ], | ||
| } as any, | ||
|
Comment on lines
+412
to
+419
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The use of To address this correctly, the following changes are needed in files not included in this pull request:
I recommend including these changes in this pull request to ensure the new test is valid and type-safe. |
||
| metadata: { | ||
| environment: "dev", | ||
| allowTraining: false, | ||
| }, | ||
| }); | ||
|
|
||
| expect(result).toHaveProperty("id"); | ||
| expect(typeof result.id).toBe("string"); | ||
| expect(result).toHaveProperty("created_at"); | ||
| expect(typeof result.created_at).toBe("string"); | ||
| expect(result).toHaveProperty("status"); | ||
| expect(result.status).toBe("pending"); | ||
|
|
||
| const completed: PredictionResponse = await client.predictions.wait( | ||
| result.id, | ||
| ); | ||
|
|
||
| expect(completed.status).toBe("completed"); | ||
| expect(completed).toHaveProperty("response"); | ||
| expect(completed.response).toBeTruthy(); | ||
| expect(completed).toHaveProperty("completed_at"); | ||
| }); | ||
| }); | ||
| }); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For better readability and consistency with other examples in this file, please add a comment explaining what this command does.