| 2 | |
| 3 | // Uploads a base64 encoded image and gets a description |
| 4 | export const uploadImageAndGetDescription = async (base64Image) => { |
| 5 | console.log('Uploading image...'); |
| 6 | const response = await fetch('/api/upload_gpt4v', { |
| 7 | method: 'POST', |
| 8 | headers: { 'Content-Type': 'application/json' }, |
| 9 | body: JSON.stringify({ file: base64Image }), |
| 10 | }); |
| 11 | if (!response.ok) { |
| 12 | console.error('Error processing image'); |
| 13 | throw new Error('Error processing image'); |
| 14 | } |
| 15 | console.log('Image uploaded successfully'); |
| 16 | return await response.json(); |
| 17 | }; |
| 18 | |
| 19 | // Uploads a file |
| 20 | export const uploadFile = async (file) => { |