fix: migrate from sunset OpenAI Assistants API to Responses API #1
PrabalParihar/chatbotlandpatch[bot]+83 −64 in 3 filesverification passed
| File | Pattern | Change |
|---|---|---|
| scripts/assistant.ts:37 | needs-human | Left unchanged for a maintainer: uploaded files need a vector store. |
| src/lib/server/assitant.ts:7 | simple-run | Moved onto the Responses API. |
| src/lib/server/assitant.ts:24 | simple-run | Moved onto the Responses API. |
| src/lib/server/assitant.ts:29 | simple-run | Moved onto the Responses API. |
| src/lib/server/assitant.ts:34 | simple-run | Moved onto the Responses API. |
| src/lib/server/assitant.ts:44 | thread-history | Moved onto the Responses API. |
src/lib/server/assitant.ts console.log('Working on question', question);- let run = await ai.beta.threads.runs.create(threadId, { assistant_id: ASSISTANT_ID });+ const response = await ai.responses.create({+ model,+ instructions,+ conversation: conversationId,+ input+ }); - console.log('Check status of run', run.id);- console.time(run.id);- do {- run = await ai.beta.threads.runs.retrieve(run.thread_id, run.id);- await new Promise<void>((resolve) => setTimeout(() => resolve(), 500));- } while (run.status === 'in_progress' || run.status === 'queued');+ console.log('Check status of run', response.id);+ console.time(response.id);+ console.timeEnd(response.id);
Behaviour
- Threads the code creates are now conversations, and the conversation id is handed back where the thread id was.
- A stored assistant id has no model or instructions in the repository, so the code reads OPENAI_MODEL and OPENAI_INSTRUCTIONS and throws if either is unset.
- The project's own test command needs secrets the sandbox does not have, so it was compared against the unpatched tree rather than required to pass.
Verification
- npm install --ignore-scripts --no-audit --no-fund
- type check, lint, and test command, compared with the unpatched tree
- contract test