Metadata-Version: 2.1
Name: call-center
Version: 0.1.0
Summary: OpenAI function calling utility
Author-email: Philip Meier <github.pmeier@posteo.de>
License: BSD 3-Clause License
        
        Copyright (c) 2023, Philip Meier
        
        Redistribution and use in source and binary forms, with or without
        modification, are permitted provided that the following conditions are met:
        
        1. Redistributions of source code must retain the above copyright notice, this
           list of conditions and the following disclaimer.
        
        2. Redistributions in binary form must reproduce the above copyright notice,
           this list of conditions and the following disclaimer in the documentation
           and/or other materials provided with the distribution.
        
        3. Neither the name of the copyright holder nor the names of its
           contributors may be used to endorse or promote products derived from
           this software without specific prior written permission.
        
        THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
        AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
        DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
        FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
        SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
        CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
        OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
        OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
        
Project-URL: Repository, https://github.com/pmeier/call-center
Classifier: Development Status :: 4 - Beta
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: docstring-parser
Requires-Dist: httpx
Requires-Dist: httpx-sse
Requires-Dist: pydantic >=2

# `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']
```
