-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: add e2e tests for new supported image formats
- Loading branch information
Showing
6 changed files
with
88 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { describe, it, expect } from 'vitest' | ||
import { Ollama } from '../src/index' | ||
import path from 'path' | ||
import { fileURLToPath } from 'url' | ||
import { dirname } from 'path' | ||
|
||
|
||
async function describeImage(imageName: string) { | ||
const __filename = fileURLToPath(import.meta.url) | ||
const __dirname = dirname(__filename) | ||
const instance = new Ollama() | ||
const imagePath = path.resolve(__dirname, `./mocks/images/${imageName}`) | ||
const response = await instance.chat({ | ||
model: 'llama3.2-vision', | ||
messages: [{ role: 'user', content: 'what is this?', images: [imagePath] }], | ||
}) | ||
return response.message.content; | ||
} | ||
|
||
const testConfig = { | ||
timeout: 5 * 60 * 1000, // 5 minutes | ||
retry: 3, | ||
} | ||
|
||
describe('Ollama | Nodejs | Vision image formats', () => { | ||
it('support ".webp" image recognition', testConfig, async () => { | ||
const result = await describeImage('WebP-Gradient.webp') | ||
expect(result.toLowerCase()).toContain('gradient') | ||
}) | ||
|
||
it('support ".gif" image recognition', testConfig, async () => { | ||
const result = await describeImage('200w.gif') | ||
expect(result.toLowerCase()).toContain('cat') | ||
}) | ||
|
||
it('support ".avif" image recognition', testConfig, async () => { | ||
const result = await describeImage('fox.profile0.8bpc.yuv420.avif') | ||
expect(result.toLowerCase()).toContain('fox') | ||
}) | ||
|
||
it('support ".tiff/.tif" image recognition', testConfig, async () => { | ||
const result = await describeImage('julia.tif') | ||
expect(result.toLowerCase()).toContain('julia') | ||
}) | ||
|
||
it('support ".svg" image recognition', testConfig, async () => { | ||
const result = await describeImage('house.svg') | ||
expect(result.toLowerCase()).toContain('house') | ||
}) | ||
}) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.