-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcontext_variables.py
40 lines (30 loc) · 1.06 KB
/
context_variables.py
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
from anthill import Anthill, Agent
client = Anthill()
def instructions(context_variables):
name = context_variables.get("name", "User")
return f"You are a helpful agent. Greet the user by name ({name})."
def print_account_details(context_variables: dict):
"""Use this function to print account system account details"""
user_id = context_variables.get("user_id", None)
name = context_variables.get("name", None)
print(f"Account Details: {name} {user_id}")
return "Success"
agent = Agent(
name="Agent",
model="groq/llama-3.3-70b-versatile",
instructions=instructions,
functions=[print_account_details],
)
context_variables = {"name": "James", "user_id": 123}
response = client.run(
messages=[{"role": "user", "content": "Hi!"}],
agent=agent,
context_variables=context_variables,
)
print(response.messages[-1]["content"])
response = client.run(
messages=[{"role": "user", "content": "Print my account details!"}],
agent=agent,
context_variables=context_variables,
)
print(response.messages[-1]["content"])