GithubHelp home page GithubHelp logo

yeonkoocn / nextjs-chatgpt-tutorial Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jakeprins/nextjs-chatgpt-tutorial

0.0 0.0 0.0 734 KB

Build your own ChatGPT application with Next.js, TypeScript, and TailwindCSS.

Home Page: https://www.jakeprins.com/blog/how-to-create-a-chatgpt-application-using-next-js-and-the-openai-api

JavaScript 7.84% TypeScript 74.20% CSS 17.96%

nextjs-chatgpt-tutorial's Introduction

Next.js ChatGPT Tutorial Documentation

Build and customize your own ChatGPT-like web app using Next.js and the OpenAI API. The provided code serves as a foundation, and you can customize it to fit your specific use case.

Screenshot

Tutorial

You can find a step-by-step tutorial here.

Overview

The application uses the following components:

  • Next.js for the frontend and backend server
  • The OpenAI API for chat interactions
  • Tailwind CSS for styling
  • Apideck components for toast notifications and modals

Getting Started

  1. Clone the repository and navigate to the project directory.

  2. Install the required dependencies by running npm install or yarn.

  3. Create a .env.local file in the project root and add your OpenAI API key:

    OPENAI_API_KEY=your_openai_api_key
    
  4. Start the development server by running npm run dev or yarn dev.

  5. Open your browser and navigate to http://localhost:3000 to access the application.

  6. You can now interact with the chatbot using the input field at the bottom of the screen.

Customizing the Application

Model Selection (Optional)

The current implementation of the application uses the "gpt-3.5-turbo" model for chat interactions. This model provides excellent performance for a wide range of tasks and is the recommended choice for most use cases.

However, you might be interested in using other models such as GPT-4. As of March 25th, 2023, GPT-4 is available but in an invite-only mode. Your OpenAI account may not yet have access to it. If you do have access to GPT-4, you can change the model used in the application by modifying the createMessage function in the /src/pages/api/createMessage.ts file:

const body = JSON.stringify({
  messages,
  model: 'gpt-4', // Replace 'gpt-3.5-turbo' with 'gpt-4'
  stream: false
})

Remember that the performance, response time, and pricing for different models may vary. Please refer to the OpenAI API documentation for more information on available models and their specific capabilities.

Feel free to modify the code and styles to fit your specific needs. The application uses Tailwind CSS for styling, making it easy to customize the design by modifying the /src/styles/tailwind.css and /src/styles/globals.css files.

You can also update the application logic, components, and API calls to match your requirements. The main chat functionality is located in /src/utils/sendMessage.ts and /src/utils/useMessages.tsx.

Deploying to Production

To deploy your application, you can use a platform like Vercel or Netlify. Both platforms offer seamless integration with Next.js and support environment variables, which are required to store your OpenAI API key securely. Follow the documentation provided by your chosen platform to deploy the application.

If you have any questions or need further assistance, don't hesitate to create a GitHub issue!

TeamSmart AI

For a complete ChatGPT Chrome extension checkout TeamSmart AI.

nextjs-chatgpt-tutorial's People

Contributors

jakeprins avatar sparkyrider 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.