JabrilJacobs commited on
Commit
ff02c25
·
verified ·
1 Parent(s): 8aac80d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +44 -6
app.py CHANGED
@@ -33,7 +33,50 @@ class BasicAgent:
33
  class NewAgent:
34
  def __init__(self):
35
  print("NewAgent initialized.")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
 
38
  # Initialize the web search tool
39
  search_tool = DuckDuckGoSearchRun()
@@ -76,12 +119,7 @@ class NewAgent:
76
  )
77
  builder.add_edge("tools", "assistant")
78
  alfred = builder.compile()
79
-
80
- def __call__(self, question: str) -> str:
81
- print(f"Agent received question (first 50 chars): {question[:50]}...")
82
- # fixed_answer = "This is a default answer."
83
- # print(f"Agent returning fixed answer: {fixed_answer}")
84
- # return fixed_answer
85
  messages = [HumanMessage(content=question)]
86
  response = alfred.invoke({"messages": messages})
87
 
 
33
  class NewAgent:
34
  def __init__(self):
35
  print("NewAgent initialized.")
36
+ # # Initialize the web search tool
37
+ # search_tool = DuckDuckGoSearchRun()
38
+ # # Initialize the Hub stats tool
39
+ # hub_stats_tool = Tool(
40
+ # name="get_hub_stats",
41
+ # func=get_hub_stats,
42
+ # description="Fetches the most downloaded model from a specific author on the Hugging Face Hub."
43
+ # )
44
+ # # Generate the chat interface, including the tools
45
+ # tools = [
46
+ # search_tool,
47
+ # # weather_info_tool,
48
+ # hub_stats_tool,
49
+ # ]
50
+ # llm = ChatOpenAI(model="gpt-4o")
51
+ # llm_with_tools = llm.bind_tools(tools, parallel_tool_calls=False)
52
 
53
+ # # Generate the AgentState and Agent graph
54
+ # class AgentState(TypedDict):
55
+ # messages: Annotated[list[AnyMessage], add_messages]
56
+ # def assistant(state: AgentState):
57
+ # sys_msg = SystemMessage(content=f"You are a general AI assistant. I will ask you a question. Report your thoughts, and finish your answer with the following template: FINAL ANSWER: [YOUR FINAL ANSWER]. YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated list of numbers and/or strings. If you are asked for a number, don't use comma to write your number neither use units such as $ or percent sign unless specified otherwise. If you are asked for a string, don't use articles, neither abbreviations (e.g. for cities), and write the digits in plain text unless specified otherwise. If you are asked for a comma separated list, apply the above rules depending of whether the element to be put in the list is a number or a string.")
58
+ # return {
59
+ # "messages": [llm_with_tools.invoke([sys_msg] + state["messages"])],
60
+ # }
61
+
62
+ # ## The graph
63
+ # builder = StateGraph(AgentState)
64
+ # # Define nodes: these do the work
65
+ # builder.add_node("assistant", assistant)
66
+ # builder.add_node("tools", ToolNode(tools))
67
+ # # Define edges: these determine how the control flow moves
68
+ # builder.add_edge(START, "assistant")
69
+ # builder.add_conditional_edges(
70
+ # "assistant",
71
+ # # If the latest message requires a tool, route to tools
72
+ # # Otherwise, provide a direct response
73
+ # tools_condition,
74
+ # )
75
+ # builder.add_edge("tools", "assistant")
76
+ # alfred = builder.compile()
77
+
78
+ def __call__(self, question: str) -> str:
79
+ print(f"Agent received question (first 50 chars): {question[:50]}...")
80
 
81
  # Initialize the web search tool
82
  search_tool = DuckDuckGoSearchRun()
 
119
  )
120
  builder.add_edge("tools", "assistant")
121
  alfred = builder.compile()
122
+
 
 
 
 
 
123
  messages = [HumanMessage(content=question)]
124
  response = alfred.invoke({"messages": messages})
125