bstraehle commited on
Commit
ca824ea
1 Parent(s): da7c75f

Update rag_langgraph.py

Browse files
Files changed (1) hide show
  1. rag_langgraph.py +9 -2
rag_langgraph.py CHANGED
@@ -39,6 +39,13 @@ def agent_node(state, agent, name):
39
  result = agent.invoke(state)
40
  return {"messages": [HumanMessage(content=result["output"], name=name)]}
41
 
 
 
 
 
 
 
 
42
  def create_graph(topic, word_count):
43
  tavily_tool = TavilySearchResults(max_results=10)
44
 
@@ -92,10 +99,10 @@ def create_graph(topic, word_count):
92
  | JsonOutputFunctionsParser()
93
  )
94
 
95
- researcher_agent = create_agent(llm, [tavily_tool], system_prompt=f"Prioritizing research papers, research content on topic: {topic}.")
96
  researcher_node = functools.partial(agent_node, agent=researcher_agent, name="Researcher")
97
 
98
- writer_agent = create_agent(llm, [None], system_prompt=f"Write a {word_count}-word article on topic: {topic}. Add a references section with research papers.")
99
  writer_node = functools.partial(agent_node, agent=writer_agent, name="Writer")
100
 
101
  workflow = StateGraph(AgentState)
 
39
  result = agent.invoke(state)
40
  return {"messages": [HumanMessage(content=result["output"], name=name)]}
41
 
42
+ @tool
43
+ def today_tool(text: str) -> str:
44
+ """Returns today's date. Use this for any questions related to knowing today's date.
45
+ The input should always be an empty string, and this function will always return today's date.
46
+ Any date mathematics should occur outside this function."""
47
+ return str(date.today())
48
+
49
  def create_graph(topic, word_count):
50
  tavily_tool = TavilySearchResults(max_results=10)
51
 
 
99
  | JsonOutputFunctionsParser()
100
  )
101
 
102
+ researcher_agent = create_agent(llm, [tavily_tool], system_prompt=f"Prioritizing research papers, research content on topic: '{topic}'.")
103
  researcher_node = functools.partial(agent_node, agent=researcher_agent, name="Researcher")
104
 
105
+ writer_agent = create_agent(llm, [today_tool], system_prompt=f"Write a {word_count}-word article on topic: '{topic}'. Add a 'references' section with research papers. Add the 'current date' and 'author': Multi-AI-Agent System based on GPT-4o.")
106
  writer_node = functools.partial(agent_node, agent=writer_agent, name="Writer")
107
 
108
  workflow = StateGraph(AgentState)