Skip to content

ChatGPT AI Supported - ChatGPT clone is a simple web application powered by the OpenAI library and built with PHP. It allows users to chat with an AI language model that responds in real-time. Chat history is saved using cookies, and the project requires the use of an API key and enabled SQLite3.

Notifications You must be signed in to change notification settings

andrepradika/ChatGPT

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ChatGPT Clone

ChatGPT clone is a simple web application powered by the OpenAI library and built with PHP. It allows users to chat with an AI language model that responds in real-time. Chat history is saved using cookies, and the project requires the use of an API key and enabled SQLite3.

Table of Contents

Prerequisites

Before running this project, you should have the following:

  • PHP 7.4 or later with SQLite3 enabled
  • Composer
  • An OpenAI API key (which should be set to the $open_ai_key variable in event-stream.php)

Get Started

Enable sqlite3

  • Open the php.ini file. This file is usually located in the PHP installation directory.
  • Find the following line: ;extension=php_sqlite3.dll
  • Remove the semicolon at the beginning of the line to uncomment it.
  • Save the file.
  • Restart the web server.

Clone this repository to your local machine

git clone https://github.com/orhanerday/ChatGPT.git

Navigate to the project directory

cd ChatGPT

Install OrhanErday/OpenAI

composer require orhanerday/open-ai

Set your OpenAI API key as the $open_ai_key variable in event-stream.php

$open_ai_key = ""; 

Start the PHP built-in web server

php -S localhost:8000 -t .

Open your web browser and go to http://localhost:8000

You should now see the ChatGPT clone interface, where you can chat with the OpenAI language model.


ezgif-1-92e240a6d3

This project is a ChatGPT clone that allows users to chat with an AI language model trained by OpenAI. It's powered by the github.com/orhanerday/OpenAI php library, which provides an easy-to-use interface for communicating with the OpenAI API.

Image

Live Demo Video


ChatGPT_Clone-vimeo-800126555-hls-akfire_interconnect_quic_sep-436.mp4

Important Notice

This project was created to highlight the Stream Example feature of OpenAI GPT-3 Api Client in PHP by Orhan Erday, please don't have too high expectations about the project.

Donation

Buy Me A Coffee

Join our discord server

Discord Banner 2

Click here to join the Discord server

GPT-4

Change model at event-stream.php

....
$chat = $open_ai->chat([
    'model' => 'gpt-4',

....

Using Docker


Method I

Clone this repository to your local machine

git clone https://github.com/orhanerday/ChatGPT.git

Navigate to the project directory

cd ChatGPT

Build the image

docker build -t chatgpt .

Run the app

docker run -p 8000:8000 -e OPENAI_API_KEY=sk-o7hL4nCDcjw chatgpt

Open your web browser and go

http://localhost:8000


Method II

Or you can use docker hub without cloning or building;

Pull the image from Docker Hub

docker pull orhan55555/chatgpt

Run the app

docker run -p 8000:8000 -e OPENAI_API_KEY=sk-o7hL4nCDcjw orhan55555/chatgpt

Open your web browser and go

http://localhost:8000


Chat History

This project saves chat history using cookies by default. If you want to change this to use authentication instead, you can modify the code in index.php to save chat history in a database or other storage mechanism.

Tools Explanation

This project includes additional tools to enhance the ChatGPT clone functionality:

Weather Tool

The weather tool retrieves weather information using the free wttr.in service. If a user message contains the word "weather", the tool extracts the location (e.g., "weather in London") and retrieves the weather information for that location. If no location is specified, it defaults to "New York".

Stock Tool

The stock tool retrieves stock information using the free Stooq API. If a user message contains the word "stock" or "price", the tool extracts the stock symbol (e.g., "stock AAPL") and retrieves the stock information for that symbol. If no symbol is specified, it defaults to "AAPL".

Credits

This project is powered by the github.com/orhanerday/OpenAI php library, which provides an easy-to-use interface for communicating with the OpenAI API.

About

ChatGPT AI Supported - ChatGPT clone is a simple web application powered by the OpenAI library and built with PHP. It allows users to chat with an AI language model that responds in real-time. Chat history is saved using cookies, and the project requires the use of an API key and enabled SQLite3.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 44.1%
  • JavaScript 27.6%
  • CSS 17.0%
  • Hack 9.4%
  • Dockerfile 1.9%