RCaz commited on
Commit
a95e66e
·
verified ·
1 Parent(s): 813434f

added youtube tool after checking question for test

Browse files
Files changed (1) hide show
  1. agent.py +10 -7
agent.py CHANGED
@@ -49,32 +49,35 @@ def real_number_calculator(
49
 
50
 
51
 
52
- class CourseAgent:
53
  def __init__(self):
54
 
55
  # import code agent and basic tool from smolagent
56
- from smolagents import CodeAgent, OpenAIServerModel, DuckDuckGoSearchTool, FinalAnswerTool, VisitWebpageTool
57
 
58
  # import additional tool from langchain @ https://docs.langchain.com/oss/python/integrations/tools
59
  from langchain.agents import load_tools
60
  from smolagents import Tool
61
  wikipedia_tool = Tool.from_langchain(load_tools(["wikipedia"])[0])
 
62
 
63
  # import tools from MCP servers @ https://github.com/mcp
64
  from mcp import StdioServerParameters
65
  server_parameters = StdioServerParameters(command="uvx",
66
- args=["--quiet", "pubmedmcp@0.1.3"],
67
  env={"UV_PYTHON": "3.12", **os.environ},
68
  )
69
-
 
70
  model = OpenAIServerModel(model_id="gpt-4o")
71
- model = InferenceClientModel("Qwen/Qwen2.5-Coder-32B-Instruct")
72
  # Instantiate the agent
73
  self.agent = CodeAgent(
74
  tools=[real_number_calculator(), # homemade tool
75
  DuckDuckGoSearchTool(), # basic tools from smolagent
76
  VisitWebpageTool(),
77
- wikipedia_tool(top_k_results=3), # tool from langchain with extra parmaeters
 
78
  FinalAnswerTool()],
79
  model=model,
80
  max_steps=3,
@@ -85,4 +88,4 @@ def real_number_calculator(
85
  print(f"Agent received question (first 50 chars): {question[:50]}...")
86
  answer = self.agent.invoke(question)
87
  print(f"Agent returning his answer: {answer}")
88
- return fixed_answer
 
49
 
50
 
51
 
52
+ class TestAgent:
53
  def __init__(self):
54
 
55
  # import code agent and basic tool from smolagent
56
+ from smolagents import CodeAgent, OpenAIServerModel, DuckDuckGoSearchTool, FinalAnswerTool, VisitWebpageTool, MCPServerTool
57
 
58
  # import additional tool from langchain @ https://docs.langchain.com/oss/python/integrations/tools
59
  from langchain.agents import load_tools
60
  from smolagents import Tool
61
  wikipedia_tool = Tool.from_langchain(load_tools(["wikipedia"])[0])
62
+ wikipedia_tool.top_k_results=3
63
 
64
  # import tools from MCP servers @ https://github.com/mcp
65
  from mcp import StdioServerParameters
66
  server_parameters = StdioServerParameters(command="uvx",
67
+ args=["--quiet", "youtubeqa@0.2.1"],
68
  env={"UV_PYTHON": "3.12", **os.environ},
69
  )
70
+ youtube_tools = MCPServerTool(server_params=server_parameters)
71
+
72
  model = OpenAIServerModel(model_id="gpt-4o")
73
+ #model = InferenceClientModel("Qwen/Qwen2.5-Coder-32B-Instruct")
74
  # Instantiate the agent
75
  self.agent = CodeAgent(
76
  tools=[real_number_calculator(), # homemade tool
77
  DuckDuckGoSearchTool(), # basic tools from smolagent
78
  VisitWebpageTool(),
79
+ wikipedia_tool, # tool from langchain with extra parmaeters
80
+ youtube_tools, # tool from MCP server
81
  FinalAnswerTool()],
82
  model=model,
83
  max_steps=3,
 
88
  print(f"Agent received question (first 50 chars): {question[:50]}...")
89
  answer = self.agent.invoke(question)
90
  print(f"Agent returning his answer: {answer}")
91
+ return answer