JabrilJacobs commited on
Commit
56e6de5
·
verified ·
1 Parent(s): 1083fc0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -9
app.py CHANGED
@@ -36,6 +36,16 @@ class NewAgent:
36
  def __call__(self, question: str, file_name: str = "", task_id: str = "") -> str:
37
  print(f"Agent received question (first 50 chars): {question[:50]}...")
38
 
 
 
 
 
 
 
 
 
 
 
39
  # Initialize the web search tool
40
  search_tool = DuckDuckGoSearchRun()
41
  # Initialize the Hub stats tool
@@ -56,20 +66,12 @@ class NewAgent:
56
  func=read_excel_file,
57
  description="Reads an Excel file and returns structured information about its contents."
58
  )
59
- # Initialize the Download File tool
60
- download_file_tool = Tool(
61
- name="download_file",
62
- func=download_file,
63
- description="Downloads a file associated with a task_id. Input should be 'task_id,filename'"
64
- )
65
  # Generate the chat interface, including the tools
66
  tools = [
67
  search_tool,
68
- # weather_info_tool,
69
  hub_stats_tool,
70
  image_analysis_tool,
71
  read_excel_tool,
72
- download_file_tool,
73
  ]
74
  # llm = ChatOpenAI(model="gpt-4o")
75
  llm = ChatOpenAI(model="gpt-4.1")
@@ -92,7 +94,9 @@ class NewAgent:
92
  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.
93
  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.
94
  Current task_id: {task_id}
95
- Current file (if any): {file_name}"""
 
 
96
  )
97
  return {
98
  "messages": [llm_with_tools.invoke([sys_msg] + state["messages"])],
 
36
  def __call__(self, question: str, file_name: str = "", task_id: str = "") -> str:
37
  print(f"Agent received question (first 50 chars): {question[:50]}...")
38
 
39
+ # Auto-download file if file_name and task_id are provided
40
+ local_file_path = ""
41
+ if file_name and task_id:
42
+ print(f"Auto-downloading file: {file_name} for task: {task_id}")
43
+ local_file_path = download_file(task_id, file_name)
44
+ if local_file_path.startswith("Error"):
45
+ print(f"File download failed: {local_file_path}")
46
+ else:
47
+ print(f"File downloaded successfully to: {local_file_path}")
48
+
49
  # Initialize the web search tool
50
  search_tool = DuckDuckGoSearchRun()
51
  # Initialize the Hub stats tool
 
66
  func=read_excel_file,
67
  description="Reads an Excel file and returns structured information about its contents."
68
  )
 
 
 
 
 
 
69
  # Generate the chat interface, including the tools
70
  tools = [
71
  search_tool,
 
72
  hub_stats_tool,
73
  image_analysis_tool,
74
  read_excel_tool,
 
75
  ]
76
  # llm = ChatOpenAI(model="gpt-4o")
77
  llm = ChatOpenAI(model="gpt-4.1")
 
94
  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.
95
  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.
96
  Current task_id: {task_id}
97
+ Current file (if any): {file_name}
98
+ Downloaded file path: {local_file_path}
99
+ """
100
  )
101
  return {
102
  "messages": [llm_with_tools.invoke([sys_msg] + state["messages"])],