Open Source Chat Interface Based on OpenAI API – ChatGPT-web

Introduction

ChatGPT is incredibly powerful! OpenAI’s CEO Sam Altman stated directly: this is our most powerful model to date! It performs comparably to humans on various professional and academic benchmarks! It must be said that since the launch of ChatGPT, Microsoft has won several rounds in the tech battle against Google.

This article introduces an open-source chat interface based on the OpenAI API – ChatGPT-web.

Open Source Chat Interface Based on OpenAI API - ChatGPT-web

ChatGPT-web is a simple single-page web interface for accessing the OpenAI ChatGPT API. Before using it, you need to register for an OpenAI API key. All messages are stored in the browser’s local storage, so everything is private. You can also close the browser tab and come back later to continue the conversation.

OpenAI charges based on the number of tokens used (usage-based), meaning it is much cheaper than ChatGPT Plus unless you use over 10 million tokens each month. All messages are stored in your browser’s local storage, ensuring privacy. You can also close the browser tab and return later to continue the conversation.

As an alternative to OpenAI, you can also use Petals swarm as a free API option for open chat models like Llama 2.

Features

Open Source: ChatGPT-web is open source (GPL-3.0), so you can self-host and modify it as needed.

Private: All chats and messages are stored in your browser’s local storage, ensuring privacy.

Customizable: You can customize prompts, temperature, and other model settings. Supports multiple models (including GPT-4).

Cheaper: ChatGPT-web uses the commercial OpenAI API, making it much cheaper than the ChatGPT Plus subscription.

Fast: ChatGPT-web is a single-page web application, making it fast and responsive.

Mobile Friendly: ChatGPT-web is mobile-friendly, allowing you to use it on your phone.

Voice Input: ChatGPT-web supports voice input, so you can speak to ChatGPT. It will respond to you.

Predefined Prompts: ChatGPT-web comes with a range of predefined prompts, allowing you to get started quickly.

Export: ChatGPT-web can export chats as Markdown files, enabling you to share with others.

Code: ChatGPT-web recognizes and highlights code blocks, allowing you to copy them with one click.

Desktop Application: ChatGPT-web can be packaged as a desktop application, allowing you to use it outside the browser.

Image Generation: ChatGPT-web can generate images using the DALL·E model with the prompt “show me an image of …”.

Streaming: ChatGPT-web can stream responses from the API, allowing you to see the response as it is generated.

Development

To run the development server, execute

npm ci npm run dev # or: npm run build

To update the awesome-chatgpt-prompts subtree, run: git subtree pull --prefix src/awesome-chatgpt-prompts https://github.com/f/awesome-chatgpt-prompts.git main --squash

Use Docker compose docker compose up -d

Mock API

If you don’t want to wait for API responses, you can use a mock API. To use the mock API, edit the .env file in the project root directory and set the key VITE_API_BASE=http://localhost:5174. Then, run the docker compose up -d command above.

You can customize the mock API response by sending a message starting with ‘d’ followed by a number, which will cause the response to delay for the specified number of seconds. You can customize the response length by including ‘l’ followed by a number, which will return a response with the specified number of sentences. For example, sending the message d2 l10 will result in a 2-second delay and a response of 10 sentences.

Desktop Application

You can also use ChatGPT-web as a desktop application. To do this, first install Rust. Then, simply run npm run tauri dev for the development version or npm run tauri build for the production version of the desktop application. The desktop application will be built in the src-tauri/target folder.

References

For more information, please refer to: https://github.com/Niek/chatgpt-web

Leave a Comment