Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

updateProdEnv.ts 1.4 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
  1. import fs from "fs";
  2. const HF_DEPLOYMENT_TOKEN = process.env.HF_DEPLOYMENT_TOKEN; // token used for pushing to hub
  3. const SERPER_API_KEY = process.env.SERPER_API_KEY;
  4. const OPENID_CONFIG = process.env.OPENID_CONFIG;
  5. const MONGODB_URL = process.env.MONGODB_URL;
  6. const HF_TOKEN = process.env.HF_TOKEN ?? process.env.HF_ACCESS_TOKEN; // token used for API requests in prod
  7. const WEBHOOK_URL_REPORT_ASSISTANT = process.env.WEBHOOK_URL_REPORT_ASSISTANT; // slack webhook url used to get "report assistant" events
  8. const ADMIN_API_SECRET = process.env.ADMIN_API_SECRET;
  9. // Read the content of the file .env.template
  10. const PUBLIC_CONFIG = fs.readFileSync(".env.template", "utf8");
  11. // Prepend the content of the env variable SECRET_CONFIG
  12. const full_config = `${PUBLIC_CONFIG}
  13. MONGODB_URL=${MONGODB_URL}
  14. OPENID_CONFIG=${OPENID_CONFIG}
  15. SERPER_API_KEY=${SERPER_API_KEY}
  16. HF_TOKEN=${HF_TOKEN}
  17. WEBHOOK_URL_REPORT_ASSISTANT=${WEBHOOK_URL_REPORT_ASSISTANT}
  18. ADMIN_API_SECRET=${ADMIN_API_SECRET}
  19. `;
  20. // Make an HTTP POST request to add the space secrets
  21. fetch(`https://huggingface.co/api/spaces/huggingchat/chat-ui/secrets`, {
  22. method: "POST",
  23. body: JSON.stringify({
  24. key: "DOTENV_LOCAL",
  25. value: full_config,
  26. description: `Env variable for HuggingChat. Last updated ${new Date().toISOString()}`,
  27. }),
  28. headers: {
  29. Authorization: `Bearer ${HF_DEPLOYMENT_TOKEN}`,
  30. "Content-Type": "application/json",
  31. },
  32. });
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...