fix: restore image editing requests
Image editing requests included a generation-only response_format field that some compatible providers reject. Editing now sends only supported defaults while preserving explicitly configured custom request fields.\n\nRelease note: 修复部分图像服务商修改图片时报错的问题;参考图编辑现在可以正常提交。
This commit is contained in:
@@ -5548,7 +5548,7 @@ describe('ModelAgentRuntime', () => {
|
|||||||
expect(form.get('prompt')).toBe('把背景改成白色')
|
expect(form.get('prompt')).toBe('把背景改成白色')
|
||||||
expect(form.get('n')).toBe('1')
|
expect(form.get('n')).toBe('1')
|
||||||
expect(form.get('quality')).toBe('medium')
|
expect(form.get('quality')).toBe('medium')
|
||||||
expect(form.get('response_format')).toBe('b64_json')
|
expect(form.get('response_format')).toBeNull()
|
||||||
expect(form.get('background')).toBe('transparent')
|
expect(form.get('background')).toBe('transparent')
|
||||||
const uploaded = form.get('image')
|
const uploaded = form.get('image')
|
||||||
expect(uploaded).toBeInstanceOf(Blob)
|
expect(uploaded).toBeInstanceOf(Blob)
|
||||||
|
|||||||
@@ -1793,7 +1793,12 @@ export class ModelAgentRuntime implements AgentRuntime {
|
|||||||
images: NonNullable<AgentExecutionRequest['images']>
|
images: NonNullable<AgentExecutionRequest['images']>
|
||||||
): FormData {
|
): FormData {
|
||||||
const form = new FormData()
|
const form = new FormData()
|
||||||
const fields = this.createImageGenerationRequest(prompt)
|
const fields = this.createRequestBody({
|
||||||
|
model: this.options.model,
|
||||||
|
prompt: prompt.slice(0, 100_000),
|
||||||
|
n: 1,
|
||||||
|
quality: this.options.imageGenerationQuality ?? 'auto'
|
||||||
|
})
|
||||||
for (const [name, value] of Object.entries(fields)) {
|
for (const [name, value] of Object.entries(fields)) {
|
||||||
form.append(
|
form.append(
|
||||||
name,
|
name,
|
||||||
|
|||||||
Reference in New Issue
Block a user