From 59ee7a5304abf0c527ebe8711ea9a219a3e45976 Mon Sep 17 00:00:00 2001 From: Caster Date: Fri, 22 May 2026 10:02:24 +0800 Subject: [PATCH 1/3] feat(codex): support image references in responses imagegen --- .../src/pages/scenario/PlaygroundPage.tsx | 20 ++++++- internal/client/codex_client.go | 55 ++++++++++++++++++- 2 files changed, 71 insertions(+), 4 deletions(-) diff --git a/frontend/src/pages/scenario/PlaygroundPage.tsx b/frontend/src/pages/scenario/PlaygroundPage.tsx index ac19de875..31166142e 100644 --- a/frontend/src/pages/scenario/PlaygroundPage.tsx +++ b/frontend/src/pages/scenario/PlaygroundPage.tsx @@ -45,6 +45,7 @@ const PlaygroundPage: React.FC = () => { const [models, setModels] = useState([]); const [model, setModel] = useState(''); const [prompt, setPrompt] = useState(''); + const [imageRefs, setImageRefs] = useState(''); const [size, setSize] = useState('1024x1024'); const [quality, setQuality] = useState('auto'); const [count, setCount] = useState(1); @@ -74,13 +75,15 @@ const PlaygroundPage: React.FC = () => { setResults([]); try { const client = await getOpenAIClient(IMAGE_SCENARIO); + const refs = imageRefs.split('\n').map((v) => v.trim()).filter(Boolean); const resp = await client.images.generate({ model, prompt: prompt.trim(), n: count, size: size as any, quality, - }); + ...(refs.length > 0 ? ({ extra_body: { input_image_refs: refs } } as any) : {}), + } as any); setResults(resp.data ?? []); } catch (err: any) { const status = err?.status ? `${err.status}: ` : ''; @@ -89,7 +92,7 @@ const PlaygroundPage: React.FC = () => { } finally { setSending(false); } - }, [prompt, model, count, size, quality, showNotification]); + }, [prompt, imageRefs, model, count, size, quality, showNotification]); const noModels = useMemo(() => models.length === 0, [models]); @@ -186,6 +189,19 @@ const PlaygroundPage: React.FC = () => { disabled={noModels} /> + + setImageRefs(e.target.value)} + disabled={noModels} + /> + + {uploadRefs.length > 0 && ( + + {uploadRefs.length} uploaded reference image(s) + + )} + {uploadRefs.length > 0 && ( + + )} + + {uploadRefs.length > 0 && ( - {uploadRefs.length} uploaded reference image(s) + {t('playground.uploadedCount', { defaultValue: "{{count}} uploaded reference image(s)", count: uploadRefs.length })} )} {uploadRefs.length > 0 && ( )} + {uploadRefs.length > 0 && ( + + {uploadRefs.slice(0, 8).map((src, idx) => ( + + ))} + + )} +