KoRiF
introduce LangGraph-based QA-workflow with CodeAgent answers generation
3d98ed0
import os
from smolagents import CodeAgent, InferenceClientModel, FinalAnswerTool, DuckDuckGoSearchTool, WikipediaSearchTool, PythonInterpreterTool
from dotenv import load_dotenv
load_dotenv()
def gen_question_answer(question: str) -> str:
duck_duck_go_search_tool = DuckDuckGoSearchTool()
wikipedia_search_tool = WikipediaSearchTool()
final_answer_tool = FinalAnswerTool()
python_interpreter_tool = PythonInterpreterTool()
agent = CodeAgent(tools=[duck_duck_go_search_tool, wikipedia_search_tool, python_interpreter_tool, final_answer_tool], model=InferenceClientModel(), add_base_tools=True, additional_authorized_imports=["pandas"])
response = agent.run(question) # Use run() instead of query()
return str(response)