Metadata-Version: 2.1
Name: funcchain
Version: 0.0.11
Summary: 🔖 write langchain prompts as python functions
License: MIT
Author: Shroominic
Author-email: contact@shroominic.com
Requires-Python: >=3.10,<4.0
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Requires-Dist: docstring-parser (>=0.15)
Requires-Dist: jinja2 (>=3,<4)
Requires-Dist: langchain (>=0.0.277)
Requires-Dist: openai (>=0.28)
Requires-Dist: pydantic (>=2,<3)
Requires-Dist: pydantic-settings (>=2,<3)
Requires-Dist: python-dotenv (>=1,<2)
Requires-Dist: rich (>=13)
Requires-Dist: tiktoken (>=0.4)
Description-Content-Type: text/markdown

# funcchain

🔖 write langchain prompts as python functions

## Demo

```python
from langchain.pydantic_v1 import BaseModel, Field
from typing import Union, List
from funcchain import chain

class Item(BaseModel):
    name: str = Field(..., description="Name of the item")
    description: str = Field(..., description="Description of the item")
    keywords: List[str] = Field(..., description="Keywords for the item")

class ShoppingList(BaseModel):
    """ List of items to buy """
    items: List[Item]
    store: str = Field(..., description="The store to buy the items from")

class TodoList(BaseModel):
    todos: List[Item]
    urgency: int = Field(..., description="The urgency of all tasks (1-10)")

def extract_list(user_input: str) -> Union[TodoList, ShoppingList]:
    """
    USER_INPUT:
    {user_input}

    The user input is either a shopping List or a todo list.
    """
    return chain()


user_input = input("Enter your list: ")
lst = extract_list(user_input)

if isinstance(lst, ShoppingList):
    print("Here is your Shopping List: ")
    for item in lst.items:
        print(f"{item.name}: {item.description}")
    print(f"You need to go to: {lst.store}")

if isinstance(lst, TodoList):
    print("Here is your Todo List: ")
    for item in lst.items:
        print(f"{item.name}: {item.description}")
    print(f"Urgency: {lst.urgency}")

```

