Upload app.py
Browse files
app.py
CHANGED
|
@@ -13,11 +13,22 @@ from langchain_ollama import ChatOllama
|
|
| 13 |
|
| 14 |
|
| 15 |
# 生成聊天界面,包括工具
|
| 16 |
-
|
| 17 |
-
|
|
|
|
|
|
|
| 18 |
tools = [guest_info_tool, search_tool, weather_info_tool, hub_stats_tool]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
-
chat_with_tools = llm.bind_tools(tools)
|
| 21 |
# 生成 AgentState 和 Agent 图
|
| 22 |
class AgentState(TypedDict):
|
| 23 |
messages: Annotated[list[AnyMessage], add_messages]
|
|
|
|
| 13 |
|
| 14 |
|
| 15 |
# 生成聊天界面,包括工具
|
| 16 |
+
#本地加载ollama模型
|
| 17 |
+
# llm = ChatOllama(model="gpt-oss:20b", request_timeout=120.0)
|
| 18 |
+
# chat_with_tools = llm.bind_tools(tools)
|
| 19 |
+
#使用远程推理服务器
|
| 20 |
tools = [guest_info_tool, search_tool, weather_info_tool, hub_stats_tool]
|
| 21 |
+
# 初始化 Hugging Face 模型
|
| 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)
|
| 29 |
+
tools = [guest_info_tool]
|
| 30 |
+
chat_with_tools = chat.bind_tools(tools)
|
| 31 |
|
|
|
|
| 32 |
# 生成 AgentState 和 Agent 图
|
| 33 |
class AgentState(TypedDict):
|
| 34 |
messages: Annotated[list[AnyMessage], add_messages]
|