-
-
Notifications
You must be signed in to change notification settings - Fork 772
Expand file tree
/
Copy pathopenai_gpt4_example.py
More file actions
30 lines (23 loc) · 720 Bytes
/
openai_gpt4_example.py
File metadata and controls
30 lines (23 loc) · 720 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
"""
Basic example of using OpenAI GPT-4 with PraisonAI
"""
from praisonaiagents import Agent
# Initialize Agent with OpenAI GPT-4
agent = Agent(
instructions="You are a helpful assistant",
llm="openai/gpt-4o-mini",
)
# Example conversation
response = agent.start("Hello! Can you help me with a coding task?")
# Example with code generation
coding_task = """
Write a Python function that implements a binary search algorithm.
Include proper documentation and error handling.
"""
response = agent.start(coding_task)
# Example with analysis
analysis_task = """
Analyze the pros and cons of using microservices architecture
for a large-scale e-commerce application.
"""
response = agent.start(analysis_task)