Skip to content

Commit e84191a

Browse files
author
Dhivya-Bharathy
committed
Update all provider examples to use new clean format with praisonaiagents.Agent
1 parent 29a39c6 commit e84191a

File tree

8 files changed

+215
-343
lines changed

8 files changed

+215
-343
lines changed

examples/python/providers/anthropic/anthropic_claude_example.py

Lines changed: 25 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2,46 +2,30 @@
22
Basic example of using Anthropic Claude with PraisonAI
33
"""
44

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

7-
def main():
8-
# Initialize PraisonAI with Anthropic Claude
9-
praison = PraisonAI(
10-
model="claude-3-5-sonnet-20241022",
11-
provider="anthropic",
12-
api_key="your-anthropic-api-key-here" # Replace with your actual Anthropic API key
13-
)
14-
15-
# Create a simple agent
16-
agent = praison.create_agent(
17-
name="Anthropic Claude Agent",
18-
description="A basic agent using Anthropic Claude model"
19-
)
20-
21-
# Example conversation
22-
response = agent.run("Hello! Can you help me with a writing task?")
23-
print("Agent Response:", response)
24-
25-
# Example with creative writing
26-
writing_task = """
27-
Write a short story about a time traveler who discovers
28-
they can only travel to moments of great historical significance.
29-
Make it engaging and about 200 words.
30-
"""
31-
32-
response = agent.run(writing_task)
33-
print("\nCreative Writing Response:")
34-
print(response)
35-
36-
# Example with reasoning
37-
reasoning_task = """
38-
Explain the concept of quantum entanglement in simple terms,
39-
and then discuss its potential applications in quantum computing.
40-
"""
41-
42-
response = agent.run(reasoning_task)
43-
print("\nReasoning Task Response:")
44-
print(response)
7+
# Initialize Agent with Anthropic Claude
8+
agent = Agent(
9+
instructions="You are a helpful assistant",
10+
llm="anthropic/claude-3-5-sonnet-20241022",
11+
)
4512

46-
if __name__ == "__main__":
47-
main()
13+
# Example conversation
14+
response = agent.start("Hello! Can you help me with a writing task?")
15+
16+
# Example with creative writing
17+
writing_task = """
18+
Write a short story about a time traveler who discovers
19+
they can only travel to moments of great historical significance.
20+
Make it engaging and about 200 words.
21+
"""
22+
23+
response = agent.start(writing_task)
24+
25+
# Example with reasoning
26+
reasoning_task = """
27+
Explain the concept of quantum entanglement in simple terms,
28+
and then discuss its potential applications in quantum computing.
29+
"""
30+
31+
response = agent.start(reasoning_task)

examples/python/providers/cohere/cohere_example.py

Lines changed: 32 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -2,51 +2,35 @@
22
Basic example of using Cohere with PraisonAI
33
"""
44

