mirror of
https://github.com/HeyPuter/puter.git
synced 2026-09-11 15:55:44 +00:00
fix(puter-js): require prompt in ai.txt2img (#3804)
txt2vid rejects missing prompts client-side with prompt_required, but txt2img sent the request to the backend. Add the same guard before the driver call.
This commit is contained in:
@@ -607,6 +607,11 @@ describe('ai.txt2img driver payloads', () => {
|
||||
expect(img.src).toBe('data:image/png;base64,QUJD');
|
||||
expect(img.toString()).toBe('data:image/png;base64,QUJD');
|
||||
});
|
||||
|
||||
it('txt2img rejects without a prompt', async () => {
|
||||
await expect(ai.txt2img({})).rejects.toMatchObject({ code: 'prompt_required' });
|
||||
expect(FakeXHR.requests).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('ai.txt2vid driver payloads', () => {
|
||||
|
||||
@@ -58,6 +58,10 @@ export async function txt2img (promptOrOptions, optionsOrTestMode) {
|
||||
options = promptOrOptions;
|
||||
}
|
||||
|
||||
if ( ! options.prompt ) {
|
||||
throw ({ message: 'Prompt parameter is required', code: 'prompt_required' });
|
||||
}
|
||||
|
||||
const driverHint = typeof options.driver === 'string' ? options.driver : undefined;
|
||||
const imageService = driverHint || 'ai-image';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user