Markiian Tsalyk commited on
Commit
887480a
·
1 Parent(s): 55eb2ba

Excel reader tool

Browse files
__pycache__/tools.cpython-313.pyc CHANGED
Binary files a/__pycache__/tools.cpython-313.pyc and b/__pycache__/tools.cpython-313.pyc differ
 
llama_index_agent.py CHANGED
@@ -88,6 +88,16 @@ class LlamaIndexAgent:
88
  name="fetch_historical_event_data",
89
  description="Use this to fetch data about historical event that occured in certain year such as Olympics games, Footbal games, NBA etc.",
90
  )
 
 
 
 
 
 
 
 
 
 
91
 
92
  # Create the agent
93
  self.agent = ReActAgent.from_tools(
@@ -102,6 +112,8 @@ class LlamaIndexAgent:
102
  transcript_youtube_tool,
103
  classify_fruit_vegitable_tool,
104
  fetch_historical_event_data_tool,
 
 
105
  ],
106
  llm=self.llm,
107
  verbose=verbose,
@@ -153,13 +165,13 @@ if __name__ == "__main__":
153
  # "Given this table defining * on the set S = {a, b, c, d, e}\n\n|*|a|b|c|d|e|\n|---|---|---|---|---|---|\n|a|a|b|c|b|d|\n|b|b|c|a|e|c|\n|c|c|a|b|b|a|\n|d|b|e|b|e|d|\n|e|d|b|a|d|c|\n\nprovide the subset of S involved in any possible counter-examples that prove * is not commutative. Provide your answer as a comma separated list of the elements in the set in alphabetical order.",
154
  # "What is the first name of the only Malko Competition recipient from the 20th Century (after 1977) whose nationality on record is a country that no longer exists?"
155
  # "Who are the pitchers with the number before and after Taishō Tamai's number as of July 2023? Give them to me in the form Pitcher Before, Pitcher After, use their last names only, in Roman characters.",
156
- "What country had the least number of athletes at the 1928 Summer Olympics? If there's a tie for a number of athletes, return the first in alphabetical order. Give the IOC country code as your answer."
157
  # "Where were the Vietnamese specimens described by Kuznetzov in Nedoshivina's 2010 paper eventually deposited? Just give me the city name without abbreviations.",
158
  # "How many at bats did the Yankee with the most walks in the 1977 regular season have that same season?",
159
  # "Who did the actor who played Ray in the Polish-language version of Everybody Loves Raymond play in Magda M.? Give only the first name.",
160
  # "Who nominated the only Featured Article on English Wikipedia about a dinosaur that was promoted in November 2016?",
161
  # "What is the final numeric output from the attached Python code? File name: f918266a-b3e0-4914-865d-4faa564f1aef.py",
162
- # """Examine the video at https://www.youtube.com/watch?v=1htKBjuUWec.\n\nWhat does Teal'c say in response to the question \"Isn't that hot?\"""",
163
  # "What is the surname of the equine veterinarian mentioned in 1.E Exercises from the chemistry materials licensed by Marisa Alviar-Agnew & Henry Agnew under the CK-12 license in LibreText's Introductory Chemistry materials as compiled 08/21/2023?",
164
  # """
165
  # I'm making a grocery list for my mom, but she's a professor of botany and she's a real stickler when it comes to categorizing things. I need to add different foods to different categories on the grocery list, but if I make a mistake, she won't buy anything inserted in the wrong category. Here's the list I have so far:\n\nmilk, eggs, flour, whole bean coffee, Oreos, sweet potatoes, fresh basil, plums, green beans, rice, corn, bell pepper, whole allspice, acorns, broccoli, celery, zucchini, lettuce, peanuts\n\nI need to make headings for the fruits and vegetables. Could you please create a list of just the vegetables from my list? If you could do that, then I can figure out how to categorize the rest of the list into the appropriate categories. But remember that my mom is a real stickler, so make sure that no botanical fruits end up on the vegetable list, or she won't get them when she's at the store. Please alphabetize the list of vegetables, and place each item in a comma separated list.
 
88
  name="fetch_historical_event_data",
89
  description="Use this to fetch data about historical event that occured in certain year such as Olympics games, Footbal games, NBA etc.",
90
  )
91
+ read_excel_tool = FunctionTool.from_defaults(
92
+ fn=tools.read_excel,
93
+ name="read_excel",
94
+ description="Use this to read excel file",
95
+ )
96
+ pandas_column_sum_tool = FunctionTool.from_defaults(
97
+ fn=tools.pandas_column_sum,
98
+ name="pandas_column_sum",
99
+ description="Use this to compute sum on pandas dataframe column",
100
+ )
101
 
