SergeyO7 commited on
Commit
3cf8730
·
verified ·
1 Parent(s): 9e0ec52

Update agent.py

Browse files
Files changed (1) hide show
  1. agent.py +6 -6
agent.py CHANGED
@@ -3,8 +3,8 @@ import asyncio
3
 
4
  class MagAgent:
5
  def __init__(self):
6
- """Initialize the CodeAgent with search tools."""
7
- print("Initializing CodeAgent with search tools...")
8
  self.agent = CodeAgent(
9
  model=OpenAIServerModel(model_name="gpt-4o-mini"), # Use a lightweight model
10
  tools=[
@@ -12,18 +12,18 @@ class MagAgent:
12
  WikipediaSearchTool()
13
  ]
14
  )
15
- print("CodeAgent initialized.")
16
 
17
  async def __call__(self, question: str) -> str:
18
- """Process a question asynchronously using the CodeAgent."""
19
- print(f"CodeAgent received question (first 50 chars): {question[:50]}...")
20
  try:
21
  # Run the agent asynchronously
22
  response = await asyncio.to_thread(
23
  self.agent.run,
24
  prompt=f"Answer the following question accurately and concisely: {question}"
25
  )
26
- print(f"CodeAgent response: {response[:50]}...")
27
  return response
28
  except Exception as e:
29
  error_msg = f"Error processing question: {e}"
 
3
 
4
  class MagAgent:
5
  def __init__(self):
6
+ """Initialize the MagAgent with search tools."""
7
+ print("Initializing MagAgent with search tools...")
8
  self.agent = CodeAgent(
9
  model=OpenAIServerModel(model_name="gpt-4o-mini"), # Use a lightweight model
10
  tools=[
 
12
  WikipediaSearchTool()
13
  ]
14
  )
15
+ print("MagAgent initialized.")
16
 
17
  async def __call__(self, question: str) -> str:
18
+ """Process a question asynchronously using the MagAgent."""
19
+ print(f"MagAgent received question (first 50 chars): {question[:50]}...")
20
  try:
21
  # Run the agent asynchronously
22
  response = await asyncio.to_thread(
23
  self.agent.run,
24
  prompt=f"Answer the following question accurately and concisely: {question}"
25
  )
26
+ print(f"MagAgent response: {response[:50]}...")
27
  return response
28
  except Exception as e:
29
  error_msg = f"Error processing question: {e}"