Update agents/tools/ai_tools.py
Browse files- agents/tools/ai_tools.py +9 -11
agents/tools/ai_tools.py
CHANGED
|
@@ -55,7 +55,6 @@ class AITools():
|
|
| 55 |
|
| 56 |
file = client.files.upload(file=file_path)
|
| 57 |
|
| 58 |
-
###
|
| 59 |
while True:
|
| 60 |
media_file = client.files.get(name=file.name)
|
| 61 |
if media_file.state == "ACTIVE":
|
|
@@ -63,7 +62,6 @@ class AITools():
|
|
| 63 |
elif media_file.state == "FAILED":
|
| 64 |
raise RuntimeError("Media file processing failed")
|
| 65 |
time.sleep(1)
|
| 66 |
-
###
|
| 67 |
|
| 68 |
response = client.models.generate_content(
|
| 69 |
model=model,
|
|
@@ -75,7 +73,7 @@ class AITools():
|
|
| 75 |
)
|
| 76 |
)
|
| 77 |
|
| 78 |
-
result = response.text
|
| 79 |
print(f"๐ ๏ธ AITools: {tool_name}: result={result}")
|
| 80 |
return result
|
| 81 |
except Exception as e:
|
|
@@ -85,7 +83,7 @@ class AITools():
|
|
| 85 |
def _extract_execution_result(response):
|
| 86 |
for part in response.candidates[0].content.parts:
|
| 87 |
if part.code_execution_result is not None:
|
| 88 |
-
return part.code_execution_result.output
|
| 89 |
|
| 90 |
return None
|
| 91 |
|
|
@@ -118,7 +116,7 @@ class AITools():
|
|
| 118 |
)
|
| 119 |
)
|
| 120 |
|
| 121 |
-
result = response.text
|
| 122 |
print(f"๐ ๏ธ AITools: web_search_tool: result={result}")
|
| 123 |
return result
|
| 124 |
except Exception as e:
|
|
@@ -162,7 +160,7 @@ class AITools():
|
|
| 162 |
instruction=question,
|
| 163 |
url=url_str,
|
| 164 |
command_type="act" # TODO: act, extract, observe
|
| 165 |
-
)
|
| 166 |
|
| 167 |
print(f"๐ ๏ธ AITools: web_browser_tool: result={result}")
|
| 168 |
return result
|
|
@@ -248,7 +246,7 @@ class AITools():
|
|
| 248 |
thinking_level=THINKING_LEVEL_YOUTUBE_ANALYSIS
|
| 249 |
)
|
| 250 |
)
|
| 251 |
-
)
|
| 252 |
|
| 253 |
print(f"๐ ๏ธ AITools: youtube_analysis_tool: result={result}")
|
| 254 |
return result
|
|
@@ -299,7 +297,7 @@ class AITools():
|
|
| 299 |
)
|
| 300 |
)
|
| 301 |
|
| 302 |
-
result = response.text
|
| 303 |
print(f"๐ ๏ธ AITools: document_analysis_tool: result={result}")
|
| 304 |
return result
|
| 305 |
except Exception as e:
|
|
@@ -435,7 +433,7 @@ class AITools():
|
|
| 435 |
|
| 436 |
for part in response.parts:
|
| 437 |
if part.text is not None:
|
| 438 |
-
result = part.text
|
| 439 |
break
|
| 440 |
|
| 441 |
board = chess.Board(result) # FEN validation
|
|
@@ -498,7 +496,7 @@ class AITools():
|
|
| 498 |
|
| 499 |
for part in response.parts:
|
| 500 |
if part.text is not None:
|
| 501 |
-
result = part.text
|
| 502 |
break
|
| 503 |
|
| 504 |
print(f"๐ ๏ธ AITools: algebraic_notation_tool: result={result}")
|
|
@@ -537,7 +535,7 @@ class AITools():
|
|
| 537 |
)
|
| 538 |
)
|
| 539 |
|
| 540 |
-
result = response.text
|
| 541 |
print(f"๐ ๏ธ AITools: final_answer_tool: result={result}")
|
| 542 |
return result
|
| 543 |
except Exception as e:
|
|
|
|
| 55 |
|
| 56 |
file = client.files.upload(file=file_path)
|
| 57 |
|
|
|
|
| 58 |
while True:
|
| 59 |
media_file = client.files.get(name=file.name)
|
| 60 |
if media_file.state == "ACTIVE":
|
|
|
|
| 62 |
elif media_file.state == "FAILED":
|
| 63 |
raise RuntimeError("Media file processing failed")
|
| 64 |
time.sleep(1)
|
|
|
|
| 65 |
|
| 66 |
response = client.models.generate_content(
|
| 67 |
model=model,
|
|
|
|
| 73 |
)
|
| 74 |
)
|
| 75 |
|
| 76 |
+
result = response.text
|
| 77 |
print(f"๐ ๏ธ AITools: {tool_name}: result={result}")
|
| 78 |
return result
|
| 79 |
except Exception as e:
|
|
|
|
| 83 |
def _extract_execution_result(response):
|
| 84 |
for part in response.candidates[0].content.parts:
|
| 85 |
if part.code_execution_result is not None:
|
| 86 |
+
return part.code_execution_result.output
|
| 87 |
|
| 88 |
return None
|
| 89 |
|
|
|
|
| 116 |
)
|
| 117 |
)
|
| 118 |
|
| 119 |
+
result = response.text
|
| 120 |
print(f"๐ ๏ธ AITools: web_search_tool: result={result}")
|
| 121 |
return result
|
| 122 |
except Exception as e:
|
|
|
|
| 160 |
instruction=question,
|
| 161 |
url=url_str,
|
| 162 |
command_type="act" # TODO: act, extract, observe
|
| 163 |
+
)
|
| 164 |
|
| 165 |
print(f"๐ ๏ธ AITools: web_browser_tool: result={result}")
|
| 166 |
return result
|
|
|
|
| 246 |
thinking_level=THINKING_LEVEL_YOUTUBE_ANALYSIS
|
| 247 |
)
|
| 248 |
)
|
| 249 |
+
)
|
| 250 |
|
| 251 |
print(f"๐ ๏ธ AITools: youtube_analysis_tool: result={result}")
|
| 252 |
return result
|
|
|
|
| 297 |
)
|
| 298 |
)
|
| 299 |
|
| 300 |
+
result = response.text
|
| 301 |
print(f"๐ ๏ธ AITools: document_analysis_tool: result={result}")
|
| 302 |
return result
|
| 303 |
except Exception as e:
|
|
|
|
| 433 |
|
| 434 |
for part in response.parts:
|
| 435 |
if part.text is not None:
|
| 436 |
+
result = part.text
|
| 437 |
break
|
| 438 |
|
| 439 |
board = chess.Board(result) # FEN validation
|
|
|
|
| 496 |
|
| 497 |
for part in response.parts:
|
| 498 |
if part.text is not None:
|
| 499 |
+
result = part.text
|
| 500 |
break
|
| 501 |
|
| 502 |
print(f"๐ ๏ธ AITools: algebraic_notation_tool: result={result}")
|
|
|
|
| 535 |
)
|
| 536 |
)
|
| 537 |
|
| 538 |
+
result = response.text
|
| 539 |
print(f"๐ ๏ธ AITools: final_answer_tool: result={result}")
|
| 540 |
return result
|
| 541 |
except Exception as e:
|