https://github.com/pmeier/call-center
OpenAI function calling utility
https://github.com/pmeier/call-center
Last synced: about 1 year ago
JSON representation
OpenAI function calling utility
- Host: GitHub
- URL: https://github.com/pmeier/call-center
- Owner: pmeier
- License: bsd-3-clause
- Created: 2023-12-01T08:45:23.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-12-01T08:47:28.000Z (over 2 years ago)
- Last Synced: 2025-03-08T18:46:41.115Z (over 1 year ago)
- Language: Python
- Homepage:
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# `call-center`
```python
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']
```
```python
@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']
```