| 76 | |
| 77 | // Runs an assistant |
| 78 | export const runAssistant = async (assistantId, threadId) => { |
| 79 | console.log('Running assistant...'); |
| 80 | const response = await fetch('/api/runAssistant', { |
| 81 | method: 'POST', |
| 82 | headers: { 'Content-Type': 'application/json' }, |
| 83 | body: JSON.stringify({ assistantId, threadId }), |
| 84 | }); |
| 85 | if (!response.ok) { |
| 86 | console.error('Failed to run assistant'); |
| 87 | throw new Error('Failed to run assistant'); |
| 88 | } |
| 89 | const data = await response.json(); |
| 90 | console.log('Assistant run successfully. Run ID:', data.runId); |
| 91 | return data; |
| 92 | }; |
| 93 | |
| 94 | // Checks the status of a run |
| 95 | export const checkRunStatus = async (threadId, runId) => { |