The ReflectWorkflow
class is a specialized workflow implementation in the ReXia.AI framework. It extends the BaseWorkflow
class and implements a reflective approach to task solving, utilizing various components such as planning, tool usage, work execution, and finalization. This workflow is designed to be used within an Agent instance.
llm
: The language model used by the workflow.task
: The task that the workflow is designed to perform.verbose
: A flag used for enabling verbose mode.channel
: The collaboration channel for the workflow.plan
: The plan component of the workflow.tool
: The tool component of the workflow.work
: The work component of the workflow.finalise
: The finalise component of the workflow.
Initializes a ReflectWorkflow instance.
Parameters:
llm
: The language model used by the workflow.task
: The task assigned to the workflow.verbose
: A flag for enabling verbose mode. Defaults toFalse
.max_attempts
: The maximum number of attempts to get a valid response from the model. Defaults to3
.
Internal method that executes the main workflow process.
Public method to initiate the workflow execution.
Here's an example of how to use the ReflectWorkflow
class with an Agent:
from rexia_ai.workflows import ReflectWorkflow
from rexia_ai.agent import Agent
# Initialize your language model
llm = ... # Your language model instance
# Define the task
task = "Analyze the given text and provide a summary."
# Create an Agent instance with ReflectWorkflow
agent = Agent(
llm=llm,
task=task,
workflow=ReflectWorkflow,
verbose=True
)
# Run the agent (which will use the ReflectWorkflow)
result = agent.invoke()
print(result)
The ReflectWorkflow
utilizes several components:
- Plan: Responsible for creating a plan to accomplish the task.
- Tool: Handles the usage of any tools provided by the language model.
- Work: Executes the main work based on the plan and tool usage.
- Finalise: Wraps up the task and provides the final output.
Each component is initialized with a specific worker (PlanWorker, ToolWorker, Worker, FinaliseWorker) that defines its behavior.
typing
- ReXia.AI components (
BaseWorkflow
,BaseMemory
,CollaborationChannel
,TaskStatus
,Component
) - ReXia.AI workers (
PlanWorker
,FinaliseWorker
,Worker
,ToolWorker
) - ReXia.AI Agent class
Ensure all dependencies are installed and properly imported.
We welcome contributions to improve the ReXia.AI framework. Please follow these steps to contribute:
- Fork the repository.
- Create a new branch (
git checkout -b feature-branch
). - Make your changes.
- Commit your changes (
git commit -m 'Add new feature'
). - Push to the branch (
git push origin feature-branch
). - Create a new Pull Request.
This project is licensed under the Apache License 2.0. See the LICENSE file for details.