LamiaYT commited on
Commit
46e21d3
·
1 Parent(s): db5169b
Files changed (1) hide show
  1. app.py +41 -20
app.py CHANGED
@@ -130,28 +130,37 @@ def extract_youtube_details(url: str) -> str:
130
 
131
  @tool
132
  def decode_reversed_text(text: str) -> str:
133
- """Decode reversed text."""
134
- try:
135
- if "ecnetnes siht dnatsrednu uoy fi" in text.lower():
136
- reversed_text = text[::-1]
137
- reversed_lower = reversed_text.lower()
138
- opposites = {
139
- "left": "right", "right": "left",
140
- "up": "down", "down": "up",
141
- "north": "south", "south": "north",
142
- "east": "west", "west": "east"
143
- }
144
- for key, value in opposites.items():
145
- if key in reversed_lower:
146
- return value
147
- return reversed_text
148
- return text[::-1]
149
- except Exception as e:
150
- return f"Text decoding error: {str(e)}"
151
 
152
  @tool
153
  def solve_advanced_math(problem: str) -> str:
154
- """Solve advanced math problems and commutativity tables."""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
155
  try:
156
  problem_lower = problem.lower()
157
  if "commutative" in problem_lower and "|" in problem:
@@ -209,7 +218,19 @@ def solve_advanced_math(problem: str) -> str:
209
 
210
  @tool
211
  def get_detailed_wikipedia(topic: str) -> str:
212
- """Get detailed Wikipedia information."""
 
 
 
 
 
 
 
 
 
 
 
 
213
  try:
214
  time.sleep(1)
215
  topic_clean = topic.replace(" ", "_").strip()
 
130
 
131
  @tool
132
  def decode_reversed_text(text: str) -> str:
133
+ """
134
+ Decode reversed text, optionally identifying directional opposites.
135
+
136
+ If the input appears to be written backward and contains known patterns, this tool reverses it
137
+ and checks for direction-related words (e.g., left/right) to return their opposites.
138
+
139
+ Args:
140
+ text (str): A string of text that may be written in reverse.
141
+
142
+ Returns:
143
+ str: The decoded text, possibly with directional opposites, or the original reversed string.
144
+ """
145
+
 
 
 
 
 
146
 
147
  @tool
148
  def solve_advanced_math(problem: str) -> str:
149
+ """
150
+ Solve advanced math problems, including commutative table checks and numeric computations.
151
+
152
+ This tool can:
153
+ - Detect which elements break commutativity in a given operation table.
154
+ - Extract and analyze chess notation for move-related questions.
155
+ - Compute arithmetic operations such as sum, average, product, and percentages from a text-based problem.
156
+
157
+ Args:
158
+ problem (str): A string describing a math-related or logic puzzle, operation table, or numeric question.
159
+
160
+ Returns:
161
+ str: The solution or explanation based on the problem type and extracted data.
162
+ """
163
+
164
  try:
165
  problem_lower = problem.lower()
166
  if "commutative" in problem_lower and "|" in problem:
 
218
 
219
  @tool
220
  def get_detailed_wikipedia(topic: str) -> str:
221
+ """
222
+ Get a detailed summary and metadata from Wikipedia for a given topic.
223
+
224
+ This tool first attempts to fetch a summary from Wikipedia's REST API.
225
+ If that fails, it uses the MediaWiki search API as a fallback to retrieve top matches.
226
+
227
+ Args:
228
+ topic (str): The topic to look up on Wikipedia.
229
+
230
+ Returns:
231
+ str: A formatted string with the topic title, summary extract, and page URL or search results.
232
+ """
233
+
234
  try:
235
  time.sleep(1)
236
  topic_clean = topic.replace(" ", "_").strip()