Giter Club home page Giter Club logo

chatgpt-demo's Introduction

ChatGPT Demo

This project aims to replicate the design of the conversation interface on the official ChatGPT website. The main features include creating new conversations, displaying responses with stream output, and highlighting code snippets. Additionally, there is a unique feature that detects code for generating visualizations using ECharts and renders them accordingly.

Technologies Used

Frontend

  • React
  • Redux
  • Material-UI (MUI)
  • ECharts-for-React
  • React-Syntax-Highlighter

Backend

  • Flask
  • MySQL

Additional Details

The frontend implementation involves calling the OpenAI API and handles VPN forwarding using https-proxy-agent. The main code for conversation handling is as follows:

const api = new ChatGPTAPI({
  ...options,
  fetch: (url, options = {}) => {
    const defaultOptions = {
      agent: new HttpsProxyAgent({host: config.proxyHost, port: config.proxyPort}),server information correctly
    }
    const mergedOptions = {
      ...defaultOptions,
      ...options
    }
    return fetch(url, mergedOptions);
  },
});

await api.sendMessage(sendMsg, {
  systemMessage: '',
  onProgress: r => {
    setOnProgress(true);
    dispatch(uiSlice.actions.changeOnProgress(true));
    setAns(r.text);
    dispatch(uiSlice.actions.changeCurAnswer(r.text));
  },
}).then((res) => {
  setOnProgress(false);
  dispatch(uiSlice.actions.changeOnProgress(false));
  addMessage(curSessionId as string, res.text, false);
});

Screenshots

Conversation Interface

chatgpt-demo's People

Contributors

qyunhuang 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.