5-
from praisonai import PraisonAI
6-
7-
def main():
8-
# Initialize PraisonAI with Cohere
9-
praison = PraisonAI(
10-
model="command-r-plus",
11-
provider="cohere",
12-
api_key="your-cohere-api-key-here" # Replace with your actual Cohere API key
13-
)
14-
15-
# Create a simple agent
16-
agent = praison.create_agent(
17-
name="Cohere Agent",
18-
description="A basic agent using Cohere model"
19-
)
20-
21-
# Example conversation
22-
response = agent.run("Hello! Can you help me with a business analysis task?")
23-
print("Agent Response:", response)
24-
25-
# Example with business analysis
26-
business_task = """
27-
Analyze the potential market opportunities for a new AI-powered
28-
productivity tool targeting remote workers. Include market size,
29-
competitive landscape, and go-to-market strategy recommendations.
30-
"""
31-
32-
response = agent.run(business_task)
33-
print("\nBusiness Analysis Response:")
34-
print(response)
35-
36-
# Example with document summarization
37-
summary_task = """
38-
Summarize the key points from this business proposal:
39-
40-
Our company proposes to develop an AI-powered customer service chatbot
41-
that can handle 80% of common customer inquiries automatically. The system
42-
will integrate with existing CRM platforms and provide 24/7 support.
43-
Expected ROI is 300% within the first year, with implementation taking
44-
6 months and requiring a team of 5 developers.
45-
"""
46-
47-
response = agent.run(summary_task)
48-
print("\nDocument Summarization Response:")
49-
print(response)
50-
51-
if __name__ == "__main__":
52-
main()
5+
from praisonaiagents import Agent
6+
7+
# Initialize Agent with Cohere
8+
agent = Agent(
9+
instructions="You are a helpful assistant",
10+
llm="cohere/command-r-plus",
11+
)
12+
13+
# Example conversation
14+
response = agent.start("Hello! Can you help me with a business analysis task?")
15+
16+
# Example with business analysis
17+
business_task = """
18+
Analyze the potential market opportunities for a new AI-powered
19+
productivity tool targeting remote workers. Include market size,
20+
competitive landscape, and go-to-market strategy recommendations.
21+
"""
22+
23+
response = agent.start(business_task)
24+
25+
# Example with document summarization
26+
summary_task = """
27+
Summarize the key points from this business proposal:
28+
29+
Our company proposes to develop an AI-powered customer service chatbot
30+
that can handle 80% of common customer inquiries automatically. The system
31+
will integrate with existing CRM platforms and provide 24/7 support.
32+
Expected ROI is 300% within the first year, with implementation taking
33+
6 months and requiring a team of 5 developers.
34+
"""
35+
36+
response = agent.start(summary_task)

examples/python/providers/deepseek/deepseek_example.py

Lines changed: 33 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -2,52 +2,36 @@
22
Basic example of using DeepSeek with PraisonAI
33
"""
44

5-
from praisonai import PraisonAI
6-
7-
def main():
8-
# Initialize PraisonAI with DeepSeek
9-
praison = PraisonAI(
10-
model="deepseek-chat",
11-
provider="deepseek",
12-
api_key="your-deepseek-api-key-here" # Replace with your actual DeepSeek API key
13-
)
14-
15-
# Create a simple agent
16-
agent = praison.create_agent(
17-
name="DeepSeek Agent",
18-
description="A basic agent using DeepSeek model"
19-
)
20-
21-
# Example conversation
22-
response = agent.run("Hello! Can you help me with a mathematical problem?")
23-
print("Agent Response:", response)
24-
25-
# Example with mathematical reasoning
26-
math_task = """
27-
Solve this calculus problem step by step:
28-
Find the derivative of f(x) = x^3 * e^(2x) using the product rule.
29-
"""
30-
31-
response = agent.run(math_task)
32-
print("\nMathematical Reasoning Response:")
33-
print(response)
34-
35-
# Example with code optimization
36-
code_task = """
37-
Optimize this Python function for better performance:
38-
39-
def find_duplicates(arr):
40-
duplicates = []
41-
for i in range(len(arr)):
42-
for j in range(i+1, len(arr)):
43-
if arr[i] == arr[j] and arr[i] not in duplicates:
44-
duplicates.append(arr[i])
45-
return duplicates
46-
"""
47-
48-
response = agent.run(code_task)
49-
print("\nCode Optimization Response:")
50-
print(response)
51-
52-
if __name__ == "__main__":
53-
main()
5+
from praisonaiagents import Agent
6+
7+
# Initialize Agent with DeepSeek
8+
agent = Agent(
9+
instructions="You are a helpful assistant",
10+
llm="deepseek/deepseek-chat",
11+
)
12+
13+
# Example conversation
14+
response = agent.start("Hello! Can you help me with a mathematical problem?")
15+
16+
# Example with mathematical reasoning
17+
math_task = """
18+
Solve this calculus problem step by step:
19+
Find the derivative of f(x) = x^3 * e^(2x) using the product rule.
20+
"""
21+
22+
response = agent.start(math_task)
23+
24+
# Example with code optimization
25+
code_task = """
26+
Optimize this Python function for better performance:
27+
28+
def find_duplicates(arr):
29+
duplicates = []
30+
for i in range(len(arr)):
31+
for j in range(i+1, len(arr)):
32+
if arr[i] == arr[j] and arr[i] not in duplicates:
33+
duplicates.append(arr[i])
34+
return duplicates
35+
"""
36+
37+
response = agent.start(code_task)

examples/python/providers/google/google_gemini_example.py

Lines changed: 24 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2,45 +2,29 @@
22
Basic example of using Google Gemini with PraisonAI
33
"""
44

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

7-
def main():
8-
# Initialize PraisonAI with Google Gemini
9-
praison = PraisonAI(
10-
model="gemini-1.5-pro",
11-
provider="google",
12-
api_key="your-google-api-key-here" # Replace with your actual Google API key
13-
)
14-
15-
# Create a simple agent
16-
agent = praison.create_agent(
17-
name="Google Gemini Agent",
18-
description="A basic agent using Google Gemini model"
19-
)
20-
21-
# Example conversation
22-
response = agent.run("Hello! Can you help me with a research task?")
23-
print("Agent Response:", response)
24-
25-
# Example with research and analysis
26-
research_task = """
27-
Research and provide insights on the latest developments in
28-
renewable energy technology, focusing on solar and wind power innovations.
29-
"""
30-
31-
response = agent.run(research_task)
32-
print("\nResearch Task Response:")
33-
print(response)
34-
35-
# Example with multimodal capabilities (text-based for now)
36-
multimodal_task = """
37-
Describe how you would analyze an image of a city skyline
38-
and provide insights about urban development patterns.
39-
"""
40-
41-
response = agent.run(multimodal_task)
42-
print("\nMultimodal Analysis Response:")
43-
print(response)
7+
# Initialize Agent with Google Gemini
8+
agent = Agent(
9+
instructions="You are a helpful assistant",
10+
llm="google/gemini-1.5-pro",
11+
)
4412

45-
if __name__ == "__main__":
46-
main()
13+
# Example conversation
14+
response = agent.start("Hello! Can you help me with a research task?")
15+
16+
# Example with research and analysis
17+
research_task = """
18+
Research and provide insights on the latest developments in
19+
renewable energy technology, focusing on solar and wind power innovations.
20+
"""
21+
22+
response = agent.start(research_task)
23+
24+
# Example with multimodal capabilities (text-based for now)
25+
multimodal_task = """
26+
Describe how you would analyze an image of a city skyline
27+
and provide insights about urban development patterns.
28+
"""
29+
30+
response = agent.start(multimodal_task)

examples/python/providers/groq/kimi_with_groq_example.py

Lines changed: 16 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,21 @@
22
Basic example of using Kimi model with Groq provider in PraisonAI
33
"""
44

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

7-
def main():
8-
# Initialize PraisonAI with Kimi model using Groq provider
9-
praison = PraisonAI(
10-
model="kimi",
11-
provider="groq",
12-
api_key="your-groq-api-key-here" # Replace with your actual Groq API key
13-
)
14-
15-
# Create a simple agent
16-
agent = praison.create_agent(
17-
name="Kimi Groq Agent",
18-
description="A basic agent using Kimi model with Groq provider"
19-
)
20-
21-
# Example conversation
22-
response = agent.run("Hello! Can you help me with a coding task?")
23-
print("Agent Response:", response)
24-
25-
# Example with more complex task
26-
coding_task = """
27-
Write a Python function that calculates the factorial of a number.
28-
Include error handling and documentation.
29-
"""
30-
31-
response = agent.run(coding_task)
32-
print("\nCoding Task Response:")
33-
print(response)
7+
# Initialize Agent with Kimi model using Groq provider
8+
agent = Agent(
9+
instructions="You are a helpful assistant",
10+
llm="groq/kimi",
11+
)
3412

35-
if __name__ == "__main__":
36-
main()
13+
# Example conversation
14+
response = agent.start("Hello! Can you help me with a coding task?")
15+
16+
# Example with more complex task
17+
coding_task = """
18+
Write a Python function that calculates the factorial of a number.
19+
Include error handling and documentation.
20+
"""
21+
22+
response = agent.start(coding_task)

0 commit comments

Comments
 (0)