| 60 | |
| 61 | // Creates a thread |
| 62 | export const createThread = async (inputmessage) => { |
| 63 | console.log('Creating thread...'); |
| 64 | const response = await fetch('/api/createThread', { |
| 65 | method: 'POST', |
| 66 | headers: { 'Content-Type': 'application/json' }, |
| 67 | body: JSON.stringify({ inputmessage }), |
| 68 | }); |
| 69 | if (!response.ok) { |
| 70 | console.error('Failed to create thread'); |
| 71 | throw new Error('Failed to create thread'); |
| 72 | } |
| 73 | console.log('Thread created successfully'); |
| 74 | return await response.json(); |
| 75 | }; |
| 76 | |
| 77 | // Runs an assistant |
| 78 | export const runAssistant = async (assistantId, threadId) => { |