https://github.com/pairprogio/nestjs-gpt-action-api-template
Boilerplate project to quickly launch a NestJS powered API for ChatGPT GPT actions
https://github.com/pairprogio/nestjs-gpt-action-api-template
api boilerplate chatgpt gpt gpt-actions nestjs template
Last synced: 2 months ago
JSON representation
Boilerplate project to quickly launch a NestJS powered API for ChatGPT GPT actions
- Host: GitHub
- URL: https://github.com/pairprogio/nestjs-gpt-action-api-template
- Owner: pAIrprogio
- License: apache-2.0
- Created: 2024-03-01T21:43:32.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-03-01T22:42:44.000Z (over 2 years ago)
- Last Synced: 2024-03-01T23:32:12.652Z (over 2 years ago)
- Topics: api, boilerplate, chatgpt, gpt, gpt-actions, nestjs, template
- Language: TypeScript
- Homepage:
- Size: 415 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# NestJS GPT Action API Template

## Installation
```bash
git clone https://github.com/pairprog/nestjs-gpt-action-template.git
cd nestjs-gpt-action-template
pnpm install
cp .env.example .env
```
## Configure
- In [package.json](./package.json) `> scripts > tunnel` , change `domain_name` with yours
- In [.env](./.env)
- Change `BASE_URL` with yours
- (_Not required_) Set `SENTRY_DSN` to enable Sentry error reporting
- In [main.ts](./src/main.ts)
- Set the `Title` and `Description` of the API
## Run Locally
```bash
pnpm run tunnel
```
And in another terminal window
```bash
pnpm run start:dev
# or
pnpm run start:debug
```
- The OpenAPI schema's URL will be shown in the terminal window in blue.
- Copy it
- In "actions" section of your GPT app:
- Click "Create New Action"
- Click on "Import from URL"
- Paste the URL.
- Click "Import"
## Add an action
- Look at [wikipedia.controller.ts](./src/wikipedia/wikipedia.controller.ts) and [wikipedia.dto.ts](./src/wikipedia/wikipedia.dto.ts) to see how to add a new action
## Other
### OpenAI specific headers
OpenAI provides identifying information with each query. You can access them in routes using the [ChatGptHeaders](./src/chat-gpt/chat-gpt.dto.ts) decorator
```ts
@Post('/my/path')
function myPath(@ChatGptHeaders() headers: ChatGptHeaders) {
// ...
}
```