Spaces:
Runtime error
Runtime error
Create FinalAnswerTool.py
Browse files- tools/FinalAnswerTool.py +20 -0
tools/FinalAnswerTool.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from smolagents import LiteLLMModel
|
| 2 |
+
from src.settings import Settings
|
| 3 |
+
from src.utils import InputTokenRateLimiter
|
| 4 |
+
from smolagents.tools import Tool
|
| 5 |
+
from litellm import completion
|
| 6 |
+
import os
|
| 7 |
+
|
| 8 |
+
settings = Settings()
|
| 9 |
+
print(settings.llm_model_id)
|
| 10 |
+
class FinalAnswerTool(Tool):
|
| 11 |
+
name = "final_answer"
|
| 12 |
+
description = "Provides the exact, final answer to the given question."
|
| 13 |
+
inputs = {
|
| 14 |
+
"answer": {"type": "string", "description": "The final, correctly formatted answer string."},
|
| 15 |
+
}
|
| 16 |
+
output_type = "string"
|
| 17 |
+
|
| 18 |
+
def forward(self, answer: str) -> str:
|
| 19 |
+
final_answer = f"FINAL ANSWER: {answer}"
|
| 20 |
+
return final_answer
|