alisamak commited on
Commit
62c5a8c
·
verified ·
1 Parent(s): a813a8a

Update tools.py

Browse files
Files changed (1) hide show
  1. tools.py +36 -6
tools.py CHANGED
@@ -21,9 +21,16 @@ import re
21
  @tool
22
  def extract_number_from_text(text: str) -> str:
23
  """
24
- Extract the most relevant number (e.g., counts or totals) from a given text.
25
- Use this after a Wikipedia or document summary to pull quantities like album counts, dates, etc.
 
 
 
 
 
 
26
  """
 
27
  print(f"🛠️ extract_number_from_text called with: {text[:80]}...")
28
  try:
29
  matches = re.findall(r"\b\d+\b", text)
@@ -36,9 +43,16 @@ def extract_number_from_text(text: str) -> str:
36
  @tool
37
  def search_wikipedia(query: str) -> str:
38
  """
39
- Search English Wikipedia and return a summary of the most relevant page.
40
- Use this for questions about people, dates, history, science, or named concepts.
 
 
 
 
 
 
41
  """
 
42
  print(f"🛠️ search_wikipedia called with: {query}")
43
  try:
44
  page = wikipedia.page(query)
@@ -54,8 +68,16 @@ def search_wikipedia(query: str) -> str:
54
  @tool
55
  def analyze_youtube_video(url: str) -> str:
56
  """
57
- Analyze a YouTube video using only its title and description via OpenAI/GPT.
 
 
 
 
 
 
 
58
  """
 
59
  # Extract YouTube URL from text if embedded
60
  match = re.search(r"https?://(?:www\.)?(?:youtube\.com/watch\?v=|youtu\.be/)[\w-]+", url)
61
  if match:
@@ -125,8 +147,16 @@ def fetch_video_metadata(video_id: str) -> str:
125
  @tool
126
  def check_commutativity_table(table_text: str) -> str:
127
  """
128
- Parse a multiplication table from markdown-like text and return the set of elements involved in counter-examples to commutativity.
 
 
 
 
 
 
 
129
  """
 
130
  try:
131
  lines = [line.strip() for line in table_text.strip().splitlines() if '|' in line]
132
  header = [e.strip() for e in lines[0].split('|')[1:] if e.strip()] # skip first column label
 
21
  @tool
22
  def extract_number_from_text(text: str) -> str:
23
  """
24
+ extract_number_from_text(text: str) -> str:
25
+ Extract the most relevant number (e.g., totals, counts, or dates) from a block of text.
26
+
27
+ Args:
28
+ text: A string containing the text from which to extract a number (e.g., Wikipedia summary or document).
29
+
30
+ Returns:
31
+ A string representing the extracted number or a message if no number is found.
32
  """
33
+
34
  print(f"🛠️ extract_number_from_text called with: {text[:80]}...")
35
  try:
36
  matches = re.findall(r"\b\d+\b", text)
 
43
  @tool
44
  def search_wikipedia(query: str) -> str:
45
  """
46
+ search_wikipedia(query: str) -> str:
47
+ Search English Wikipedia and return the summary of the most relevant article.
48
+
49
+ Args:
50
+ query: A query string about a person, event, scientific term, or concept.
51
+
52
+ Returns:
53
+ A concise summary of the corresponding Wikipedia page or a disambiguation notice.
54
  """
55
+
56
  print(f"🛠️ search_wikipedia called with: {query}")
57
  try:
58
  page = wikipedia.page(query)
 
68
  @tool
69
  def analyze_youtube_video(url: str) -> str:
70
  """
71
+ analyze_youtube_video(url: str) -> str:
72
+ Analyze a YouTube video based on its title and description metadata.
73
+
74
+ Args:
75
+ url: A full YouTube video URL.
76
+
77
+ Returns:
78
+ An analysis of the video's topic, audience, and themes using its metadata.
79
  """
80
+
81
  # Extract YouTube URL from text if embedded
82
  match = re.search(r"https?://(?:www\.)?(?:youtube\.com/watch\?v=|youtu\.be/)[\w-]+", url)
83
  if match:
 
147
  @tool
148
  def check_commutativity_table(table_text: str) -> str:
149
  """
150
+ check_commutativity_table(table_text: str) -> str:
151
+ Check if a binary operation table (in markdown-style) is commutative.
152
+
153
+ Args:
154
+ table_text: A markdown-style multiplication table with headers and rows.
155
+
156
+ Returns:
157
+ A comma-separated list of elements that violate commutativity, or a message if none found.
158
  """
159
+
160
  try:
161
  lines = [line.strip() for line in table_text.strip().splitlines() if '|' in line]
162
  header = [e.strip() for e in lines[0].split('|')[1:] if e.strip()] # skip first column label