Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rename user_access → interactive #259

Merged
merged 4 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def research_workflow() -> str:
topic = cf.Task(
"Work with the user to come up with a research topic",
result_type=ResearchTopic,
user_access=True,
interactive=True,
)

# Task 2: the default agent will create an outline based on the topic
Expand Down
8 changes: 4 additions & 4 deletions docs/concepts/agents.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ An agent has the following key properties:
- `instructions`: Specific instructions or guidelines for the agent to follow during task execution. These instructions are private and not shared with other agents.
- `tools`: A list of tools available to the agent. Tools are Python functions that the agent can call to perform specific actions or computations.
- `model`: A LangChain model that powers the agent responses.
- `user_access`: Indicates whether the agent has access to user interactions. If set to `True`, the agent will be provided with the `talk_to_user` tool to communicate with users.
- `interactive`: Indicates whether the agent has access to user interactions. If set to `True`, the agent will be provided with a tool for interacting with users on the command line.

These properties help define the agent's characteristics, behavior, and capabilities within the flow.

Expand Down Expand Up @@ -76,16 +76,16 @@ For a full guide on how to use LLMs in ControlFlow, including changing the defau

## User Access and Interaction

Agents with the `user_access` flag set to `True` have the ability to interact with users using the `talk_to_user` tool. This tool allows agents to send messages to users and receive responses.
Agents with the `interactive` flag set to `True` have the ability to interact with users on the command line.

```python
from controlflow import Agent

agent = Agent(
name="Support Agent",
description="An AI agent that interacts with users",
user_access=True
interactive=True
)
```

In this example, we create an agent named "UserAssistant" with the `user_access` flag set to `True`. This agent will have access to the `talk_to_user` tool to communicate with users when necessary.
In this example, we create an agent named "UserAssistant" with the `interactive` flag set to `True`. This agent will have access to a tool to communicate with users on the CLI.
10 changes: 5 additions & 5 deletions docs/concepts/tasks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ from controlflow import Task
interests = Task(
objective="Ask user for three interests",
result_type=list[str],
user_access=True,
interactive=True,
instructions="Politely ask the user to provide three of their interests or hobbies."
)
```
Expand All @@ -29,7 +29,7 @@ The `@task` decorator provides a concise and intuitive way to define tasks using
```python
from controlflow import task

