Janneyffr commited on
Commit
9bfeee9
·
verified ·
1 Parent(s): 273bb54

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -10,7 +10,10 @@ from tools import search_tool, weather_info_tool, hub_stats_tool, guest_info_too
10
  from retriever import docs
11
 
12
  from langchain_ollama import ChatOllama
13
-
 
 
 
14
 
15
  # 生成聊天界面,包括工具
16
  #本地加载ollama模型
@@ -22,7 +25,7 @@ tools = [guest_info_tool, search_tool, weather_info_tool, hub_stats_tool]
22
  # 生成聊天界面,包括工具
23
  llm = HuggingFaceEndpoint(
24
  repo_id="Qwen/Qwen2.5-Coder-32B-Instruct",
25
- # huggingfacehub_api_token="YOUR-KES",暂不需要
26
  )
27
 
28
  chat = ChatHuggingFace(llm=llm, verbose=True)
 
10
  from retriever import docs
11
 
12
  from langchain_ollama import ChatOllama
13
+ import os
14
+ HF_TOKEN = os.environ.get("HF_TOKEN")
15
+ if HF_TOKEN is None:
16
+ raise RuntimeError("⚠️ 没有找到 HF_TOKEN,请先在 Spaces 的 Variables and secrets 添加。")
17
 
18
  # 生成聊天界面,包括工具
19
  #本地加载ollama模型
 
25
  # 生成聊天界面,包括工具
26
  llm = HuggingFaceEndpoint(
27
  repo_id="Qwen/Qwen2.5-Coder-32B-Instruct",
28
+ huggingfacehub_api_token=HF_TOKEN,
29
  )
30
 
31
  chat = ChatHuggingFace(llm=llm, verbose=True)