-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathai_agent.py
33 lines (29 loc) · 980 Bytes
/
ai_agent.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from crewai import Agent, Task, Crew
import os
# Create a simple agent with direct model reference
math_agent = Agent(
role="Math Expert",
goal="Solve mathematical problems and explain the solutions clearly",
backstory="""You are an experienced mathematics teacher who excels at
breaking down complex problems into simple steps. You enjoy helping
students understand mathematical concepts.""",
allow_delegation=False,
verbose=True,
llm="ollama/gemma2:2b" # Directly specify the model
)
# Create a task for the agent
math_task = Task(
description="What is 15213123 * 7123123 and can you explain how you solved it?",
agent=math_agent,
expected_output="The answer with a clear explanation of the multiplication process."
)
# Create a crew with the agent and task
crew = Crew(
agents=[math_agent],
tasks=[math_task],
verbose=True
)
# Run the crew and get the result
result = crew.kickoff()
print("\nResult:")
print(result)