(req: NextRequest)
| 22 | }); |
| 23 | |
| 24 | export async function POST(req: NextRequest) { |
| 25 | try { |
| 26 | // Extract JSON data from the request |
| 27 | const data = await req.json(); |
| 28 | const threadId = data.threadId; |
| 29 | const runId = data.runId; |
| 30 | |
| 31 | // Log the received thread ID and run ID for debugging |
| 32 | console.log(`Received request with threadId: ${threadId} and runId: ${runId}`); |
| 33 | |
| 34 | // Retrieve the status of the run for the given thread ID and run ID using the OpenAI API |
| 35 | const runStatus = await openai.beta.threads.runs.retrieve(threadId, runId); |
| 36 | |
| 37 | // Log the retrieved run status for debugging |
| 38 | console.log(`Retrieved run status: ${runStatus.status}`); |
| 39 | |
| 40 | // Return the retrieved run status as a JSON response |
| 41 | return NextResponse.json({ status: runStatus.status }); |
| 42 | } catch (error) { |
| 43 | // Log any errors that occur during the process |
| 44 | console.error(`Error occurred: ${error}`); |
| 45 | } |
| 46 | } |
nothing calls this directly
no outgoing calls
no test coverage detected