requirements.txt clean up

pull/307/head
Kye 1 year ago committed by Zack
parent 9fce25b5d2
commit 03e482f0cb

@ -135,8 +135,8 @@ def parse_done_token(response: str) -> bool:
class Flow:
"""
Flow is a chain like structure from langchain that provides the autonomy to language models
to generate sequential responses.
Flow is the structure that provides autonomy to any llm in a reliable and effective fashion.
The flow structure is designed to be used with any llm and provides the following features:
Features:
* Interactive, AI generates, then user input

@ -117,15 +117,7 @@ class SequentialWorkflow:
dashboard: bool = False
def add(
<<<<<<< HEAD
self,
agent: Union[Callable, Agent],
task: Optional[str] = None,
*args,
**kwargs,
=======
self, task: str, flow: Union[Callable, Flow], *args, **kwargs
>>>>>>> 49c7b97c (code quality fixes: line length = 80)
) -> None:
"""
Add a task to the workflow.
@ -188,21 +180,11 @@ class SequentialWorkflow:
),
)
def remove_task(self, task: str) -> None:
def remove_task(self, task_description: str) -> None:
"""Remove tasks from sequential workflow"""
try:
self.tasks = [
task
for task in self.tasks
if task.description != task
]
except Exception as error:
print(
colored(
f"Error removing task from workflow: {error}",
"red",
),
)
self.tasks = [
task for task in self.tasks if task.description != task_description
]
def update_task(self, task: str, **updates) -> None:
"""
@ -515,15 +497,9 @@ class SequentialWorkflow:
# Ensure that 'task' is provided in the kwargs
if "task" not in task.kwargs:
raise ValueError(
<<<<<<< HEAD
"The 'task' argument is required"
" for the Agent agent execution"
f" in '{task.description}'"
=======
"The 'task' argument is required for the"
" Flow flow execution in"
f" '{task.description}'"
>>>>>>> 49c7b97c (code quality fixes: line length = 80)
)
# Separate the 'task' argument from other kwargs
flow_task_arg = task.kwargs.pop("task")
@ -575,28 +551,6 @@ class SequentialWorkflow:
ValueError: If a Agent instance is used as a task and the 'task' argument is not provided.
"""
<<<<<<< HEAD
try:
for _ in range(self.max_loops):
for task in self.tasks:
# Check if the current task can be executed
if task.result is None:
# Check if the agent is a Agent and a 'task' argument is needed
if isinstance(task.agent, Agent):
# Ensure that 'task' is provided in the kwargs
if "task" not in task.kwargs:
raise ValueError(
"The 'task' argument is required"
" for the Agent agent execution"
f" in '{task.description}'"
)
# Separate the 'task' argument from other kwargs
flow_task_arg = task.kwargs.pop("task")
task.result = await task.agent.arun(
flow_task_arg,
*task.args,
**task.kwargs,
=======
for _ in range(self.max_loops):
for task in self.tasks:
# Check if the current task can be executed
@ -608,7 +562,6 @@ class SequentialWorkflow:
raise ValueError(
"The 'task' argument is required for the Flow"
f" flow execution in '{task.description}'"
>>>>>>> 49c7b97c (code quality fixes: line length = 80)
)
else:
# If it's not a Agent instance, call the agent directly
@ -616,39 +569,8 @@ class SequentialWorkflow:
*task.args, **task.kwargs
)
<<<<<<< HEAD
# Pass the result as an argument to the next task if it exists
next_task_index = self.tasks.index(task) + 1
if next_task_index < len(self.tasks):
next_task = self.tasks[next_task_index]
if isinstance(next_task.agent, Agent):
# For Agent flows, 'task' should be a keyword argument
next_task.kwargs["task"] = task.result
else:
# For other callable flows, the result is added to args
next_task.args.insert(0, task.result)
# Autosave the workflow state
if self.autosave:
self.save_workflow_state(
"sequential_workflow_state.json"
)
except Exception as e:
print(
colored(
(
"Error initializing the Sequential workflow:"
f" {e} try optimizing your inputs like the"
" agent class and task description"
),
"red",
attrs=["bold", "underline"],
)
)
=======
# Autosave the workflow state
if self.autosave:
self.save_workflow_state(
"sequential_workflow_state.json"
)
>>>>>>> 49c7b97c (code quality fixes: line length = 80)

Loading…
Cancel
Save