final_exam / tools /gaia_tool.py
VinogradovAI's picture
Update tools/gaia_tool.py
279cfc2 verified
Raw History Blame Contribute Delete
912 Bytes
from langchain_openai.chat_models import ChatOpenAI
from langchain.tools import BaseTool
from config import config
class GaiaQATool(BaseTool):
"""
Инструмент для ответов на вопросы GAIA Level 1.
"""
name: str = "gaia_level1_qa"
description: str = "Answer factoid questions from the GAIA knowledge base. Use for questions like 'How many albums…'', 'Who nominated…'', 'What is the surname…'', 'What was the award number…'' or any direct trivia queries."
def _run(self, question: str) -> str:
llm = ChatOpenAI(
model_name=config.OPENAI_MODEL,
openai_api_key=config.OPENAI_API_KEY,
temperature=0
)
prompt = f"Answer GAIA Level 1 question: {question}"
return llm.invoke(prompt)
async def _arun(self, question: str) -> str:
raise NotImplementedError("Async not supported.")