Python-GPT: A ChatGPT API Integration with React Frontend

Contributors Forks Stargazers Issues MIT License

About The Project

Product Name Screen Shot

Python-GPT is an innovative project that integrates OpenAI's ChatGPT with a Python backend (FastAPI) and a React frontend. This application allows users to interact with ChatGPT in a user-friendly web interface, providing a seamless experience for querying and receiving responses from the AI model.

Built With

  • React
  • FastAPI
  • Vite
  • OpenAI API

Getting Started

To get a local copy up and running, follow these simple steps.

Prerequisites

  • Node.js and npm
  npm install npm@latest -g
  • Python 3.7+

Installation

  1. Clone the repo
  2. Install NPM packages for the React frontend
  3. Set up the Python virtual environment and install dependencies for the backend
  4. Enter your OpenAI API key in the .env file in the backend directory

Usage

Python-GPT can be used to interact with the ChatGPT model for various purposes, such as getting answers to questions, generating text based on prompts, or even having a casual conversation with the AI.

To start the backend server:


uvicorn main:app --reload

To run the frontend:


cd frontend npm run dev

Demo

Two Sum Problem Solution

In this demo, we posed a popular junior developer interview question to our ChatGPT-3 app: "Write a Python function to solve the 'Two Sum' problem."

The 'Two Sum' problem is a classic coding interview question that tests understanding of arrays and hash tables. The challenge is to find two numbers in an array that add up to a specific target number.

Here's the AI-generated solution to this problem:

Two Sum Problem Solution

The screenshot above shows the ChatGPT-3 app's response to the Two Sum problem, demonstrating its capability to assist with coding interview preparations.


Creative Writing Prompt

Question: "Can you write a short story about a time-traveling detective?"

This prompt showcases ChatGPT-3's ability to create imaginative and narrative content.

Time-Traveling Detective Story

The screenshot above displays the AI's creative storytelling skills.


Technical Explanation in Simple Terms

Question: "Explain quantum computing in a way a 10-year-old would understand."

This demonstrates the AI's capability to simplify complex concepts for a younger audience.

Quantum Computing Explanation

Here, ChatGPT-3 breaks down the complexities of quantum computing into simpler terms.


Humorous Response

Question: "Tell me a joke about artificial intelligence."

This prompt highlights the AI's lighter, more humorous side.

AI Joke

The AI's response to a humorous prompt, showcasing its wit.


Philosophical Inquiry

Question: "What would be your advice for achieving happiness?"

This type of question can lead to interesting, thought-provoking responses from the AI.

Advice on Happiness

ChatGPT-3's philosophical take on achieving happiness.


Futuristic Scenario

Question: "Describe what you think the world will look like in the year 2024."

This prompt showcases the AI's ability to generate speculative and futuristic ideas.

World in 2100

The AI's vision of the future, as depicted in its response.

Roadmap

  • Implement user authentication for personalized experiences.
  • Add more interactive features to the frontend.
  • Integrate additional AI models for diverse functionalities.

See the open issues for a full list of proposed features (and known issues).

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the MIT License. See LICENSE.txt for more information.

Contact

Dalonte Griffin

LinkedIn

Project Link: https://github.com/dalgriff/python-gpt

Acknowledgments

  • OpenAI
  • FastAPI
  • React
  • Vite