From be3fc30f331778a7eea480d07d8792af10610ef6 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Mon, 16 Feb 2026 04:39:54 +0000 Subject: [PATCH] Update refine prompt to remove border artifacts --- src/service/extraction.test.ts | 42 +++++++++++++++++++++++++--------- src/service/extraction.ts | 9 ++++---- 2 files changed, 36 insertions(+), 15 deletions(-) diff --git a/src/service/extraction.test.ts b/src/service/extraction.test.ts index 5533c97..e47d5d2 100644 --- a/src/service/extraction.test.ts +++ b/src/service/extraction.test.ts @@ -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') + }) }) diff --git a/src/service/extraction.ts b/src/service/extraction.ts index c2dc377..b69a329 100644 --- a/src/service/extraction.ts +++ b/src/service/extraction.ts @@ -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')