diff --git a/README.md b/README.md index d9c74b23..3676bf12 100644 --- a/README.md +++ b/README.md @@ -47,22 +47,26 @@ pip install . ## Example ```python -from control_flow import ai_flow, ai_task, instructions, Task +from control_flow import Agent, Task, ai_flow, ai_task, instructions from pydantic import BaseModel + class Name(BaseModel): first_name: str last_name: str + @ai_task(user_access=True) def get_user_name() -> Name: pass -@ai_task + +@ai_task(agents=[Agent(name="poetry-bot", instructions="loves limericks")]) def write_poem_about_user(name: Name, interests: list[str]) -> str: """write a poem based on the provided `name` and `interests`""" pass + @ai_flow() def demo(): # set instructions that will be used for multiple tasks @@ -72,9 +76,7 @@ def demo(): # define an AI task imperatively interests = Task( - "ask user for three interests", - result_type=list[str], - user_access=True + "ask user for three interests", result_type=list[str], user_access=True ) interests.run_until_complete() @@ -84,6 +86,7 @@ def demo(): return poem + if __name__ == "__main__": demo() ``` diff --git a/src/control_flow/core/flow.py b/src/control_flow/core/flow.py index a8407c12..0fdd2cf2 100644 --- a/src/control_flow/core/flow.py +++ b/src/control_flow/core/flow.py @@ -72,7 +72,7 @@ def get_flow() -> Flow: """ flow: Flow | None = ctx.get("flow") if not flow: - raise ValueError("No flow found in context") + return Flow() return flow