wangold / Swarm-readme-18.py
0 likes
0 forks
1 files
Last active
1 | def greet(name, age: int, location: str = "New York"): |
2 | """Greets the user. Make sure to get their name and age before calling. |
3 | |
4 | Args: |
5 | name: Name of the user. |
6 | age: Age of the user. |
7 | location: Best place on earth. |
8 | """ |
9 | print(f"Hello {name}, glad you are {age} in {location}!") |
wangold / Swarm-readme-17.sh
0 likes
0 forks
1 files
Last active
1 | Sales Agent |
2 | {'department': 'sales', 'user_name': 'John'} |
wangold / Swarm-readme-16.py
0 likes
0 forks
1 files
Last active
1 | sales_agent = Agent(name="Sales Agent") |
2 | |
3 | def talk_to_sales(): |
4 | print("Hello, World!") |
5 | return Result( |
6 | value="Done", |
7 | agent=sales_agent, |
8 | context_variables={"department": "sales"} |
9 | ) |
wangold / Swarm-readme-15.sh
0 likes
0 forks
1 files
Last active
1 | Sales Agent |
wangold / Swarm-readme-14.py
0 likes
0 forks
1 files
Last active
1 | sales_agent = Agent(name="Sales Agent") |
2 | |
3 | def transfer_to_sales(): |
4 | return sales_agent |
5 | |
6 | agent = Agent(functions=[transfer_to_sales]) |
7 | |
8 | response = client.run(agent, [{"role":"user", "content":"Transfer me to sales."}]) |
9 | print(response.agent.name) |
wangold / Swarm-readme-13.sh
0 likes
0 forks
1 files
Last active
1 | Hola, John! |
wangold / Swarm-readme-12.py
0 likes
0 forks
1 files
Last active
1 | def greet(context_variables, language): |
2 | user_name = context_variables["user_name"] |
3 | greeting = "Hola" if language.lower() == "spanish" else "Hello" |
4 | print(f"{greeting}, {user_name}!") |
5 | return "Done" |
6 | |
7 | agent = Agent( |
8 | functions=[print_hello] |
9 | ) |
wangold / Swarm-readme-11.sh
0 likes
0 forks
1 files
Last active
1 | Hi John, how can I assist you today? |
wangold / Swarm-readme-10.py
0 likes
0 forks
1 files
Last active
1 | def instructions(context_variables): |
2 | user_name = context_variables["user_name"] |
3 | return f"Help the user, {user_name}, do whatever they want." |
4 | |
5 | agent = Agent( |
6 | instructions=instructions |
7 | ) |
8 | response = client.run( |
9 | agent=agent, |
10 | messages=[{"role":"user", "content": "Hi!"}], |
wangold / Swarm-readme-9.py
0 likes
0 forks
1 files
Last active
1 | agent = Agent( |
2 | instructions="You are a helpful agent." |
3 | ) |