File size: 3,049 Bytes
4212b91
bdfe535
f46a1f2
 
4212b91
f46a1f2
4212b91
48355ac
f46a1f2
48355ac
 
 
 
 
 
 
 
 
 
f46a1f2
48355ac
 
 
 
 
 
 
 
 
 
f46a1f2
48355ac
 
 
 
 
 
 
 
 
 
f46a1f2
48355ac
 
 
 
 
 
 
 
 
 
f46a1f2
48355ac
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f46a1f2
48355ac
f46a1f2
4212b91
 
 
 
 
 
 
 
 
 
 
 
 
f46a1f2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
from bs4 import BeautifulSoup
from smolagents import tool, Tool
import markdownify
import openpyxl
import requests
import tabulate
import whisper

# Calculator Tools
@tool
def addition_tool(a:float, b:float)->float:
  """
  Takes two floating point numbers and returns the results of their addition.
  Args:
    a: First number of the addition operation
    b: Second number of the addition operation
  """
  return f"The result of addition between {a} and {b} is {a+b}"


@tool
def subtraction_tool(a:float, b:float)->float:
  """
  Takes two floating point numbers and returns the results of their subtraction.
  Args:
    a: First number of the subtraction operation
    b: Second number of the subtraction operation
  """
  return f"The result of subtraction between {a} and {b} is {a-b}"

 
@tool
def multiplication_tool(a:float, b:float)->float:
  """
  Takes two floating point numbers and returns the results of their addition.
  Args:
    a: First number of the multiplication operation
    b: Second number of the multiplication operation
  """
  return f"The result of multiplication between {a} and {b} is {a*b}"


@tool
def division_tool(a:float, b:float)->float:
  """
  Takes two floating point numbers and returns the results of their addition.
  Args:
    a: The dividend of the division operation
    b: The divisor of the division operation
  """
  return f"The result of division between {a} and {b} is {a/b}"


@tool
def exponent_tool(a:float, b:int)->float:
  """
  Takes a floating point number and an integer expoent and returns the results of their exponential operation.
  Args:
    a: Base number of the addition operation
    b: Exponent number of the addition operation
  """
  return f"The result of exponential operation between {a} and {b} is {a**b}"


@tool
def modulus_tool(a:int, b:int)->float:
  """Get the modulus of two numbers.
    Args:
        a: first int
        b: second int
  """
  return f"The result of modulus operation between {a} and {b} is {a%b}"
    

# Main Tools
@tool
def transcriber_tool(file_path:str)->str:
  """
  Takes the file path of an audio file and returns the transcribed text
  Args:
    file_path: File path of audio file
  """
  model = whisper.load_model("base")  # You can try "small" or "medium" for better accuracy

  # Transcribe the audio
  result = model.transcribe(file_path)["text"]

  # Print the text
  return f"The result of the transcription is: \n{result}"
    

@tool
def excel_loader_tool(file_path:str)->str:
  """
  For loading and reading the contents of an excel file.
  Args:
    file_path: File path of the excel file
  """

  def format_sheet(data):
    import tabulate
    return tabulate.tabulate(data[1:], headers=data[0], tablefmt="github")

  wb = openpyxl.load_workbook(file_path)
  ws = wb.active

  my_list = list()

  for value in ws.iter_rows(
      min_row=1, max_row=ws.max_row, min_col=1, max_col=ws.max_column, 
      values_only=True):
      my_list.append(value)
  
  return f"The result of the excel Loader is; \n\n{format_sheet(my_list)}"