forked from mito-systems/sol-mem-gen
36 lines
927 B
TypeScript
36 lines
927 B
TypeScript
export interface AdobeGenerationResult {
|
|
imageUrl?: string
|
|
error?: string
|
|
}
|
|
|
|
export async function generateWithAdobe(prompt: string): Promise<AdobeGenerationResult> {
|
|
try {
|
|
const response = await fetch('/api/adobe', {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
},
|
|
body: JSON.stringify({ prompt }),
|
|
})
|
|
|
|
if (!response.ok) {
|
|
throw new Error('Failed to generate image')
|
|
}
|
|
|
|
const data = await response.json()
|
|
console.log('Raw Adobe Firefly response:', data)
|
|
|
|
if (data.imageUrl) {
|
|
return { imageUrl: data.imageUrl }
|
|
} else {
|
|
console.error('Unexpected response structure:', data)
|
|
throw new Error('Invalid response format from Adobe API')
|
|
}
|
|
} catch (error) {
|
|
console.error('Adobe generation error:', error)
|
|
return {
|
|
error: error instanceof Error ? error.message : 'Generation failed'
|
|
}
|
|
}
|
|
}
|