()
| 44 | const [imageFile, setImageFile] = useState<File | null>(null) |
| 45 | |
| 46 | const connectionOptions = () => { |
| 47 | const body = { provider, numberOfImages: 1, testId, aimockPort } |
| 48 | |
| 49 | if (mode === 'sse') { |
| 50 | return { connection: fetchServerSentEvents('/api/image'), body } |
| 51 | } |
| 52 | if (mode === 'http-stream') { |
| 53 | return { connection: fetchHttpStream('/api/image/stream'), body } |
| 54 | } |
| 55 | return { |
| 56 | fetcher: async (input: { prompt: MediaPrompt }) => { |
| 57 | return generateImageFn({ |
| 58 | data: { |
| 59 | prompt: input.prompt, |
| 60 | provider, |
| 61 | numberOfImages: 1, |
| 62 | aimockPort, |
| 63 | testId, |
| 64 | }, |
| 65 | }) as Promise<ImageGenerationResult> |
| 66 | }, |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | const { generate, result, isLoading, error, status } = |
| 71 | useGenerateImage(connectionOptions()) |
no test coverage detected