-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Expand file tree
/
Copy pathai21_example.py
More file actions
31 lines (24 loc) · 773 Bytes
/
ai21_example.py
File metadata and controls
31 lines (24 loc) · 773 Bytes
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
"""
Basic example of using AI21 with PraisonAI
"""
from praisonaiagents import Agent
# Initialize Agent with AI21
agent = Agent(
instructions="You are a helpful assistant",
llm="ai21/j2-ultra",
)
# Example conversation
response = agent.start("Hello! Can you help me with a writing task?")
# Example with creative writing
writing_task = """
Write a short story about a time traveler who discovers
they can only travel to moments of great historical significance.
Make it engaging and about 200 words.
"""
response = agent.start(writing_task)
# Example with reasoning
reasoning_task = """
Explain the concept of quantum entanglement in simple terms,
and then discuss its potential applications in quantum computing.
"""
response = agent.start(reasoning_task)