nsarrazin HF staff commited on
Commit
9c8ed38
1 Parent(s): 0410c78

Add instructions for running a copy of HuggingChat (#1026)

Browse files

* Add instructions for running a copy of HuggingChat

* wording

Files changed (1) hide show
  1. README.md +26 -13
README.md CHANGED
@@ -588,11 +588,11 @@ Chat UI can connect to the google Vertex API endpoints ([List of supported model
588
 
589
  To enable:
590
 
591
- 1. [Select](https://console.cloud.google.com/project) or [create](https://cloud.google.com/resource-manager/docs/creating-managing-projects#creating_a_project) a Google Cloud project.
592
- 1. [Enable billing for your project](https://cloud.google.com/billing/docs/how-to/modify-project).
593
- 1. [Enable the Vertex AI API](https://console.cloud.google.com/flows/enableapi?apiid=aiplatform.googleapis.com).
594
- 1. [Set up authentication with a service account](https://cloud.google.com/docs/authentication/getting-started)
595
- so you can access the API from your local workstation.
596
 
597
  The service account credentials file can be imported as an environmental variable:
598
 
@@ -749,7 +749,7 @@ You can preview the production build with `npm run preview`.
749
  The config file for HuggingChat is stored in the `.env.template` file at the root of the repository. It is the single source of truth that is used to generate the actual `.env.local` file using our CI/CD pipeline. See [updateProdEnv](https://github.com/huggingface/chat-ui/blob/cdb33a9583f5339ade724db615347393ef48f5cd/scripts/updateProdEnv.ts) for more details.
750
 
751
  > [!TIP]
752
- > If you want to make changes to model config for HuggingChat, you should do so against `.env.template`.
753
 
754
  We currently use the following secrets for deploying HuggingChat in addition to the `.env.template` above:
755
 
@@ -758,21 +758,34 @@ We currently use the following secrets for deploying HuggingChat in addition to
758
  - `OPENID_CONFIG`
759
  - `SERPER_API_KEY`
760
 
761
- They are defined as secrets in the repository.
762
 
763
- ### Testing config changes locally
764
 
765
- You can test the config changes locally by first creating an `.env.SECRET_CONFIG` file with the secrets defined above. Then you can run the following command to generate the `.env.local` file:
 
 
 
766
 
767
- ```bash
768
- npm run updateLocalEnv
 
 
 
 
 
 
 
 
 
 
769
  ```
770
 
771
- This will replace your `.env.local` file with the one that will be used in prod (simply taking `.env.template + .env.SECRET_CONFIG`).
772
 
773
  ### Populate database
774
 
775
- > [!WARNING]
776
  > The `MONGODB_URL` used for this script will be fetched from `.env.local`. Make sure it's correct! The command runs directly on the database.
777
 
778
  You can populate the database using faker data using the `populate` script:
 
588
 
589
  To enable:
590
 
591
+ 1. [Select](https://console.cloud.google.com/project) or [create](https://cloud.google.com/resource-manager/docs/creating-managing-projects#creating_a_project) a Google Cloud project.
592
+ 1. [Enable billing for your project](https://cloud.google.com/billing/docs/how-to/modify-project).
593
+ 1. [Enable the Vertex AI API](https://console.cloud.google.com/flows/enableapi?apiid=aiplatform.googleapis.com).
594
+ 1. [Set up authentication with a service account](https://cloud.google.com/docs/authentication/getting-started)
595
+ so you can access the API from your local workstation.
596
 
597
  The service account credentials file can be imported as an environmental variable:
598
 
 
749
  The config file for HuggingChat is stored in the `.env.template` file at the root of the repository. It is the single source of truth that is used to generate the actual `.env.local` file using our CI/CD pipeline. See [updateProdEnv](https://github.com/huggingface/chat-ui/blob/cdb33a9583f5339ade724db615347393ef48f5cd/scripts/updateProdEnv.ts) for more details.
750
 
751
  > [!TIP]
752
+ > If you want to make changes to the model config used in production for HuggingChat, you should do so against `.env.template`.
753
 
754
  We currently use the following secrets for deploying HuggingChat in addition to the `.env.template` above:
755
 
 
758
  - `OPENID_CONFIG`
759
  - `SERPER_API_KEY`
760
 
761
+ ### Running a copy of HuggingChat locally
762
 
763
+ If you want to run an exact copy of HuggingChat locally, you will need to do the following first:
764
 
765
+ 1. Create an [OAuth App on the hub](https://huggingface.co/settings/applications/new) with `openid profile email` permissions. Make sure to set the callback URL to something like `http://localhost:5173/chat/login/callback` which matches the right path for your local instance.
766
+ 2. Create a [HF Token](https://huggingface.co/settings/tokens) with your Hugging Face account. You will need a Pro account to be able to access some of the larger models available through HuggingChat.
767
+ 3. Create a free account with [serper.dev](https://serper.dev/) (you will get 2500 free search queries)
768
+ 4. Run an instance of mongoDB, however you want. (Local or remote)
769
 
770
+ You can then create a new `.env.SECRET_CONFIG` file with the following content
771
+
772
+ ```env
773
+ MONGODB_URL=<link to your mongo DB from step 4>
774
+ HF_TOKEN=<your HF token from step 2>
775
+ OPENID_CONFIG=`{
776
+ PROVIDER_URL: "https://huggingface.co",
777
+ CLIENT_ID: "<your client ID from step 1>",
778
+ CLIENT_SECRET: "<your client secret from step 1>",
779
+ }`
780
+ SERPER_API_KEY=<your serper API key from step 3>
781
+ MESSAGES_BEFORE_LOGIN=<can be any numerical value, or set to 0 to require login>
782
  ```
783
 
784
+ You can then run `npm run updateLocalEnv` in the root of chat-ui. This will create a `.env.local` file which combines the `.env.template` and the `.env.SECRET_CONFIG` file. You can then run `npm run dev` to start your local instance of HuggingChat.
785
 
786
  ### Populate database
787
 
788
+ > [!WARNING]
789
  > The `MONGODB_URL` used for this script will be fetched from `.env.local`. Make sure it's correct! The command runs directly on the database.
790
 
791
  You can populate the database using faker data using the `populate` script: