Spaces:
Runtime error
Runtime error
Update tools/final_answer.py
Browse files- tools/final_answer.py +8 -12
tools/final_answer.py
CHANGED
|
@@ -1,14 +1,10 @@
|
|
| 1 |
-
from
|
| 2 |
-
from
|
| 3 |
|
| 4 |
-
class FinalAnswerTool
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
inputs = {'answer': {'type': 'any', 'description': 'The final answer to the problem'}}
|
| 8 |
-
output_type = "any"
|
| 9 |
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
def __init__(self, *args, **kwargs):
|
| 14 |
-
self.is_initialized = False
|
|
|
|
| 1 |
+
from langchain.schema import HumanMessage, SystemMessage
|
| 2 |
+
from langchain.chat_models import ChatOpenAI
|
| 3 |
|
| 4 |
+
class FinalAnswerTool:
|
| 5 |
+
def init(self, model_name: str = "Qwen2.5-Coder"):
|
| 6 |
+
self.client = ChatOpenAI(model_name=model_name)
|
|
|
|
|
|
|
| 7 |
|
| 8 |
+
def __call__(self, conversation: list) -> str:
|
| 9 |
+
messages = [SystemMessage(content=conversation[0])] + [HumanMessage(content=m) for m in conversation[1:]]
|
| 10 |
+
return self.client(messages).content
|
|
|
|
|
|