From 1706886a64e7cdf4038934865dc095ce1005a3c4 Mon Sep 17 00:00:00 2001 From: Fuegovic <32828263+fuegovic@users.noreply.github.com> Date: Wed, 6 Dec 2023 06:57:10 -0500 Subject: [PATCH] doc: PandoraNext guide (#1276) --- .env.example | 2 +- README.md | 6 +- docs/features/pandoranext.md | 158 ++++++++++++++++++++++++++++++++ docs/install/apis_and_tokens.md | 5 +- docs/install/dotenv.md | 9 +- mkdocs.yml | 3 +- 6 files changed, 174 insertions(+), 9 deletions(-) create mode 100644 docs/features/pandoranext.md diff --git a/.env.example b/.env.example index 02dcc799c..0869b28a1 100644 --- a/.env.example +++ b/.env.example @@ -76,7 +76,7 @@ BINGAI_TOKEN=user_provided #============# CHATGPT_TOKEN= -CHATGPT_MODELS=text-davinci-002-render-sha,gpt-4 +CHATGPT_MODELS=text-davinci-002-render-sha # CHATGPT_REVERSE_PROXY= #============# diff --git a/README.md b/README.md index ef1873ca8..da524c090 100644 --- a/README.md +++ b/README.md @@ -107,11 +107,13 @@ Keep up with the latest updates by visiting the releases page - [Releases](https * [Automated Moderation](docs/features/mod_system.md) + * [Token Usage](docs/features/token_usage.md) + * [Manage Your Database](docs/features/manage_your_database.md) + * [PandoraNext Deployment Guide](docs/features/pandoranext.md) * [Third-Party Tools](docs/features/third_party.md) * [Proxy](docs/features/proxy.md) * [Bing Jailbreak](docs/features/bing_jailbreak.md) - * [Token Usage](docs/features/token_usage.md) - * [Manage Your Database](docs/features/manage_your_database.md) +
diff --git a/docs/features/pandoranext.md b/docs/features/pandoranext.md new file mode 100644 index 000000000..7926917fd --- /dev/null +++ b/docs/features/pandoranext.md @@ -0,0 +1,158 @@ +# PandoraNext Deployment Guide + +If you're looking to use the `ChatGPT` Endpoint in LibreChat, setting up a reverse proxy is a essential. PandoraNext offers a robust solution for this purpose. This guide will walk you through deploying PandoraNext to enable the `CHATGPT_REVERSE_PROXY` for use with LibreChat. + +> Using this method you will only be able to use `text-davinci-002-render-sha` with PandoraNext in LibreChat. Other models offer with the `plus` subscription do not work. + +You can use it locally in docker or deploy it onthe web for remote access. + +## Deploy Online by Duplicating Hugging Face Space + +To deploy PandoraNext online by duplicating the Hugging Face Space, follow these steps: + +1. Get your PandoraNext license id here: [PandoraNext Dashboard](https://dash.pandoranext.com/) + +2. **Configure `config.json`:** + Edit the following `config.json`. Specify your `license_id` and `proxy_api_prefix`. For the `proxy_api_prefix`, use at least 8 characters, avoid characters that can't be used in a URL and make sure it's unique. + + Here's the `config.json` for your reference: + + ```json + { + "bind": "0.0.0.0:8181", + "tls": { + "enabled": false, + "cert_file": "", + "key_file": "" + }, + "timeout": 600, + "proxy_url": "", + "license_id": "", + "public_share": false, + "site_password": "", + "setup_password": "", + "server_tokens": true, + "proxy_api_prefix": "", + "isolated_conv_title": "*", + "captcha": { + "provider": "", + "site_key": "", + "site_secret": "", + "site_login": false, + "setup_login": false, + "oai_username": false, + "oai_password": false + }, + "whitelist": null + } + ``` + +3. **Hugging Face Space:** + Visit the [PandoraNext LibreChat Space](https://huggingface.co/spaces/LibreChat/PandoraNext) on Hugging Face. + +4. **Duplicate the Space:** + Utilize the available options to duplicate or fork the space into your own Hugging Face account. + +5. **Fill the required secrets** + When asked for the `SECRETS`, + - for `CONFIG_JSON` use the whole content of the `config.json` you just modified, + - for `TOKENS_JSON` use the following default `token.json`: + ```json + { + "test-1": { + "token": "access token / session token / refresh token", + "shared": true, + "show_user_info": false + }, + "test-2": { + "token": "access token / session token / refresh token", + "shared": true, + "show_user_info": true, + "plus": true + }, + "test2": { + "token": "access token / session token / refresh token / share token", + "password": "12345" + } + } + ``` +6. **Configure LibreChat:** + In the .env file (or secrets settings if you host LibreChat on Hugging Face), set the `CHATGPT_REVERSE_PROXY` variable using the following format: + + ```bash + CHATGPT_REVERSE_PROXY=http://your_server_domain.com/your_proxy_api_prefix_here/backend-api/conversation + ``` + + - Replace `your_server_domain.com` with the domain of your deployed space. + - you can use this format: `https://username-pandoranext.hf.space` (replace `username` with your Huggingface username) + - Replace `your_proxy_api_prefix_here` with the `proxy_api_prefix` you have set in your `config.json`. + - The resulting URL should look similar to: + `https://username-pandoranext.hf.space/your_proxy_api_prefix_here/backend-api/conversation` + +## Deploy Locally Using Docker + +For local deployment using Docker, the steps are as follows: + +1. **Clone or Download the Repository:** + Get the latest release from the [PandoraNext GitHub repository](https://github.com/pandora-next/deploy). + + ```bash + git clone https://github.com/pandora-next/deploy.git + ``` + +2. Get your PandoraNext license id here: [PandoraNext Dashboard](https://dash.pandoranext.com/) + +3. **Configure `config.json`:** + Within the cloned repository, in the `data` folder, edit `config.json`. Specify your `license_id` and `proxy_api_prefix`. For the `proxy_api_prefix`, use at least 8 characters, avoid characters that can't be used in a URL and make sure it's unique. + + Here's the `config.json` for your reference: + + ```json + { + "bind": "0.0.0.0:8181", + "tls": { + "enabled": false, + "cert_file": "", + "key_file": "" + }, + "timeout": 600, + "proxy_url": "", + "license_id": "", + "public_share": false, + "site_password": "", + "setup_password": "", + "server_tokens": true, + "proxy_api_prefix": "", + "isolated_conv_title": "*", + "captcha": { + "provider": "", + "site_key": "", + "site_secret": "", + "site_login": false, + "setup_login": false, + "oai_username": false, + "oai_password": false + }, + "whitelist": null + } + ``` + +4. **Set Up the LibreChat `.env` Filer:** + In the `.env` file within your LibreChat directory, you'll need to set the `CHATGPT_REVERSE_PROXY` variable: + + ```bash + CHATGPT_REVERSE_PROXY=http://host.docker.internal:8181/your_proxy_api_prefix_here/backend-api/conversation + ``` + - Replace `your_proxy_api_prefix_here` with the actual proxy API prefix. + +4. **Start Docker Containers:** + From the PandoraNext directory, run the following command to launch the Docker containers: + + ```bash + docker-compose up -d + ``` + +## Final Notes + +- The `proxy_api_prefix` should be sufficiently random and unique to prevent errors. +- Ensure you have obtained a license ID from the [PandoraNext Dashboard](https://dash.pandoranext.com/). diff --git a/docs/install/apis_and_tokens.md b/docs/install/apis_and_tokens.md index 1007a6e2d..c3c7262b1 100644 --- a/docs/install/apis_and_tokens.md +++ b/docs/install/apis_and_tokens.md @@ -13,7 +13,10 @@ To get your OpenAI API key, you need to: ## ChatGPT Free Access token -To get your Access token for ChatGPT 'Free Version', you need to: +> Note that this is disabled by default and requires additional configuration to work. +> See: [ChatGPT Reverse Proxy](../features/pandoranext.md) + +To get your Access token for ChatGPT 'Web Version', you need to: - Go to [https://chat.openai.com](https://chat.openai.com) - Create an account or log in with your existing one diff --git a/docs/install/dotenv.md b/docs/install/dotenv.md index 0876c3ff6..2f7a1563c 100644 --- a/docs/install/dotenv.md +++ b/docs/install/dotenv.md @@ -148,21 +148,22 @@ BINGAI_HOST= ### ChatGPT see: [ChatGPT Free Access token](./apis_and_tokens.md#chatgpt-free-access-token) -> **Warning**: The default reverse proxy (based on [PandoraNext](https://github.com/pandora-next/deploy)) needs to be updated and is not working anymore. To use this endpoint you'll have to set up your own. -> For more information: [https://github.com/waylaidwanderer/node-chatgpt-api#using-a-reverse-proxy](https://github.com/waylaidwanderer/node-chatgpt-api#using-a-reverse-proxy) +> **Warning**: To use this endpoint you'll have to set up your own reverse proxy. Here is the installation guide to deploy your own (based on [PandoraNext](https://github.com/pandora-next/deploy)): **[PandoraNext Deployment Guide](../features/pandoranext.md)** ```bash CHATGPT_REVERSE_PROXY= ``` -> Note: If you're a GPT plus user you can add gpt-4-plugins, gpt-4-code-interpreter, and gpt-4-browsing to the list above and use the models for these features; however, the view/display portion of these features are not supported, but you can use the underlying models, which have higher token context +> ~~Note: If you're a GPT plus user you can add gpt-4, gpt-4-plugins, gpt-4-code-interpreter, and gpt-4-browsing to the list above and use the models for these features; however, the view/display portion of these features are not supported, but you can use the underlying models, which have higher token context~~ +> **Note:** The current method only works with `text-davinci-002-render-sha` - Leave `CHATGPT_TOKEN=` blank to disable this endpoint - Set `CHATGPT_TOKEN=` to "user_provided" to allow users to provide their own API key from the WebUI + - It is not recommended to provide your token in the `.env` file since it expires often and sharing it could get you banned. ```bash CHATGPT_TOKEN= -CHATGPT_MODELS=text-davinci-002-render-sha,gpt-4 +CHATGPT_MODELS=text-davinci-002-render-sha ``` ### OpenAI diff --git a/mkdocs.yml b/mkdocs.yml index 10295acfa..d851203f1 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -106,8 +106,9 @@ nav: - Make Your Own Plugin: 'features/plugins/make_your_own.md' - Using official ChatGPT Plugins: 'features/plugins/chatgpt_plugins_openapi.md' - Automated Moderation: 'features/mod_system.md' - - Manage Your Database: 'features/manage_your_database.md' - Token Usage: 'features/token_usage.md' + - Manage Your Database: 'features/manage_your_database.md' + - PandoraNext Deployment Guide: 'features/pandoranext.md' - Third-Party Tools: 'features/third_party.md' - Proxy: 'features/proxy.md' - Bing Jailbreak: 'features/bing_jailbreak.md'