Skip to content

Commit 04788c5

Browse files
author
Dhivya-Bharathy
committed
Update model examples to use new clean format with praisonaiagents.Agent
1 parent e84191a commit 04788c5

File tree

2 files changed

+32
-53
lines changed

2 files changed

+32
-53
lines changed
Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,12 @@
11
import asyncio
22
from praisonaiagents import Agent
33

4-
async def main():
5-
agent = Agent(
6-
instructions="You are a helpful assistant",
7-
llm="gemini/gemini-1.5-flash-8b",
8-
self_reflect=True,
9-
verbose=True
10-
)
4+
agent = Agent(
5+
instructions="You are a helpful assistant",
6+
llm="gemini/gemini-1.5-flash-8b",
7+
self_reflect=True,
8+
verbose=True
9+
)
1110

12-
# Use achat instead of start/chat for async operation
13-
response = await agent.achat("Why sky is Blue in 1000 words?")
14-
print(response)
15-
16-
if __name__ == "__main__":
17-
# Run the async main function
18-
asyncio.run(main())
11+
# Use achat instead of start/chat for async operation
12+
response = asyncio.run(agent.achat("Why sky is Blue in 1000 words?"))

examples/python/models/grok/grok_basic_example.py

Lines changed: 24 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,44 +2,29 @@
22
Basic example of using Grok model in PraisonAI
33
"""
44

5-
from praisonai import PraisonAI
5+
from praisonaiagents import Agent
66

7-
def main():
8-
# Initialize PraisonAI with Grok model
9-
praison = PraisonAI(
10-
model="grok",
11-
api_key="your-grok-api-key-here" # Replace with your actual Grok API key
12-
)
13-
14-
# Create a simple agent
15-
agent = praison.create_agent(
16-
name="Grok Agent",
17-
description="A basic agent using Grok model"
18-
)
19-
20-
# Example conversation
21-
response = agent.run("Hello! Can you explain quantum computing in simple terms?")
22-
print("Agent Response:", response)
23-
24-
# Example with mathematical reasoning
25-
math_task = """
26-
Solve this problem step by step:
27-
If a train travels at 60 mph for 2.5 hours, how far does it travel?
28-
"""
29-
30-
response = agent.run(math_task)
31-
print("\nMath Task Response:")
32-
print(response)
33-
34-
# Example with creative writing
35-
creative_task = """
36-
Write a short story about a robot learning to paint.
37-
Make it engaging and about 100 words.
38-
"""
39-
40-
response = agent.run(creative_task)
41-
print("\nCreative Task Response:")
42-
print(response)
7+
# Initialize Agent with Grok model
8+
agent = Agent(
9+
instructions="You are a helpful assistant",
10+
llm="xai/grok-beta",
11+
)
4312

44-
if __name__ == "__main__":
45-
main()
13+
# Example conversation
14+
response = agent.start("Hello! Can you explain quantum computing in simple terms?")
15+
16+
# Example with mathematical reasoning
17+
math_task = """
18+
Solve this problem step by step:
19+
If a train travels at 60 mph for 2.5 hours, how far does it travel?
20+
"""
21+
22+
response = agent.start(math_task)
23+
24+
# Example with creative writing
25+
creative_task = """
26+
Write a short story about a robot learning to paint.
27+
Make it engaging and about 100 words.
28+
"""
29+
30+
response = agent.start(creative_task)

0 commit comments

Comments
 (0)