Update agents/tools/ai_tools.py
Browse files- agents/tools/ai_tools.py +20 -2
agents/tools/ai_tools.py
CHANGED
|
@@ -17,9 +17,10 @@ from agents.models.llms import (
|
|
| 17 |
LLM_CODE_GENERATION,
|
| 18 |
LLM_CODE_EXECUTION,
|
| 19 |
LLM_WEB_BROWSER,
|
|
|
|
| 20 |
THINKING_LEVEL_TOOLS
|
| 21 |
)
|
| 22 |
-
from agents.models.prompts import PROMPT_IMG_TO_FEN
|
| 23 |
from crewai.tools import tool
|
| 24 |
from crewai_tools import StagehandTool
|
| 25 |
from google import genai
|
|
@@ -440,4 +441,21 @@ class AITools():
|
|
| 440 |
|
| 441 |
return response.text
|
| 442 |
except Exception as e:
|
| 443 |
-
raise RuntimeError(f"Processing failed: {str(e)}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
LLM_CODE_GENERATION,
|
| 18 |
LLM_CODE_EXECUTION,
|
| 19 |
LLM_WEB_BROWSER,
|
| 20 |
+
LLM_FINAL_ANSWER,
|
| 21 |
THINKING_LEVEL_TOOLS
|
| 22 |
)
|
| 23 |
+
from agents.models.prompts import PROMPT_IMG_TO_FEN, PROMPT_FINAL_ANSWER
|
| 24 |
from crewai.tools import tool
|
| 25 |
from crewai_tools import StagehandTool
|
| 26 |
from google import genai
|
|
|
|
| 441 |
|
| 442 |
return response.text
|
| 443 |
except Exception as e:
|
| 444 |
+
raise RuntimeError(f"Processing failed: {str(e)}")
|
| 445 |
+
|
| 446 |
+
def get_final_answer(question, answer):
|
| 447 |
+
client = genai.Client(api_key=os.environ["GEMINI_API_KEY"])
|
| 448 |
+
|
| 449 |
+
prompt = PROMPT_FINAL_ANSWER.format(question=question, answer=answer)
|
| 450 |
+
|
| 451 |
+
response = client.models.generate_content(
|
| 452 |
+
model=LLM_FINAL_ANSWER,
|
| 453 |
+
contents=[prompt],
|
| 454 |
+
config=types.GenerateContentConfig(
|
| 455 |
+
thinking_config=types.ThinkingConfig(
|
| 456 |
+
thinking_level=THINKING_LEVEL_FINAL_ANSWER
|
| 457 |
+
)
|
| 458 |
+
)
|
| 459 |
+
)
|
| 460 |
+
|
| 461 |
+
return response.text
|