102
  # Create the agent
103
  self.agent = ReActAgent.from_tools(
 
112
  transcript_youtube_tool,
113
  classify_fruit_vegitable_tool,
114
  fetch_historical_event_data_tool,
115
+ read_excel_tool,
116
+ pandas_column_sum_tool,
117
  ],
118
  llm=self.llm,
119
  verbose=verbose,
 
165
  # "Given this table defining * on the set S = {a, b, c, d, e}\n\n|*|a|b|c|d|e|\n|---|---|---|---|---|---|\n|a|a|b|c|b|d|\n|b|b|c|a|e|c|\n|c|c|a|b|b|a|\n|d|b|e|b|e|d|\n|e|d|b|a|d|c|\n\nprovide the subset of S involved in any possible counter-examples that prove * is not commutative. Provide your answer as a comma separated list of the elements in the set in alphabetical order.",
166
  # "What is the first name of the only Malko Competition recipient from the 20th Century (after 1977) whose nationality on record is a country that no longer exists?"
167
  # "Who are the pitchers with the number before and after Taishō Tamai's number as of July 2023? Give them to me in the form Pitcher Before, Pitcher After, use their last names only, in Roman characters.",
168
+ # "What country had the least number of athletes at the 1928 Summer Olympics? If there's a tie for a number of athletes, return the first in alphabetical order. Give the IOC country code as your answer."
169
  # "Where were the Vietnamese specimens described by Kuznetzov in Nedoshivina's 2010 paper eventually deposited? Just give me the city name without abbreviations.",
170
  # "How many at bats did the Yankee with the most walks in the 1977 regular season have that same season?",
171
  # "Who did the actor who played Ray in the Polish-language version of Everybody Loves Raymond play in Magda M.? Give only the first name.",
172
  # "Who nominated the only Featured Article on English Wikipedia about a dinosaur that was promoted in November 2016?",
173
  # "What is the final numeric output from the attached Python code? File name: f918266a-b3e0-4914-865d-4faa564f1aef.py",
174
+ """Examine the video at https://www.youtube.com/watch?v=1htKBjuUWec.\n\nWhat does Teal'c say in response to the question \"Isn't that hot?\"""",
175
  # "What is the surname of the equine veterinarian mentioned in 1.E Exercises from the chemistry materials licensed by Marisa Alviar-Agnew & Henry Agnew under the CK-12 license in LibreText's Introductory Chemistry materials as compiled 08/21/2023?",
176
  # """
177
  # I'm making a grocery list for my mom, but she's a professor of botany and she's a real stickler when it comes to categorizing things. I need to add different foods to different categories on the grocery list, but if I make a mistake, she won't buy anything inserted in the wrong category. Here's the list I have so far:\n\nmilk, eggs, flour, whole bean coffee, Oreos, sweet potatoes, fresh basil, plums, green beans, rice, corn, bell pepper, whole allspice, acorns, broccoli, celery, zucchini, lettuce, peanuts\n\nI need to make headings for the fruits and vegetables. Could you please create a list of just the vegetables from my list? If you could do that, then I can figure out how to categorize the rest of the list into the appropriate categories. But remember that my mom is a real stickler, so make sure that no botanical fruits end up on the vegetable list, or she won't get them when she's at the store. Please alphabetize the list of vegetables, and place each item in a comma separated list.
tools.py CHANGED
@@ -249,6 +249,34 @@ def trascript_youtube(video_id: str, **kwargs) -> list:
249
  return result.snippets
250
 
251
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
252
  def final_answer(query: str, answer: str, **kwargs) -> str:
253
  """
254
  Prepare the final answer for the user. It should be always used as a last step.
 
249
  return result.snippets
250
 
251
 
252
+ def read_excel(path: str, **kwargs) -> pd.DataFrame:
253
+ """
254
+ Reads xlsx file
255
+
256
+ Args:
257
+ path: path to xlsx file
258
+
259
+ Return:
260
+ Pandas dataframe
261
+ """
262
+ return pd.read_excel(path)
263
+
264
+
265
+ def pandas_column_sum(df: pd.DataFrame, column_name: str, **kwargs) -> float:
266
+ """
267
+ Computes sum on pandas dataframe column
268
+
269
+ Args:
270
+ df: Pandas dataframe
271
+ column_name: Name of the column
272
+
273
+ Return:
274
+ Sum of the column
275
+ """
276
+ df[column_name] = df[column_name].astype(float)
277
+ return df[column_name].sum()
278
+
279
+
280
  def final_answer(query: str, answer: str, **kwargs) -> str:
281
  """
282
  Prepare the final answer for the user. It should be always used as a last step.