Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from openai:master #1

Open
wants to merge 31 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
866a97d
Update README.md
deadex-ng Nov 26, 2022
ece4764
Updating the model version to 003
abshek17 Dec 9, 2022
175c4df
Add error handling logic
schnerd Dec 23, 2022
ca6492d
Merge pull request #30 from openai/error-handling
schnerd Dec 24, 2022
df33aab
Merge branch 'master' into master
schnerd Dec 24, 2022
f9c7bdb
Merge pull request #23 from abshek17/master
schnerd Dec 24, 2022
65a52e0
Merge pull request #18 from deadex-ng/master
schnerd Dec 24, 2022
259a13a
error on empty input
schnerd Dec 24, 2022
8ab2c3c
issue templates
schnerd Dec 24, 2022
1183f75
bump next.js + react version
schnerd Dec 24, 2022
a4e14e4
bump openai package version
schnerd Dec 24, 2022
663d8d6
update node engine requirement for next.js
schnerd Jan 20, 2023
6aa4d64
readme
schnerd Jan 20, 2023
5d9d70f
Update README.md
schnerd Jan 20, 2023
6888759
chore: add an app image to README file
Jan 21, 2023
8a5a4fc
ignore vscode project file
pathree Feb 11, 2023
5992475
Create LICENSE
logankilpatrick Feb 15, 2023
af87457
Merge pull request #52 from openai/add-license-1
schnerd Feb 16, 2023
df33b0d
Merge pull request #41 from Yaronglp/chore/add_image_doc
logankilpatrick Feb 16, 2023
b4da78d
Update readme to add image alt text
logankilpatrick Feb 16, 2023
823190e
Update .env.example
logankilpatrick Mar 2, 2023
43d9a3c
Update ReadMe to fix the docs URL's
logankilpatrick Mar 2, 2023
f2d3bce
chore(package.json): specify Node.js version to 18+
shiba-hiro Apr 2, 2023
1989f13
Merge pull request #58 from pathree/test
schnerd Jul 3, 2023
e259df9
Update package.json
schnerd Jul 3, 2023
f85ddf6
Update package-lock.json
schnerd Jul 3, 2023
f32c338
Merge pull request #82 from shiba-hiro/update-node-engine-requirement
schnerd Jul 3, 2023
9e4ac12
WIP Stash, need to fix streaming and the UI
logankilpatrick Feb 6, 2024
12295a6
Code is now working with streaming!
logankilpatrick Feb 7, 2024
768211a
Merge pull request #128 from openai/dev/logan/migrate-to-chat-complet…
logankilpatrick Feb 12, 2024
514a02a
Update README.md
logankilpatrick Feb 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
OPENAI_API_KEY=
# Do not share your OpenAI API key with anyone! It should remain a secret.
OPENAI_API_KEY=
41 changes: 41 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Bug report
description: Create a report to help us improve
labels: ["bug"]
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to fill out this bug report!
- type: textarea
id: what-happened
attributes:
label: Describe the bug
description: A clear and concise description of what the bug is, and any additional context.
placeholder: Tell us what you see!
validations:
required: true
- type: textarea
id: repro-steps
attributes:
label: To Reproduce
description: Steps to reproduce the behavior.
placeholder: |
1. Fetch a '...'
2. Update the '....'
3. See error
validations:
required: true
- type: input
id: os
attributes:
label: OS
placeholder: macOS
validations:
required: false
- type: input
id: language-version
attributes:
label: Node version
placeholder: Node v16.14.2
validations:
required: false
7 changes: 7 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
blank_issues_enabled: false
contact_links:
- name: OpenAI support
url: https://help.openai.com/
about: |
Please only file issues here that you believe represent actual bugs or feature requests for the OpenAI Node.js Quickstart.
If you're having general trouble with the OpenAI API, please visit our help center to get support.
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Feature request
description: Suggest an idea for this project
labels: ["feature-request"]
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to fill out this feature request!
- type: textarea
id: feature
attributes:
label: Describe the feature or improvement you're requesting
description: A clear and concise description of what you want to happen.
validations:
required: true
- type: textarea
id: context
attributes:
label: Additional context
description: Add any other context about the feature request here.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

# misc
.DS_Store
.code-workspace

# debug
npm-debug.log*
Expand Down
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 OpenAI

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
37 changes: 32 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,33 @@
# OpenAI API Quickstart - Node.js example app

This is an example pet name generator app used in the OpenAI API [quickstart tutorial](https://beta.openai.com/docs/quickstart). It uses the [Next.js](https://nextjs.org/) framework with [React](https://reactjs.org/). Check out the tutorial or follow the instructions below to get set up.
This is an example chat app intended to get you started with your first OpenAI API project. It uses the [Chat Completions API](https://platform.openai.com/docs/api-reference/chat) to create a simple general purpose chat app with streaming.

## Basic request

To send your first API request with the [OpenAI Node SDK](https://github.com/openai/openai-node), make sure you have the right [dependencies installed](https://platform.openai.com/docs/quickstart?context=node) and then run the following code:

```python
import OpenAI from "openai";

const openai = new OpenAI();

async function main() {
const completion = await openai.chat.completions.create({
messages: [{ role: "system", content: "You are a helpful assistant." }],
model: "gpt-3.5-turbo",
});

console.log(completion.choices[0]);
}

main();
```

This quickstart app builds on top of the example code above, with streaming and a UI to visualize messages.

## Setup

1. If you don’t have Node.js installed, [install it from here](https://nodejs.org/en/)
1. If you don’t have Node.js installed, install it from [nodejs.org](https://nodejs.org/en/) (Node.js version >= 16.0.0 required)

2. Clone this repository

Expand All @@ -22,16 +45,20 @@ This is an example pet name generator app used in the OpenAI API [quickstart tut

5. Make a copy of the example environment variables file

On Linux systems:
```bash
$ cp .env.example .env
```

6. Add your [API key](https://beta.openai.com/account/api-keys) to the newly created `.env` file
On Windows:
```powershell
$ copy .env.example .env
```
6. Add your [API key](https://platform.openai.com/account/api-keys) to the newly created `.env` file

7. Run the app

```bash
$ npm run dev
```

You should now be able to access the app at [http://localhost:3000](http://localhost:3000)! For the full context behind this example app, check out the [tutorial](https://beta.openai.com/docs/quickstart).
You should now be able to access the app at [http://localhost:3000](http://localhost:3000)! For the full context behind this example app, check out the [tutorial](https://platform.openai.com/docs/quickstart).
Loading