Skip to content

Commit

Permalink
Merge pull request #22 from superagentxai/dev
Browse files Browse the repository at this point in the history
Verbose And Docs Changes
  • Loading branch information
SyedHabibM authored Nov 25, 2024
2 parents 5275555 + c0232e7 commit 0ace068
Show file tree
Hide file tree
Showing 69 changed files with 3,323 additions and 1,597 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ $ source venv/bin/activate
(venv) $ poetry install
```

## Documentation (_Coming Soon_)
## [Documentation](https://docs.superagentx.ai/introduction)

## License

Expand Down
161 changes: 161 additions & 0 deletions docs/agent.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
---
title: 'Agent'
icon: 'robot'
---

An `Agent` from `superagentx.agent` is a system or program that is initialized with specific goals and roles, enabling it to interact with a
large language model (LLM) and use a predefined prompt template. It is designed to perform agent by following a
set of instructions and can be customized with various parameters to adapt its behavior to different agent or
workflows. Essentially, the `agent` acts as a flexible tool that can be fine-tuned to carry out specific functions
based on the needs of the user.


### Agent Parameters
| Attribute | Parameters | Description |
| :-------------------- | :---------------- | :------------------------------------- |
|**Goal** | `goal` | The primary objective or goal that the engine is designed to achieve. |
|**Role** | `role` | The role or function that the engine will assume in its operations. |
|**LLM Client** | `llm` | Interface for communicating with the large language model (LLM). |
|**Prompt Template** | `prompt_template` | Defines the structure and format of prompts sent to the LLM using PromptTemplate. |
|**Agent ID** _(optional)_ | `agent_id` | A unique identifier for the engine. If not provided, a new UUID will be generated by default. Useful for tracking or referencing the engine in multi-engine environments. |
|**Name** _(optional)_ | `name` | An optional name for the engine, providing a more friendly reference for display or logging purposes. |
|**Description** _(optional)_ | `description` | An optional description that provides additional context or details about the engine's purpose and capabilities. |
|**Engines** _(optional)_ | `engines` | A list of engines (or lists of engines) that the engine can utilize. This allows for flexibility in processing and task execution based on different capabilities or configurations. |
|**Output Format** _(optional)_ | `output_format` | Specifies the desired format for the engine's output. This can dictate how results are structured and presented. |
|**Max Retry** _(optional)_ | `max_retry` | The maximum number of retry attempts for operations that may fail.Default is set to 5. This is particularly useful in scenarios where transient errors may occur, ensuring robust execution. |

```python
from superagentx.agent import Agent

ecom_agent = Agent(
name='Ecom Agent',
goal="Get me the best search results",
role="You are the best product searcher",
llm=llm_client,
prompt_template=prompt_template,
engines=[[amazon_engine, walmart_engine]],
agent_id="ecom-id-1",
description="""E-commerce enables buying and selling products online,
providing customers with the convenience of shopping anytime, anywhere.
It connects buyers and sellers through digital platforms, offering
secure transactions and delivery.
""",
output_format="Generate as JSON format",
max_retry=5
)
```
## Agent Configuration

### Sequence
In sequence execution, `engine(s)` are performed one after another, with each `engine(s)` waiting for the
previous one to finish before starting. This approach is simple but can be slow if `engine(s)` are independent.

```python
from superagentx.agent import agent

agent = Agent(
...
engines=[engine_1, engine_2, engine_3 ... engine_n],
...
)

# Engines execution will be in following order
# [engine_1, engine_2, engine_3 ... engine_n]
```

#### Alternate way of configure

```python
from superagentx.agent import agent

agent = Agent(
...,
...
)

await agent.add(engine_1, engine_2, execute_type='SEQUENCE')
.
.
.
await agent.add(engine_3, engine_4, execute_type='SEQUENCE')
.
.

# Engines execution will be in following order
# [engine_1, engine_2, engine_3, engine_4]
```

### Parallel
In parallel execution, `engine(s)` run at the same time, speeding up the process by utilizing multiple threads or processes.

```python
from superagentx.agent import agent

agent = Agent(
...
engines=[[engine_1, engine_2, engine_3 ... engine_n]],
...
)

# Engines execution will be in following order
# [[engine_1, engine_2, engine_3 ... engine_n]]
```

#### Alternate way of configure

```python
from superagentx.agent import agent

agent = Agent(
...,
...
)

await agent.add(engine_1, engine_2, execute_type='PARALLEL')
.
.

await agent.add(engine_3, engine_4, execute_type='PARALLEL')
.
.

# Engines execution will be in following order
# [[agent_1, engine_2, engine_3, engine_4]]
```

### Mixed with Sequence and Parallel

```python
from superagentx.agent import agent

agent = Agent(
...
engines=[engine_1, [engine_2, engine_3], engine_4 ... engine_n],
...
)

# Engines execution will be in following order
# [engine_1, [engine_2, engine_3], engine_4, ... engine_nm]]
```

#### Alternate way of configure

```python
from superagentx.agent import agent

agent = Agent(
...,
...
)

await agent.add(engine_1, engine_2, execute_type='SEQUENCE')
.
.
.
await agent.add(engine_3, engine_4, execute_type='PARALLEL')
.
.

# Engines execution will be in following order
# [engine_1, engine_2, [engine_3, engine_4]]
```
33 changes: 0 additions & 33 deletions docs/api-reference/introduction.mdx

This file was deleted.

97 changes: 0 additions & 97 deletions docs/development.mdx

This file was deleted.

31 changes: 31 additions & 0 deletions docs/engine.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
title: 'Engine'
icon: 'engine'
---

An `Engine` is a system that sets up and runs specific processes to perform `handler`. It organizes different `handler`
functions and uses a given prompt along with a language model to activate them. Essentially, the `engine` helps
manage and trigger these processes to carry out actions based on the instructions it receives.


### Parameters
| Attribute | Parameters | Description |
| :-------------------- | :---------------- | :------------------------------------- |
| **Handler** | `handler` | Implementation of `BaseHandler`, it method(s) will be executed based on the given prompts. |
| **LLM Client** | `llm` | Interface for communicating with the large language model (LLM). |
| **Prompt Template** | `prompt_template` | Defines the structure and format of prompts sent to the LLM using `PromptTemplate`. |
| **Tools** _(optional)_ | `tools` | List of handler method names (as dictionaries or strings) available for use during interactions. Defaults to `None`. If nothing provide `Engine` will get it dynamically using `dir(handler)`.|
| **Output Parser** _(optional)_ | `output_parser` | An optional parser to format and process the handler tools output. Defaults to `None`. |


```python
from superagentx.engine import Engine

walmart_engine = Engine(
handler=walmart_ecom_handler,
llm=llm_client,
prompt_template=prompt_template,
tools=None,
output_parser=None,
)
```
37 changes: 0 additions & 37 deletions docs/essentials/code.mdx

This file was deleted.

Loading

0 comments on commit 0ace068

Please sign in to comment.