@task(user_access=True)
@task(interactive=True)
def get_user_name() -> str:
"Politely ask the user for their name."
pass
Expand Down Expand Up @@ -151,18 +151,18 @@ calculation_task = Task(

## Handling User Interaction

ControlFlow provides a built-in mechanism for tasks to interact with human users. By setting the `user_access` property to `True`, a task can indicate that it requires human input or feedback to be completed.
ControlFlow provides a built-in mechanism for tasks to interact with human users. By setting the `interactive` property to `True`, a task can indicate that it requires human input or feedback to be completed.

```python
feedback_task = Task(
objective="Collect user feedback on the new feature",
user_access=True,
interactive=True,
result_type=str,
instructions="Ask the user to provide their thoughts on the new feature.",
)
```

When a task with `user_access=True` is executed, the AI agents assigned to the task will be given access to a special `talk_to_user` tool. This tool allows the agents to send messages to the user and receive their responses, enabling a conversation between the AI and the human.
When a task with `interactive=True` is executed, the AI agents assigned to the task will be given access to a tool that allows them to interact with the user on the command line.

## Creating Task Dependencies and Subtasks

Expand Down
2 changes: 1 addition & 1 deletion docs/examples/agent-engineer.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def run_engineer():
or as little information as the user wants to share. Once you have
enough, write out a design document to complete the task.
""",
user_access=True,
interactive=True,
result_type=DesignDoc,
)

Expand Down
4 changes: 2 additions & 2 deletions docs/examples/rock-paper-scissors.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ user_helper = cf.Agent(
# Create tasks for getting the user's choice,
# the AI's choice, and reporting the score

@cf.task(user_access=True, agents=[user_helper])
@cf.task(interactive=True, agents=[user_helper])
def get_user_choice() -> ["rock", "paper", "scissors"]:
"""Ask the user to choose rock, paper, or scissors."""

@cf.task
def get_ai_choice() -> ["rock", "paper", "scissors"]:
"""Choose rock paper or scissors"""

@cf.task(user_access=True)
@cf.task(interactive=True)
def report_score(user_choice, ai_choice) -> bool:
"""
Tell the user if they won, the overall score,
Expand Down
2 changes: 1 addition & 1 deletion docs/guides/agentic-loop.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ ControlFlow addresses this need through the `instructions()` context manager. Wi
```python
import controlflow as cf

task = cf.Task("Get the user's name", user_acces=True)
task = cf.Task("Get the user's name", interactive=True)

with instructions("Talk like a pirate"):
task.run()
Expand Down
2 changes: 1 addition & 1 deletion docs/guides/why-tasks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def research_workflow():
topic = cf.Task(
"Generate a research topic",
result_type=ResearchTopic,
user_access=True
interactive=True
)
outline = cf.Task("Create an outline", context=dict(topic=topic))
draft = cf.Task("Write a first draft", context=dict(outline=outline))
Expand Down
6 changes: 3 additions & 3 deletions docs/guides/workflow-apis.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ with cf.Flow() as greeting_flow:
name_task = cf.Task(
"Get the user's name",
result_type=str,
user_access=True
interactive=True
)

greeting_task = cf.Task(
Expand All @@ -28,7 +28,7 @@ with cf.Flow() as greeting_flow:
greeting_flow.run()
```

Here, tasks are created by instantiating the `Task` class, allowing explicit specification of properties like `result_type`, `user_access`, and `context`.
Here, tasks are created by instantiating the `Task` class, allowing explicit specification of properties like `result_type`, `interactive`, and `context`.

<Note>

Expand All @@ -42,7 +42,7 @@ The functional API uses decorators to transform Python functions into ControlFlo
```python
import controlflow as cf

@cf.task(user_access=True)
@cf.task(interactive=True)
def get_user_name() -> str:
"Ask the user for their name"
pass
Expand Down
1 change: 0 additions & 1 deletion docs/mint.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@
"group": "Reference",
"pages": [
"reference/task-class",
"reference/task-decorator"
]
},
{
Expand Down
4 changes: 2 additions & 2 deletions docs/patterns/instructions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ ControlFlow addresses this need with the `instructions()` context manager. With
```python
import controlflow as cf

task = cf.Task("Get the user's name", user_access=True)
task = cf.Task("Get the user's name", interactive=True)

with cf.instructions("Talk like a pirate"):
task.run()
Expand Down Expand Up @@ -54,7 +54,7 @@ import controlflow as cf

@cf.flow
def guided_conversation_flow():
conversation = cf.Task("Have a conversation with the user", user_access=True)
conversation = cf.Task("Have a conversation with the user", interactive=True)

while conversation.is_incomplete():
if some_condition:
Expand Down
2 changes: 1 addition & 1 deletion docs/patterns/tools.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def format_results(results: list) -> str:
product_search_task = cf.Task(
"Find and summarize products matching the user's query",
tools=[search_database, format_results],
user_access=True
interactive=True
)
```

Expand Down
12 changes: 6 additions & 6 deletions docs/patterns/user-input.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@ ControlFlow agents are primarily designed to solve problems by working autonomou

By default, agents are not able to interact with users directly. To allow it, you need to explicitly enable user access, either at the task or agent level. If applied to a task, all assigned agents will be able to interact with the user. If applied to an agent, the agent will be able to interact with the user in all of its tasks.

When `user_access=True`, the agent is given a tool for that it can use to send messages to the user. The user can then respond to these messages, and the agent can use the responses to make decisions or perform actions. By default, ControlFlow collects inputs directly in your terminal, but input can also be sent remotely via the Prefect API.
When `interactive=True`, the agent is given a tool for that it can use to send messages to the user. The user can then respond to these messages, and the agent can use the responses to make decisions or perform actions. By default, ControlFlow collects inputs directly in your terminal, but input can also be sent remotely via the Prefect API.


### Basic Inputs

To enable user input for a task, set `user_access=True`:
To enable user input for a task, set `interactive=True`:

```python
import controlflow as cf

user_input_task = cf.Task(
"Get user's favorite color",
result_type=str,
user_access=True,
interactive=True,
)

color = user_input_task.run()
Expand All @@ -48,7 +48,7 @@ class UserPreferences(BaseModel):
preferences_task = cf.Task(
"Get user preferences",
result_type=UserPreferences,
user_access=True,
interactive=True,
)

preferences = preferences_task.run()
Expand All @@ -57,7 +57,7 @@ print(f"Hello, {preferences.name}!")

### Passing Inputs to Other Tasks

You will frequently need to collect user input in one task (with `user_access=True`) and process that input in another task. You can pass the user input to subsequent tasks using the `context` parameter:
You will frequently need to collect user input in one task (with `interactive=True`) and process that input in another task. You can pass the user input to subsequent tasks using the `context` parameter:

```python
import controlflow as cf
Expand All @@ -67,7 +67,7 @@ def interactive_research_flow():
topic_task = cf.Task(
"Get research topic from user",
result_type=str,
user_access=True,
interactive=True,
instructions="If the user doesn't provide a topic, suggest 'AI'.",
)

Expand Down
4 changes: 2 additions & 2 deletions docs/quickstart.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def dice_flow():
user_task = cf.Task(
"Ask the user how many dice to roll",
result_type=int,
user_access=True
interactive=True
)

# task 2: roll the dice
Expand Down Expand Up @@ -156,7 +156,7 @@ Here's what you learned today:
- **Tasks** are how you create goals for agents.
They have a `result_type` that determines the type of data they return.
They have a `context` that can include results of other tasks, enabling multi-step workflows.
If `tools` or `user_access` is provided, the agent can use them to complete the task.
If `tools` are provided, the agent can use them to complete the task.
- **Agents** are AI models that complete tasks and can be specialized with different capabilities, tools, instructions, and even LLM models.
Agents can be assigned to tasks.
- **Flows** can involve dynamic control flow like loops, based on eager task result.
Expand Down
20 changes: 14 additions & 6 deletions docs/reference/task-class.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,20 @@ Tools can be any valid Python functions that perform specific actions, computati
By providing relevant tools to a task, you empower the AI agents to tackle more complex problems and enhance their problem-solving abilities. The agents can invoke these tools as needed during the task execution process.
</ParamField>

<ParamField path="user_access" type="bool">
The `user_access` property indicates whether the task requires human interaction or input during its execution. It is a boolean flag that, when set to `True`, signifies that the task involves user communication.

When a task has `user_access` set to `True`, the AI agents are provided with a special `talk_to_user` tool that enables them to send messages to the user and receive responses. This allows for a conversational flow between the agents and the user, facilitating the exchange of information required for the task.

It's important to note that tasks with `user_access` enabled should be designed with care, considering the user experience and the clarity of the communication. The AI agents should provide clear instructions and prompts to guide the user in providing the necessary input.
<ParamField path="interactive" type="bool">
The `interactive` property indicates whether the task requires human interaction
or input during its execution. It is a boolean flag that, when set to `True`,
signifies that the task involves user communication via the CLI

When a task has `interactive` set to `True`, the AI agents are provided with a
special tool that enables them to interact with the user through the CLI. This
allows for a conversational flow between the agents and the user, facilitating the
exchange of information required for the task.

It's important to note that tasks with `interactive` enabled should be designed with
care, considering the user experience and the clarity of the communication. The AI
agents should provide clear instructions and prompts to guide the user in providing
the necessary input through the CLI.
</ParamField>

<ParamField path="depends_on" type="list[Task]">
Expand Down
Loading