NitroSnow commited on
Commit
1cd334c
·
verified ·
1 Parent(s): 32ebe58

Delete Gala_Agent.py

Browse files
Files changed (1) hide show
  1. Gala_Agent.py +0 -58
Gala_Agent.py DELETED
@@ -1,58 +0,0 @@
1
- """
2
- LangGraph RAG Agent 整合所有必要组件
3
- """
4
- from typing import TypedDict, Annotated
5
- from langgraph.graph.message import add_messages
6
- from langchain_core.messages import AnyMessage, HumanMessage, AIMessage
7
- from langgraph.prebuilt import ToolNode
8
- from langgraph.graph import START, StateGraph
9
- from langgraph.prebuilt import tools_condition
10
- from langchain_huggingface import HuggingFaceEndpoint, ChatHuggingFace
11
- from langchain_openai import ChatOpenAI
12
- from tools import DuckDuckGoSearchRun, weather_info_tool, hub_stats_tool
13
- from retriever import guest_info_tool
14
-
15
- search_tool = DuckDuckGoSearchRun()
16
-
17
- DOUBAO_API_KEY = "cc556f72-0b09-4899-b9c3-ca2d2b4db8a5"
18
- DOUBAO_BASE_URL = "https://ark.cn-beijing.volces.com/api/v3"
19
- llm = ChatOpenAI(
20
- model="doubao-seed-1-8-251228",
21
- openai_api_key=DOUBAO_API_KEY,
22
- openai_api_base=DOUBAO_BASE_URL,
23
- )
24
- tools = [
25
- guest_info_tool, search_tool, weather_info_tool, hub_stats_tool,
26
- ]
27
- chat_with_tools = llm.bind_tools(tools)
28
-
29
- class AgentState(TypedDict):
30
- messages: Annotated[list[AnyMessage], add_messages]
31
-
32
- def assistant(state: AgentState):
33
- return {
34
- "messages": [chat_with_tools.invoke(state["messages"])]
35
- }
36
-
37
- builder = StateGraph(AgentState)
38
-
39
- builder.add_node("assistant", assistant)
40
- builder.add_node("tools", ToolNode(tools))
41
-
42
- builder.add_edge(START, "assistant")
43
- builder.add_conditional_edges(
44
- "assistant",
45
- tools_condition
46
- )
47
-
48
- builder.add_edge("tools", "assistant")
49
- alfred = builder.compile()
50
-
51
- # 示例1:获取嘉宾信息
52
- # response = alfred.invoke({"messages": "告诉我关于 Ada Lovelace的信息"})
53
-
54
-
55
- # 组合多工具应用
56
- response = alfred.invoke({"messages":"I need to speak with 'Dr. Nikola Tesla' about recent advancements in wireless energy. Can you help me prepare for this conversation?"})
57
- print("🎩 Alfred's Response:")
58
- print(response['messages'][-1].content)