nanova commited on
Commit
021e3cd
·
1 Parent(s): ad44100

feat; read env

Browse files
Files changed (1) hide show
  1. app.py +16 -2
app.py CHANGED
@@ -1,9 +1,23 @@
1
  import gradio as gr
2
  import requests
3
  import json
 
 
4
 
5
- API_URL = "https://api.whaleflux.com/whaleflux/v1/model/deployment/enova-service-8fbf8085-2d13-4583/v1/chat/completions"
6
- API_TOKEN = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyaWQiOiJNVGMwTlRVMk5EVTROaTR4T0dNd01qUXpaVEJsTVRsaVpURmhPV1V5TkdVMk9UUTRabVppTjJNME16RmtaVGt4WkRjM056RmtPR1l4TTJFek1HRmpNek15WW1JMFlUTmpPVEUwIiwiaWF0IjoxNzQ1NTY0NTg2LCJleHAiOi0xLCJvcmdfaWQiOiIxMDAyNzA5NSIsInNjb3BlIjp7InBlcm1pc3Npb24iOm51bGx9LCJ0eXBlIjoiYXBpLXRva2VuIiwiTWFwQ2xhaW1zIjpudWxsfQ.fw6eZmOWr7gBqKd6X5duGao0MOimZ69Fv0oeBVWy0Gk"
 
 
 
 
 
 
 
 
 
 
 
 
7
 
8
  """
9
  For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
 
1
  import gradio as gr
2
  import requests
3
  import json
4
+ import os
5
+ from dotenv import load_dotenv
6
 
7
+ # 加载.env文件中的环境变量
8
+ load_dotenv()
9
+
10
+ # 从环境变量中读取配置
11
+ API_URL = os.getenv("API_URL")
12
+ API_TOKEN = os.getenv("API_TOKEN")
13
+
14
+ # 验证必要的环境变量
15
+ if not API_URL or not API_TOKEN:
16
+ raise ValueError("请确保设置了环境变量 API_URL 和 API_TOKEN")
17
+
18
+ print(f"[INFO] 服务启动配置:")
19
+ print(f"[INFO] API_URL: {API_URL}")
20
+ print(f"[INFO] API_TOKEN: {API_TOKEN[:10]}...{API_TOKEN[-10:]}") # 只显示token的前10位和后10位
21
 
22
  """
23
  For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference