The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.
TypeScript agentai-chatai-studioall-in-onecoding-agentdesktop-appfluximage-generationlinuxllmlocal-ailocal-llmopen-sourceprivacyself-hostedstable-diffusionuncensoreduncensored-aivideo-generationwindows
feat(create): Improve my prompt rewrites an edit instruction too (B48)
purple5447aed0672b
diff --git a/src/components/create/experimental/__tests__/improve-my-prompt-oberflaeche.test.tsx b/src/components/create/experimental/__tests__/improve-my-prompt-oberflaeche.test.tsxindex b1789909..11ad14c4 100644--- a/src/components/create/experimental/__tests__/improve-my-prompt-oberflaeche.test.tsx+++ b/src/components/create/experimental/__tests__/improve-my-prompt-oberflaeche.test.tsx@@ -37,8 +37,8 @@ beforeEach(() => {afterEach(() => { cleanup() })describe('Schalter Improve my prompt (Desktop)', () => {- it('steht bei Bild, Video und Musik und fehlt bei Bearbeiten', () => {- for (const [intent, shown] of [['image', true], ['video', true], ['music', true], ['edit', false], ['upscale', false]] as const) {+ it('steht bei Bild, Video, Musik und Bearbeiten (B48)', () => {+ for (const [intent, shown] of [['image', true], ['video', true], ['music', true], ['edit', true], ['upscale', false]] as const) {useCreateStore.getState().setIntent(intent)const { unmount } = render(<ImproveToggle />)expect(!!screen.queryByRole('switch', { name: /improve my prompt/i })).toBe(shown)diff --git a/src/components/create/experimental/__tests__/qwen-enhancer-mac-oberflaeche.test.tsx b/src/components/create/experimental/__tests__/qwen-enhancer-mac-oberflaeche.test.tsxindex f4e3a367..2e59771c 100644--- a/src/components/create/experimental/__tests__/qwen-enhancer-mac-oberflaeche.test.tsx+++ b/src/components/create/experimental/__tests__/qwen-enhancer-mac-oberflaeche.test.tsx@@ -93,11 +93,13 @@ describe('the Mac without the enhancer is as before', () => {expect(screen.queryByRole('radiogroup')).toBeNull()})- it('Edit: no switch, even with an enhancer file in a ComfyUI list', () => {+ it('Edit: an enhancer file in a ComfyUI list is not offered, the chat model writes (B48)', () => {mac([T2I])useCreateStore.getState().setIntent('edit')render(<ImproveToggle />)- expect(theSwitch()).toBeNull()+ expect(theSwitch()).not.toBeNull()+ expect(screen.queryByTestId('improve-enhancer-line')).toBeNull()+ expect(screen.queryByRole('radiogroup')).toBeNull()})it('a ComfyUI Qwen-Image on a Mac: the chat model writes, as the run does', async () => {diff --git a/src/components/create/experimental/__tests__/qwen-enhancer-oberflaeche.test.tsx b/src/components/create/experimental/__tests__/qwen-enhancer-oberflaeche.test.tsxindex 2c865ca4..438b7f9b 100644--- a/src/components/create/experimental/__tests__/qwen-enhancer-oberflaeche.test.tsx+++ b/src/components/create/experimental/__tests__/qwen-enhancer-oberflaeche.test.tsx@@ -61,20 +61,26 @@ describe('one switch, also on Edit when the enhancer is there', () => {expect(screen.getAllByRole('switch')).toHaveLength(1)})- it('Edit stays without it when no edit enhancer is installed, or on another model, or in the cloud', () => {+ it('Edit without an edit enhancer, on another model or in the cloud: the chat model writes (B48)', () => {useCreateStore.getState().setIntent('edit')+ useCreateStore.setState({ improvePrompt: true })+ const chatOnly = () => {+ expect(theSwitch()).not.toBeNull()+ expect(screen.queryByTestId('improve-enhancer-line')).toBeNull()+ expect(screen.queryByRole('radiogroup')).toBeNull()+ }local([T2I, T2I_FREE])const a = render(<ImproveToggle />)- expect(theSwitch()).toBeNull()+ chatOnly()a.unmount()local([T2I, I2I], { name: 'flux2-klein.safetensors', type: 'flux2' })const b = render(<ImproveToggle />)- expect(theSwitch()).toBeNull()+ chatOnly()b.unmount()local([T2I, I2I])useCreateStore.setState({ backend: 'cloud' })render(<ImproveToggle />)- expect(theSwitch()).toBeNull()+ chatOnly()})it('the enhancer needs no chat model: the switch works without one', async () => {diff --git a/src/hooks/__tests__/useCloudCreate-improve.test.ts b/src/hooks/__tests__/useCloudCreate-improve.test.tsindex 14f80c52..7a139e9e 100644--- a/src/hooks/__tests__/useCloudCreate-improve.test.ts+++ b/src/hooks/__tests__/useCloudCreate-improve.test.ts@@ -188,7 +188,7 @@ describe('Improve my prompt: Cloud (Desktop)', () => {expect(improve.calls[0].kind).toBe('video')})- it('Bearbeiten ruft das Chatmodell nie, auch bei eingeschaltetem Schalter', async () => {+ it('Bearbeiten schreibt als Anweisung um (B48)', async () => {const s = useCreateStore.getState()s.setImprovePrompt(true); s.setIntent('edit'); s.setCloudImageModel('qwen-image-2.1-edit')useCreateStore.setState({@@ -196,8 +196,9 @@ describe('Improve my prompt: Cloud (Desktop)', () => {mask: { filename: 'm.png', url: 'data:image/png;base64,AA', width: 512, height: 512 },})await useCloudCreate().generate()- expect(improve.calls).toHaveLength(0)- expect(submitted[0].prompt).toBe('my own words')+ expect(improve.calls).toHaveLength(1)+ expect(improve.calls[0].kind).toBe('edit')+ expect(submitted[0].prompt).not.toBe('my own words')})it('Cancel waehrend des Umschreibens: nichts wird abgeschickt', async () => {diff --git a/src/hooks/__tests__/useCreate-mac-qwen-enhancer.test.ts b/src/hooks/__tests__/useCreate-mac-qwen-enhancer.test.tsindex 367a0a63..d2ffa925 100644--- a/src/hooks/__tests__/useCreate-mac-qwen-enhancer.test.ts+++ b/src/hooks/__tests__/useCreate-mac-qwen-enhancer.test.ts@@ -190,14 +190,14 @@ describe('an edit with Qwen-Image 2.1 on a Mac', () => {})})- it('without the edit enhancer nobody rewrites an edit: a chat model cannot see the picture', async () => {+ it('without the edit enhancer the chat model rewrites an edit as an instruction (B48)', async () => {arrange('edit', [T2I])useCreateStore.setState({ source: img('a') } as never)const { result } = renderHook(() => useCreate())await result.current.generate()expect(seen.enhancer).toEqual([])- expect(seen.chat).toEqual([])- expect(seen.runs[0].prompt).toBe('a fox')+ expect(seen.chat).toHaveLength(1)+ expect(seen.runs[0].prompt).not.toBe('a fox')})it('Cancel while the enhancer writes starts no image and shows no error', async () => {diff --git a/src/hooks/__tests__/useCreate-qwen-enhancer.test.ts b/src/hooks/__tests__/useCreate-qwen-enhancer.test.tsindex 6fcda288..e2569e0d 100644--- a/src/hooks/__tests__/useCreate-qwen-enhancer.test.ts+++ b/src/hooks/__tests__/useCreate-qwen-enhancer.test.ts@@ -234,13 +234,13 @@ describe.each(QWEN21_WEIGHTS)('local Qwen-Image 2.1, %s', (_weights, QWEN) => {expect(seen.chat).toHaveLength(1)})- it('Edit without an edit enhancer: nobody rewrites, as before', async () => {+ it('Edit without an edit enhancer: the chat model rewrites it as an edit (B48)', async () => {useCreateStore.getState().setIntent('edit')useCreateStore.setState({ source: image('street.png'), textEncoderList: [T2I, T2I_FREE] } as never)await run()expect(seen.enhancer).toHaveLength(0)- expect(seen.chat).toHaveLength(0)- expect(seen.built[0].prompt).toBe('a fox in snow')+ expect(seen.chat).toHaveLength(1)+ expect(seen.built[0].prompt).toBe('A rewrite from the chat model.')})})})diff --git a/src/lib/render/__tests__/improve-prompt.test.ts b/src/lib/render/__tests__/improve-prompt.test.tsindex 9a9f1548..4488cc6e 100644--- a/src/lib/render/__tests__/improve-prompt.test.ts+++ b/src/lib/render/__tests__/improve-prompt.test.ts@@ -12,12 +12,22 @@ describe('Improve my prompt: welche Laeufe es kennen', () => {})it('alles, was Worte des Kunden woertlich braucht, bleibt unberuehrt', () => {- for (const intent of ['edit', 'removebg', 'upscale', 'eraser', 'character', 'lipsync', 'extend', 'motion', 'tts']) {+ for (const intent of ['removebg', 'upscale', 'eraser', 'character', 'lipsync', 'extend', 'motion', 'tts']) {expect(improveKindForIntent(intent)).toBeNull()}})})+describe('B48: Bearbeiten kennt Improve my prompt', () => {+ it('ein Edit wird als Anweisung umgeschrieben, nie als Beschreibung des ganzen Bildes', () => {+ expect(improveKindForIntent('edit')).toBe('edit')+ const system = buildImproveMessages({ kind: 'edit', modelLabel: 'FLUX.1 Krea' }, 'make her jacket red')[0].content+ expect(system).toMatch(/instructions for an image editing model/)+ expect(system).toMatch(/Do not describe the whole picture/)+ expect(system).toMatch(/FLUX.1 Krea/)+ })+})+describe('Improve my prompt: was das Chatmodell gesagt bekommt', () => {it('der Prompt des Kunden geht unveraendert als Nutzernachricht', () => {const m = buildImproveMessages({ kind: 'image' }, ' a red fox in snow ')diff --git a/src/lib/render/improve-prompt.ts b/src/lib/render/improve-prompt.tsindex e302c5d2..98503149 100644--- a/src/lib/render/improve-prompt.ts+++ b/src/lib/render/improve-prompt.ts@@ -8,16 +8,17 @@// censors, never adds a subject the user did not write, and writes English,// because the render models read English best.-export type ImproveKind = 'image' | 'video' | 'music'+export type ImproveKind = 'image' | 'edit' | 'video' | 'music'/** Which kind of prompt a Create intent writes, or null when the intent has no- * prompt worth rewriting. Edit is left out on purpose: an edit instruction is- * tied to the picture and the mask, and a rewrite can change what it means.- * Speech, lip sync, motion, extend and character runs carry text the user+ * prompt worth rewriting. An edit instruction is rewritten as an instruction+ * (B48, 3.0.9): the chat model cannot see the picture, so it only sharpens+ * what to change and never describes the whole picture. Speech, lip sync, motion, extend and character runs carry text the user* chose word for word (a spoken line, a trigger word) and are never touched. */export function improveKindForIntent(intent: string): ImproveKind | null {switch (intent) {case 'image': return 'image'+ case 'edit': return 'edit'case 'video':case 'animate': return 'video'case 'music': return 'music'@@ -72,6 +73,8 @@ function kindBrief(target: ImproveTarget): string {return target.tags? 'You rewrite prompts for an image model trained on tags. Write one line of comma separated tags and short phrases: subject first, then details, setting, lighting, style. Up to about 60 words.': 'You rewrite prompts for an image model that reads natural language. Write one flowing description of the picture in plain sentences: subject, details, setting, light, composition, style. 40 to 120 words.'+ case 'edit':+ return 'You rewrite instructions for an image editing model. The user\'s text says what to change in a picture you cannot see. Keep it an instruction: name exactly what changes and how, in clear words, and say that everything else stays as it is. Do not describe the whole picture and do not invent what is in it. One or two sentences, 10 to 60 words.'case 'video':return 'You rewrite prompts for a video model. Write one flowing paragraph in the present tense, in the order things happen: the subject, what moves and how, the camera (shot size and movement), the light and the setting. If sound is part of the idea, say it. If the prompt already describes several shots joined by cuts, keep every shot in order and keep each cut written out in words. 60 to 160 words.'case 'music':