Skip to content
This repository was archived by the owner on Sep 4, 2025. It is now read-only.

Commit 8728e37

Browse files
Rough Python translation of openai-assistants-quickstart Typescript repo
1 parent 06fc2d4 commit 8728e37

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+1496
-3313
lines changed

.gitignore

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,4 @@
1-
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2-
3-
# dependencies
4-
/node_modules
5-
/.pnp
6-
.pnp.js
7-
.yarn/install-state.gz
8-
9-
# testing
10-
/coverage
11-
12-
# next.js
13-
/.next/
14-
/out/
15-
16-
# production
17-
/build
18-
19-
# misc
20-
.DS_Store
21-
*.pem
22-
23-
# debug
24-
npm-debug.log*
25-
yarn-debug.log*
26-
yarn-error.log*
27-
281
# local env files
292
.env*.local
303
.env
31-
32-
# vercel
33-
.vercel
34-
35-
# typescript
36-
*.tsbuildinfo
37-
next-env.d.ts
38-
openai-v4.29.0-beta.1.tgz
4+
.venv

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.12

LICENSE

Lines changed: 0 additions & 21 deletions
This file was deleted.

README.md

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,38 @@
1-
# OpenAI Assistants API Quickstart
1+
# OpenAI Assistants API Quickstart with Python, Jinja2, and FastAPI
22

3-
A quick-start template using the OpenAI [Assistants API](https://platform.openai.com/docs/assistants/overview) with [Next.js](https://nextjs.org/docs).
4-
<br/>
5-
<br/>
6-
![OpenAI Assistants API Quickstart](https://github.com/openai/openai-assistants-quickstart/assets/27232/755e85e9-3ea4-421f-b202-3b0c435ea270)
3+
A quick-start template using the OpenAI [Assistants API](https://platform.openai.com/docs/assistants/overview) with [Python](https://www.python.org/), [Jinja2](https://jinja.palletsprojects.com/en/3.1.x/), and [FastAPI](https://fastapi.tiangolo.com/).
74

85
## Quickstart Setup
96

107
### 1. Clone repo
118

129
```shell
13-
git clone https://github.com/openai/openai-assistants-quickstart.git
14-
cd openai-assistants-quickstart
10+
git clone https://github.com/chriscarrollsmith/openai-assistants-python-quickstart.git
11+
cd openai-assistants-python-quickstart
1512
```
1613

1714
### 2. Set your [OpenAI API key](https://platform.openai.com/api-keys)
1815

1916
```shell
20-
export OPENAI_API_KEY="sk_..."
17+
cp .env.example .env
2118
```
2219

23-
(or in `.env.example` and rename it to `.env`).
24-
2520
### 3. Install dependencies
2621

2722
```shell
28-
npm install
23+
uv install -r pyproject.toml
2924
```
3025

3126
### 4. Run
3227

3328
```shell
34-
npm run dev
29+
uv run uvicorn main:app --host 0.0.0.0 --port 8000 --reload
3530
```
3631

3732
### 5. Navigate to [http://localhost:3000](http://localhost:3000).
3833

39-
## Deployment
40-
41-
You can deploy this project to Vercel or any other platform that supports Next.js.
42-
43-
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fopenai%2Fopenai-assistants-quickstart&env=OPENAI_API_KEY,OPENAI_ASSISTANT_ID&envDescription=API%20Keys%20and%20Instructions&envLink=https%3A%2F%2Fgithub.com%2Fopenai%2Fopenai-assistants-quickstart%2Fblob%2Fmain%2F.env.example)
44-
4534
## Overview
4635

47-
This project is intended to serve as a template for using the Assistants API in Next.js with [streaming](https://platform.openai.com/docs/assistants/overview/step-4-create-a-run), tool use ([code interpreter](https://platform.openai.com/docs/assistants/tools/code-interpreter) and [file search](https://platform.openai.com/docs/assistants/tools/file-search)), and [function calling](https://platform.openai.com/docs/assistants/tools/function-calling). While there are multiple pages to demonstrate each of these capabilities, they all use the same underlying assistant with all capabilities enabled.
48-
49-
The main logic for chat will be found in the `Chat` component in `app/components/chat.tsx`, and the handlers starting with `api/assistants/threads` (found in `api/assistants/threads/...`). Feel free to start your own project and copy some of this logic in! The `Chat` component itself can be copied and used directly, provided you copy the styling from `app/components/chat.module.css` as well.
50-
5136
### Pages
5237

5338
- Basic Chat Example: [http://localhost:3000/examples/basic-chat](http://localhost:3000/examples/basic-chat)
@@ -57,8 +42,8 @@ The main logic for chat will be found in the `Chat` component in `app/components
5742

5843
### Main Components
5944

60-
- `app/components/chat.tsx` - handles chat rendering, [streaming](https://platform.openai.com/docs/assistants/overview?context=with-streaming), and [function call](https://platform.openai.com/docs/assistants/tools/function-calling/quickstart?context=streaming&lang=node.js) forwarding
61-
- `app/components/file-viewer.tsx` - handles uploading, fetching, and deleting files for [file search](https://platform.openai.com/docs/assistants/tools/file-search)
45+
- `templates/components/chat.html` - handles chat rendering, [streaming](https://platform.openai.com/docs/assistants/overview?context=with-streaming), and [function call](https://platform.openai.com/docs/assistants/tools/function-calling/quickstart?context=streaming&lang=node.js) forwarding
46+
- `templates/components/file-viewer.html` - handles uploading, fetching, and deleting files for [file search](https://platform.openai.com/docs/assistants/tools/file-search)
6247

6348
### Endpoints
6449

app/api/assistants/files/route.tsx

Lines changed: 0 additions & 77 deletions
This file was deleted.

app/api/assistants/route.ts

Lines changed: 0 additions & 38 deletions
This file was deleted.

app/api/assistants/threads/[threadId]/actions/route.ts

Lines changed: 0 additions & 15 deletions
This file was deleted.

app/api/assistants/threads/[threadId]/messages/route.ts

Lines changed: 0 additions & 20 deletions
This file was deleted.

app/api/assistants/threads/route.ts

Lines changed: 0 additions & 9 deletions
This file was deleted.

app/api/files/[fileId]/route.ts

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)