https://github.com/bra1ndump/openai-assistants-starter
Get started with openai.beta apis in minutes [TypeScript, Cloudfare Workers]
https://github.com/bra1ndump/openai-assistants-starter
assistants beta boilerplate cloudflare cloudflare-workers gpt openai openai-beta-assistants template typescript
Last synced: 3 days ago
JSON representation
Get started with openai.beta apis in minutes [TypeScript, Cloudfare Workers]
- Host: GitHub
- URL: https://github.com/bra1ndump/openai-assistants-starter
- Owner: bra1nDump
- Created: 2023-11-07T02:17:17.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-11-12T08:35:46.000Z (over 1 year ago)
- Last Synced: 2025-04-26T03:54:21.050Z (9 days ago)
- Topics: assistants, beta, boilerplate, cloudflare, cloudflare-workers, gpt, openai, openai-beta-assistants, template, typescript
- Language: TypeScript
- Homepage:
- Size: 87.9 KB
- Stars: 36
- Watchers: 2
- Forks: 6
- Open Issues: 3
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# beta openai example: assistants + threads + runs
- TypeScript
- Cloudflare Workers
- OpenAI node.js SDK## This project includes:
- VSCode debugging with breakpoints for both the worker and the unit tests
- Unit tests
- 2 endpoints
- `POST /threads` that creates a new thread and returns the thread id
- `POST /threads/:threadId/messages`
- Reads user message from the request body as plain text
- Adds a message to a thread
- Creats an assistant if it doesn't exist
- Runs the assistant on the thread
- Polls the run until it's completed
- Returns the assistant response as plain text## Running
1. Clone the repo and run `npm install`
2. Copy `wrangler.example.toml` to `wrangler.toml` and fill in the OpenAI API key
3. Assuming you are using VSCode, press F5 to start the worker
1. You can also select `Worker + Test` to run the unit tests and see the worker in action (all breakpoitable!)## Other goodies
I have included assistant-documentation that you can simply paste into chatgpt to answer any questions about the new beta.assistants API. I have actually used this to build the initial version of the code.- [all documents](./assistants-documentation/)
- [logs from playground (lets you understand how OpenAI implemented their playgrounds roughly)](assistants-documentation/4. playground assistants log.md)
- [prompt to create the index.ts](./assistants-documentation/6.%20prompt%20to%20bootstrap%20this%20project.md)
- [overall prompt I submitted to ChatGPT to generate the index.ts (did reasonably well)](assistants-documentation/7. prompt with all the files above in it.md)