Skip to content

Commit

Permalink
Support multiple assistants for tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
jlowin committed Apr 8, 2024
1 parent b5e1056 commit bddb485
Show file tree
Hide file tree
Showing 9 changed files with 348 additions and 169 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ControlFlow is a framework for integrating AI agents into traditional workflows.
## Example

```python
from control_flow import ai_flow, ai_task, run_agent, instructions
from control_flow import ai_flow, ai_task, run_ai_task, instructions
from pydantic import BaseModel


Expand Down Expand Up @@ -40,7 +40,7 @@ def demo():
name = get_user_name()

# define an AI task inline
interests = run_agent("ask user for three interests", cast=list[str], user_access=True)
interests = run_ai_task("ask user for three interests", cast=list[str], user_access=True)

# set instructions for just the next task
with instructions("no more than 8 lines"):
Expand Down
8 changes: 4 additions & 4 deletions examples/documentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import control_flow
from control_flow import ai_flow, ai_task
from marvin.beta.assistants import Assistant, Thread
from marvin.tools.filesystem import ls, read, read_lines, write
from marvin.tools.filesystem import read, write

ROOT = Path(control_flow.__file__).parents[2]

Expand All @@ -23,7 +23,7 @@ def glob(pattern: str) -> list[str]:
You are an expert technical writer who writes wonderful documentation for
open-source tools and believes that documentation is a product unto itself.
""",
tools=[read, read_lines, ls, write, glob],
tools=[read, write, glob],
)


Expand All @@ -35,7 +35,7 @@ def examine_source_code(source_dir: Path, extensions: list[str]):
"""


@ai_task
@ai_task(model="gpt-3.5-turbo")
def read_docs(docs_dir: Path):
"""
Read all documentation in the docs dir and subdirectories, if any.
Expand All @@ -52,7 +52,7 @@ def write_docs(docs_dir: Path, instructions: str = None):
@ai_flow(assistant=assistant)
def docs_flow(instructions: str):
examine_source_code(ROOT / "src", extensions=[".py"])
read_docs(ROOT / "docs")
# read_docs(ROOT / "docs")
write_docs(ROOT / "docs", instructions=instructions)


Expand Down
4 changes: 2 additions & 2 deletions examples/readme_example.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from control_flow import ai_flow, ai_task, instructions, run_agent
from control_flow import ai_flow, ai_task, instructions, run_ai_task
from pydantic import BaseModel


Expand Down Expand Up @@ -26,7 +26,7 @@ def demo():
name = get_user_name()

# define an AI task inline
interests = run_agent(
interests = run_ai_task(
"ask user for three interests",
cast=list[str],
user_access=True,
Expand Down
4 changes: 3 additions & 1 deletion src/control_flow/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from .settings import settings

from .agent import ai_task, Agent, run_agent
from .agent import ai_task, Agent, run_ai_task
from .flow import ai_flow
from .instructions import instructions

from marvin.beta.assistants import Assistant
Loading

0 comments on commit bddb485

Please sign in to comment.