OpenAI function calling utility
Project description
call-center
from call_center import Agent
user = "pmeier"
agent = Agent(system_prompt=f"The current user is {user}")
@agent.register
def get_products(user: str):
"""Get the available products for the user
:param user: User to get products for.
"""
return [f"Product{idx}" for idx in {"pmeier": [3, 5, 7, 14]}.get(user, [])]
print(agent.answer("What products are available for me?"))
print(get_products(user))
The available products for you are: Product3, Product5, Product7, and Product14.
['Product3', 'Product5', 'Product7', 'Product14']
@agent.register
def rank_products(products: list[str]):
"""Rank products by revenue.
:param products: List of products to rank.
"""
return sorted(products)
async def answer(prompt):
async for chunk in agent.aanswer_stream(prompt):
print(chunk, end="")
print()
import asyncio
asyncio.run(answer("What are the top three products?"))
print(rank_products(get_products(user))[:3])
The top three products are:
1. Product14
2. Product3
3. Product5
['Product14', 'Product3', 'Product5']
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
call-center-0.1.0.tar.gz
(7.7 kB
view details)
Built Distribution
File details
Details for the file call-center-0.1.0.tar.gz
.
File metadata
- Download URL: call-center-0.1.0.tar.gz
- Upload date:
- Size: 7.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 395bc82ac5483b4dc4d0d48b370408633bf0a6bdc706dcd152e15c5f8d3a95b2 |
|
MD5 | 567d4ec94627d61b0998a0a0907bc7c2 |
|
BLAKE2b-256 | 8079a8a336a1c3573fc28ecb6e905ecc6acb16cf59e73bbe9c47b7fc4874a8c8 |
File details
Details for the file call_center-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: call_center-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a7eb7b058a5d99a2bf592c23a7bce08f2427483b803e17fd5ce504503e308767 |
|
MD5 | 2695f3e2e363255bc784491a7adcfa68 |
|
BLAKE2b-256 | c8df84bbe4b805cfc247f4362251400282a0fe38eefe6c115640c813b15cc25b |