aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Reinier van der Leer <pwuts@agpt.co> 2024-05-07 13:44:31 +0200
committerGravatar Reinier van der Leer <pwuts@agpt.co> 2024-05-07 13:44:31 +0200
commit2ef5cd7d4ca4ab15f866997981c3439ed6f96cff (patch)
tree7e0c0a46f62e34f1502e6a11cf87914764c6e06d
parentfix(agent/docs): Fix symlinks to component-based agent docs (diff)
downloadAuto-GPT-2ef5cd7d4ca4ab15f866997981c3439ed6f96cff.tar.gz
Auto-GPT-2ef5cd7d4ca4ab15f866997981c3439ed6f96cff.tar.bz2
Auto-GPT-2ef5cd7d4ca4ab15f866997981c3439ed6f96cff.zip
fix(agent): Swap target files and symlinks of component documentation to make package buildable
Documentation files were in docs/content/AutoGPT/components, symlinks in autogpts/autogpt/autogpt/(agents|commands). Chef doesn't allow symlinks that point to locations outside of package dir. Replacing the documentation files with symlinks, and symlinks with the actual documentation files, should fix this.
-rw-r--r--[l---------]autogpts/autogpt/autogpt/agents/README.md38
-rw-r--r--[l---------]autogpts/autogpt/autogpt/commands/README.md129
l---------[-rw-r--r--]docs/content/AutoGPT/components/agents.md38
l---------[-rw-r--r--]docs/content/AutoGPT/components/components.md129
4 files changed, 167 insertions, 167 deletions
diff --git a/autogpts/autogpt/autogpt/agents/README.md b/autogpts/autogpt/autogpt/agents/README.md
index 0ac88dda9..4ab573243 120000..100644
--- a/autogpts/autogpt/autogpt/agents/README.md
+++ b/autogpts/autogpt/autogpt/agents/README.md
@@ -1 +1,37 @@
-../../../../docs/content/AutoGPT/components/agents.md \ No newline at end of file
+# 🤖 Agents
+
+Agent is composed of [🧩 Components](./components.md) and responsible for executing pipelines and some additional logic. The base class for all agents is `BaseAgent`, it has the necessary logic to collect components and execute protocols.
+
+## Important methods
+
+`BaseAgent` provides two abstract methods needed for any agent to work properly:
+1. `propose_action`: This method is responsible for proposing an action based on the current state of the agent, it returns `ThoughtProcessOutput`.
+2. `execute`: This method is responsible for executing the proposed action, returns `ActionResult`.
+
+## AutoGPT Agent
+
+`Agent` is the main agent provided by AutoGPT. It's a subclass of `BaseAgent`. It has all the [Built-in Components](./built-in-components.md). `Agent` implements the essential abstract methods from `BaseAgent`: `propose_action` and `execute`.
+
+## Building your own Agent
+
+The easiest way to build your own agent is to extend the `Agent` class and add additional components. By doing this you can reuse the existing components and the default logic for executing [⚙️ Protocols](./protocols.md).
+
+```py
+class MyComponent(AgentComponent):
+ pass
+
+class MyAgent(Agent):
+ def __init__(
+ self,
+ settings: AgentSettings,
+ llm_provider: ChatModelProvider,
+ file_storage: FileStorage,
+ legacy_config: Config,
+ ):
+ # Call the parent constructor to bring in the default components
+ super().__init__(settings, llm_provider, file_storage, legacy_config)
+ # Add your custom component
+ self.my_component = MyComponent()
+```
+
+For more customization, you can override the `propose_action` and `execute` or even subclass `BaseAgent` directly. This way you can have full control over the agent's components and behavior. Have a look at the [implementation of Agent](https://github.com/Significant-Gravitas/AutoGPT/tree/master/autogpts/autogpt/autogpt/agents/agent.py) for more details.
diff --git a/autogpts/autogpt/autogpt/commands/README.md b/autogpts/autogpt/autogpt/commands/README.md
index 82aa51245..5575f0bcb 120000..100644
--- a/autogpts/autogpt/autogpt/commands/README.md
+++ b/autogpts/autogpt/autogpt/commands/README.md
@@ -1 +1,128 @@
-../../../../docs/content/AutoGPT/components/components.md \ No newline at end of file
+# 🧩 Components
+
+Components are the building blocks of [🤖 Agents](./agents.md). They are classes inheriting `AgentComponent` or implementing one or more [⚙️ Protocols](./protocols.md) that give agent additional abilities or processing.
+
+Components can be used to implement various functionalities like providing messages to the prompt, executing code, or interacting with external services.
+They can be enabled or disabled, ordered, and can rely on each other.
+
+Components assigned in the agent's `__init__` via `self` are automatically detected upon the agent's instantiation.
+For example inside `__init__`: `self.my_component = MyComponent()`.
+You can use any valid Python variable name, what matters for the component to be detected is its type (`AgentComponent` or any protocol inheriting from it).
+
+Visit [Built-in Components](./built-in-components.md) to see what components are available out of the box.
+
+```py
+from autogpt.agents import Agent
+from autogpt.agents.components import AgentComponent
+
+class HelloComponent(AgentComponent):
+ pass
+
+class SomeComponent(AgentComponent):
+ def __init__(self, hello_component: HelloComponent):
+ self.hello_component = hello_component
+
+class MyAgent(Agent):
+ def __init__(self):
+ # These components will be automatically discovered and used
+ self.hello_component = HelloComponent()
+ # We pass HelloComponent to SomeComponent
+ self.some_component = SomeComponent(self.hello_component)
+```
+
+## Ordering components
+
+The execution order of components is important because the latter ones may depend on the results of the former ones.
+
+### Implicit order
+
+Components can be ordered implicitly by the agent; each component can set `run_after` list to specify which components should run before it. This is useful when components rely on each other or need to be executed in a specific order. Otherwise, the order of components is alphabetical.
+
+```py
+# This component will run after HelloComponent
+class CalculatorComponent(AgentComponent):
+ run_after = [HelloComponent]
+```
+
+### Explicit order
+
+Sometimes it may be easier to order components explicitly by setting `self.components` list in the agent's `__init__` method. This way you can also ensure there's no circular dependencies and `run_after` is ignored.
+
+!!! warning
+ Be sure to include all components - by setting `self.components` list, you're overriding the default behavior of discovering components automatically. Since it's usually not intended agent will inform you in the terminal if some components were skipped.
+
+```py
+class MyAgent(Agent):
+ def __init__(self):
+ self.hello_component = HelloComponent()
+ self.calculator_component = CalculatorComponent(self.hello_component)
+ # Explicitly set components list
+ self.components = [self.hello_component, self.calculator_component]
+```
+
+## Disabling components
+
+You can control which components are enabled by setting their `_enabled` attribute.
+Either provide a `bool` value or a `Callable[[], bool]`, will be checked each time
+the component is about to be executed. This way you can dynamically enable or disable
+components based on some conditions.
+You can also provide a reason for disabling the component by setting `_disabled_reason`.
+The reason will be visible in the debug information.
+
+```py
+class DisabledComponent(MessageProvider):
+ def __init__(self):
+ # Disable this component
+ self._enabled = False
+ self._disabled_reason = "This component is disabled because of reasons."
+
+ # Or disable based on some condition, either statically...:
+ self._enabled = self.some_property is not None
+ # ... or dynamically:
+ self._enabled = lambda: self.some_property is not None
+
+ # This method will never be called
+ def get_messages(self) -> Iterator[ChatMessage]:
+ yield ChatMessage.user("This message won't be seen!")
+
+ def some_condition(self) -> bool:
+ return False
+```
+
+If you don't want the component at all, you can just remove it from the agent's `__init__` method. If you want to remove components you inherit from the parent class you can set the relevant attribute to `None`:
+
+!!! Warning
+ Be careful when removing components that are required by other components. This may lead to errors and unexpected behavior.
+
+```py
+class MyAgent(Agent):
+ def __init__(self):
+ super().__init__(...)
+ # Disable WatchdogComponent that is in the parent class
+ self.watchdog = None
+
+```
+
+## Exceptions
+
+Custom errors are provided which can be used to control the execution flow in case something went wrong. All those errors can be raised in protocol methods and will be caught by the agent.
+By default agent will retry three times and then re-raise an exception if it's still not resolved. All passed arguments are automatically handled and the values are reverted when needed.
+All errors accept an optional `str` message. There are following errors ordered by increasing broadness:
+
+1. `ComponentEndpointError`: A single endpoint method failed to execute. Agent will retry the execution of this endpoint on the component.
+2. `EndpointPipelineError`: A pipeline failed to execute. Agent will retry the execution of the endpoint for all components.
+3. `ComponentSystemError`: Multiple pipelines failed.
+
+**Example**
+
+```py
+from autogpt.agents.components import ComponentEndpointError
+from autogpt.agents.protocols import MessageProvider
+
+# Example of raising an error
+class MyComponent(MessageProvider):
+ def get_messages(self) -> Iterator[ChatMessage]:
+ # This will cause the component to always fail
+ # and retry 3 times before re-raising the exception
+ raise ComponentEndpointError("Endpoint error!")
+```
diff --git a/docs/content/AutoGPT/components/agents.md b/docs/content/AutoGPT/components/agents.md
index 4ab573243..7d3808a14 100644..120000
--- a/docs/content/AutoGPT/components/agents.md
+++ b/docs/content/AutoGPT/components/agents.md
@@ -1,37 +1 @@
-# 🤖 Agents
-
-Agent is composed of [🧩 Components](./components.md) and responsible for executing pipelines and some additional logic. The base class for all agents is `BaseAgent`, it has the necessary logic to collect components and execute protocols.
-
-## Important methods
-
-`BaseAgent` provides two abstract methods needed for any agent to work properly:
-1. `propose_action`: This method is responsible for proposing an action based on the current state of the agent, it returns `ThoughtProcessOutput`.
-2. `execute`: This method is responsible for executing the proposed action, returns `ActionResult`.
-
-## AutoGPT Agent
-
-`Agent` is the main agent provided by AutoGPT. It's a subclass of `BaseAgent`. It has all the [Built-in Components](./built-in-components.md). `Agent` implements the essential abstract methods from `BaseAgent`: `propose_action` and `execute`.
-
-## Building your own Agent
-
-The easiest way to build your own agent is to extend the `Agent` class and add additional components. By doing this you can reuse the existing components and the default logic for executing [⚙️ Protocols](./protocols.md).
-
-```py
-class MyComponent(AgentComponent):
- pass
-
-class MyAgent(Agent):
- def __init__(
- self,
- settings: AgentSettings,
- llm_provider: ChatModelProvider,
- file_storage: FileStorage,
- legacy_config: Config,
- ):
- # Call the parent constructor to bring in the default components
- super().__init__(settings, llm_provider, file_storage, legacy_config)
- # Add your custom component
- self.my_component = MyComponent()
-```
-
-For more customization, you can override the `propose_action` and `execute` or even subclass `BaseAgent` directly. This way you can have full control over the agent's components and behavior. Have a look at the [implementation of Agent](https://github.com/Significant-Gravitas/AutoGPT/tree/master/autogpts/autogpt/autogpt/agents/agent.py) for more details.
+../../../../autogpts/autogpt/autogpt/agents/README.md \ No newline at end of file
diff --git a/docs/content/AutoGPT/components/components.md b/docs/content/AutoGPT/components/components.md
index 5575f0bcb..8f836ac3d 100644..120000
--- a/docs/content/AutoGPT/components/components.md
+++ b/docs/content/AutoGPT/components/components.md
@@ -1,128 +1 @@
-# 🧩 Components
-
-Components are the building blocks of [🤖 Agents](./agents.md). They are classes inheriting `AgentComponent` or implementing one or more [⚙️ Protocols](./protocols.md) that give agent additional abilities or processing.
-
-Components can be used to implement various functionalities like providing messages to the prompt, executing code, or interacting with external services.
-They can be enabled or disabled, ordered, and can rely on each other.
-
-Components assigned in the agent's `__init__` via `self` are automatically detected upon the agent's instantiation.
-For example inside `__init__`: `self.my_component = MyComponent()`.
-You can use any valid Python variable name, what matters for the component to be detected is its type (`AgentComponent` or any protocol inheriting from it).
-
-Visit [Built-in Components](./built-in-components.md) to see what components are available out of the box.
-
-```py
-from autogpt.agents import Agent
-from autogpt.agents.components import AgentComponent
-
-class HelloComponent(AgentComponent):
- pass
-
-class SomeComponent(AgentComponent):
- def __init__(self, hello_component: HelloComponent):
- self.hello_component = hello_component
-
-class MyAgent(Agent):
- def __init__(self):
- # These components will be automatically discovered and used
- self.hello_component = HelloComponent()
- # We pass HelloComponent to SomeComponent
- self.some_component = SomeComponent(self.hello_component)
-```
-
-## Ordering components
-
-The execution order of components is important because the latter ones may depend on the results of the former ones.
-
-### Implicit order
-
-Components can be ordered implicitly by the agent; each component can set `run_after` list to specify which components should run before it. This is useful when components rely on each other or need to be executed in a specific order. Otherwise, the order of components is alphabetical.
-
-```py
-# This component will run after HelloComponent
-class CalculatorComponent(AgentComponent):
- run_after = [HelloComponent]
-```
-
-### Explicit order
-
-Sometimes it may be easier to order components explicitly by setting `self.components` list in the agent's `__init__` method. This way you can also ensure there's no circular dependencies and `run_after` is ignored.
-
-!!! warning
- Be sure to include all components - by setting `self.components` list, you're overriding the default behavior of discovering components automatically. Since it's usually not intended agent will inform you in the terminal if some components were skipped.
-
-```py
-class MyAgent(Agent):
- def __init__(self):
- self.hello_component = HelloComponent()
- self.calculator_component = CalculatorComponent(self.hello_component)
- # Explicitly set components list
- self.components = [self.hello_component, self.calculator_component]
-```
-
-## Disabling components
-
-You can control which components are enabled by setting their `_enabled` attribute.
-Either provide a `bool` value or a `Callable[[], bool]`, will be checked each time
-the component is about to be executed. This way you can dynamically enable or disable
-components based on some conditions.
-You can also provide a reason for disabling the component by setting `_disabled_reason`.
-The reason will be visible in the debug information.
-
-```py
-class DisabledComponent(MessageProvider):
- def __init__(self):
- # Disable this component
- self._enabled = False
- self._disabled_reason = "This component is disabled because of reasons."
-
- # Or disable based on some condition, either statically...:
- self._enabled = self.some_property is not None
- # ... or dynamically:
- self._enabled = lambda: self.some_property is not None
-
- # This method will never be called
- def get_messages(self) -> Iterator[ChatMessage]:
- yield ChatMessage.user("This message won't be seen!")
-
- def some_condition(self) -> bool:
- return False
-```
-
-If you don't want the component at all, you can just remove it from the agent's `__init__` method. If you want to remove components you inherit from the parent class you can set the relevant attribute to `None`:
-
-!!! Warning
- Be careful when removing components that are required by other components. This may lead to errors and unexpected behavior.
-
-```py
-class MyAgent(Agent):
- def __init__(self):
- super().__init__(...)
- # Disable WatchdogComponent that is in the parent class
- self.watchdog = None
-
-```
-
-## Exceptions
-
-Custom errors are provided which can be used to control the execution flow in case something went wrong. All those errors can be raised in protocol methods and will be caught by the agent.
-By default agent will retry three times and then re-raise an exception if it's still not resolved. All passed arguments are automatically handled and the values are reverted when needed.
-All errors accept an optional `str` message. There are following errors ordered by increasing broadness:
-
-1. `ComponentEndpointError`: A single endpoint method failed to execute. Agent will retry the execution of this endpoint on the component.
-2. `EndpointPipelineError`: A pipeline failed to execute. Agent will retry the execution of the endpoint for all components.
-3. `ComponentSystemError`: Multiple pipelines failed.
-
-**Example**
-
-```py
-from autogpt.agents.components import ComponentEndpointError
-from autogpt.agents.protocols import MessageProvider
-
-# Example of raising an error
-class MyComponent(MessageProvider):
- def get_messages(self) -> Iterator[ChatMessage]:
- # This will cause the component to always fail
- # and retry 3 times before re-raising the exception
- raise ComponentEndpointError("Endpoint error!")
-```
+../../../../autogpts/autogpt/autogpt/commands/README.md \ No newline at end of file