Update refine prompt to remove border artifacts
This commit is contained in:
1 parent
46eb0b2d61
commit
be3fc30f33
2 files changed
+36
-15
No files matched your search
@@ -1,19 +1,22 @@
|
||||
import { describe, expect, test, mock, beforeAll } from 'bun:test'
|
||||
|
||||
// Mock dependencies
|
||||
const generateTextMock = mock(async () => ({
|
||||
assets: [
|
||||
{
|
||||
item_name: 'Helmet',
|
||||
description: 'A rusty helmet',
|
||||
category: 'Headwear',
|
||||
sub_category: 'Helmet',
|
||||
},
|
||||
],
|
||||
}))
|
||||
const generateImageMock = mock(async () => 'data:image/png;base64,mockImage')
|
||||
|
||||
mock.module('./ai', () => ({
|
||||
aiService: {
|
||||
generateText: mock(async () => ({
|
||||
assets: [
|
||||
{
|
||||
item_name: 'Helmet',
|
||||
description: 'A rusty helmet',
|
||||
category: 'Headwear',
|
||||
sub_category: 'Helmet',
|
||||
},
|
||||
],
|
||||
})),
|
||||
generateImage: mock(async () => 'data:image/png;base64,mockImage'),
|
||||
generateText: generateTextMock,
|
||||
generateImage: generateImageMock,
|
||||
},
|
||||
}))
|
||||
|
||||
@@ -74,4 +77,21 @@ describe('ExtractionService', () => {
|
||||
expect(result[0].name).toBe('Helmet')
|
||||
expect(result[0].base64).toContain('data:image/png;base64,')
|
||||
})
|
||||
|
||||
test('refineAsset calls AI service with correct prompt', async () => {
|
||||
// Clear previous calls
|
||||
generateImageMock.mockClear()
|
||||
|
||||
const base64 = 'data:image/png;base64,mockImageContent'
|
||||
const result = await extractionService.refineAsset(base64)
|
||||
|
||||
expect(result).toBe('data:image/png;base64,mockImage')
|
||||
expect(generateImageMock).toHaveBeenCalled()
|
||||
|
||||
const callArgs = generateImageMock.mock.calls[0]
|
||||
const prompt = callArgs[0]
|
||||
|
||||
expect(prompt).toContain('CRITICAL: Detect and remove any straight lines, black borders, or frame-like artifacts')
|
||||
expect(prompt).toContain('These are cropping artifacts and MUST be removed')
|
||||
})
|
||||
})
|
||||
@@ -160,10 +160,11 @@ Task: Asset Refinement
|
||||
Instructions:
|
||||
1. Process the provided asset image.
|
||||
2. Remove any remaining background artifacts and ensure a pure white or transparent background.
|
||||
3. Upscale the image and enhance details for high-quality game asset presentation.
|
||||
4. Ensure the object is centered and fully visible.
|
||||
5. EXTREME DETAIL: Preserve every existing detail, texture, and pattern from the input image. Do not change the design. Only sharpen and clarify.
|
||||
6. Return only the image.
|
||||
3. CRITICAL: Detect and remove any straight lines, black borders, or frame-like artifacts at the edges of the image. These are cropping artifacts and MUST be removed.
|
||||
4. Upscale the image and enhance details for high-quality game asset presentation.
|
||||
5. Ensure the object is centered and fully visible.
|
||||
6. EXTREME DETAIL: Preserve every existing detail, texture, and pattern from the input image. Do not change the design. Only sharpen and clarify.
|
||||
7. Return only the image.
|
||||
`
|
||||
// Using generateImage with image input
|
||||
return aiService.generateImage(prompt, [file], 'step_refine_model')
|
||||
|
||||
Reference in new issue
Block a user