Giter Club home page Giter Club logo

next-openai-app's Introduction

Vercel AI + Chat GPT Steams + Postgres Template

This is a repo that has newest vercel ai, chatGpt streaming and postgres features. The App has a quick response times because we are using vercel ai streaming configuration. In addition, I am persisting the messages using postgres.

This is a good starter kit, but please keep in mind that in order to make this a production level app, you need to make app more secure with authentication

To Run Locally

To run the example locally you need to:

  1. Sign up at OpenAI's Developer Platform.
  2. Go to OpenAI's dashboard and create an API KEY.
  3. Set the required OpenAI environment variable as the token value as shown the example env file but in a new file called .env.local
  4. pnpm install to install the required dependencies.
  5. pnpm dev to launch the development server.

To Deploy

Using vercel.com, it is easy to deploy. Here are the main steps I took.

  1. Publish app on github.com
  2. Go on vercel.com, connect your github repo to vercel.
  3. Set up Postgres Storage by going to Storage Settings

Steps Taken From Beginning

  1. Setup Next.js Repo. You can use one of the templates likes this from vercel
  2. Add Open AI Key. You can generate a new API Key here
  3. Validate that the front-end works. Run npm dev and play with app locally
  4. Setup github + deploy. Go to vercel.com and set up account and connect to the github repo you setup in step #1 . You can then deploy app with a few clicks.
  5. Make sure environment variables are setup in vercel.com. within vercel repo, go to Settings => Environment Variables and add OPENAI_API_KEY key

Exta Credit (Postgres)

  1. Wihin vercel.com, navigate to your repo again and go to Storage & Setup a Postgres instance. Follow the instruction to connect the instance to your repo & pull the credentials down locally. If you don't have vercel installed, install globally npm i --g vercel
  2. Add the necessary postgres code to fetch, update, etc. (I already added some basics)

Learn More

To learn more about OpenAI, Next.js, and the Vercel AI SDK take a look at the following resources:

next-openai-app's People

Contributors

andriy-kulak avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.