🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
🐛 fix: only include input_fidelity parameter for gpt-image-1. (#9920)
Taehyung Lee65dbc6383d44
diff --git a/packages/model-runtime/src/core/openaiCompatibleFactory/createImage.ts b/packages/model-runtime/src/core/openaiCompatibleFactory/createImage.tsindex 3942243601f..b1d38227873 100644--- a/packages/model-runtime/src/core/openaiCompatibleFactory/createImage.ts+++ b/packages/model-runtime/src/core/openaiCompatibleFactory/createImage.ts@@ -67,7 +67,7 @@ async function generateByImageMode(const defaultInput = {n: 1,...(model.includes('dall-e') ? { response_format: 'b64_json' } : {}),- ...(isImageEdit ? { input_fidelity: 'high' } : {}),+ ...(isImageEdit && model === 'gpt-image-1' ? { input_fidelity: 'high' } : {}),};const options = cleanObject({diff --git a/packages/model-runtime/src/core/openaiCompatibleFactory/index.test.ts b/packages/model-runtime/src/core/openaiCompatibleFactory/index.test.tsindex c8f7c77eb8e..e4b8d30360c 100644--- a/packages/model-runtime/src/core/openaiCompatibleFactory/index.test.ts+++ b/packages/model-runtime/src/core/openaiCompatibleFactory/index.test.ts@@ -1254,7 +1254,6 @@ describe('LobeOpenAICompatibleFactory', () => {);expect(instance['client'].images.edit).toHaveBeenCalledWith({image: expect.any(File),- input_fidelity: 'high',mask: 'https://example.com/mask.jpg',model: 'dall-e-2',n: 1,@@ -1301,7 +1300,6 @@ describe('LobeOpenAICompatibleFactory', () => {expect(instance['client'].images.edit).toHaveBeenCalledWith({image: [mockFile1, mockFile2],- input_fidelity: 'high',model: 'dall-e-2',n: 1,prompt: 'Merge these images',@@ -1330,6 +1328,39 @@ describe('LobeOpenAICompatibleFactory', () => {'Failed to convert image URLs to File objects: Error: Failed to download image',);});++ it('should include input_fidelity parameter for gpt-image-1 model', async () => {+ const mockResponse = {+ data: [{ b64_json: 'gpt-image-edited-base64' }],+ };++ const mockFile = new File(['content'], 'test-image.jpg', { type: 'image/jpeg' });++ vi.mocked(openaiHelpers.convertImageUrlToFile).mockResolvedValue(mockFile);+ vi.spyOn(instance['client'].images, 'edit').mockResolvedValue(mockResponse as any);++ const payload = {+ model: 'gpt-image-1',+ params: {+ imageUrl: 'https://example.com/image.jpg',+ prompt: 'Edit this image with gpt-image-1',+ },+ };++ const result = await (instance as any).createImage(payload);++ expect(instance['client'].images.edit).toHaveBeenCalledWith({+ image: expect.any(File),+ input_fidelity: 'high',+ model: 'gpt-image-1',+ n: 1,+ prompt: 'Edit this image with gpt-image-1',+ });++ expect(result).toEqual({+ imageUrl: 'data:image/png;base64,gpt-image-edited-base64',+ });+ });});describe('error handling', () => {@@ -1431,7 +1462,6 @@ describe('LobeOpenAICompatibleFactory', () => {expect(instance['client'].images.edit).toHaveBeenCalledWith({customParam: 'should remain unchanged',image: expect.any(File),- input_fidelity: 'high',model: 'dall-e-2',n: 1,prompt: 'Test prompt',