-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathxai_grok_example.py
More file actions
41 lines (32 loc) · 1.16 KB
/
xai_grok_example.py
File metadata and controls
41 lines (32 loc) · 1.16 KB
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
34
35
36
37
38
39
40
41
"""
Basic example of using xAI Grok with PraisonAI
"""
from praisonaiagents import Agent
# Initialize Agent with xAI Grok
agent = Agent(
instructions="You are a helpful assistant",
llm="xai/grok-beta",
)
# Example conversation
response = agent.start("Hello! Can you help me with a complex reasoning task?")
# Example with complex reasoning
reasoning_task = """
Analyze this scenario step by step:
A company has 100 employees, 60% work remotely, 30% work hybrid, and 10% work in-office.
They want to implement a new AI tool that requires high-speed internet.
What are the challenges and solutions for this implementation?
"""
response = agent.start(reasoning_task)
# Example with creative problem solving
creative_task = """
Design a solution for reducing food waste in urban areas using AI technology.
Consider economic, environmental, and social factors.
Provide a step-by-step implementation plan.
"""
response = agent.start(creative_task)
# Example with humor and personality (Grok's specialty)
humor_task = """
Explain quantum physics using analogies that would make a 10-year-old laugh,
while still being scientifically accurate.
"""
response = agent.start(humor_task)