Skip to main content

OpenAI function calling utility

Project description


from call_center import Agent

user = "pmeier"
agent = Agent(system_prompt=f"The current user is {user}")

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?"))
The available products for you are: Product3, Product5, Product7, and Product14.
['Product3', 'Product5', 'Product7', 'Product14']
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="")

import asyncio"What are the top three products?"))
The top three products are:
1. Product14
2. Product3
3. Product5
['Product14', 'Product3', 'Product5']

Project details

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 hashes)

Uploaded Source

Built Distribution

call_center-0.1.0-py3-none-any.whl (6.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page