Skip to content
This repository was archived by the owner on Mar 16, 2024. It is now read-only.

Feature/cleanup readme setup #101

Merged
merged 2 commits into from
Jun 30, 2023
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
48 changes: 48 additions & 0 deletions .setup.sh.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
## NOTE - the code below is contained in setup.sh.example

# Clone the repository
git clone git@github.com:emrgnt-cmplxty/Automata.git
cd Automata

# Create the local environment
python3 -m venv local_env
source local_env/bin/activate

# Install the project in editable mode
pip3 install -e .

# Setup pre-commit hooks
pre-commit install

# Set up .env
cp .env.example .env
OPEN_API_KEY=your_openai_api_key_here
GITHUB_API_KEY=your_github_api_key
CONVERSATION_DB_PATH="$PWD/conversation_db.sqlite3"
TASK_DB_PATH="$PWD/task_db.sqlite3"
TASKS_OUTPUT_PATH="$PWD/tasks"
REPOSITORY_NAME="emrgnt-cmplxty/Automata"
sed -i "s|your_openai_api_key|$OPEN_API_KEY|" .env
sed -i "s|your_github_api_key|$GITHUB_API_KEY|" .env
sed -i "s|your_conversation_db_path|$CONVERSATION_DB_PATH|" .env
sed -i "s|your_task_db_path|$TASK_DB_PATH|" .env
sed -i "s|your_tasks_output_path|$TASKS_OUTPUT_PATH|" .env
sed -i "s|your_repository_name|$REPOSITORY_NAME|" .env
# Additional Notes -
# Default Max Workers is 8, manually change the .env to update this quantity.
# For MAC users, the example should read as follows -
## sed -i '' "s|your_openai_api_key|$OPEN_API_KEY|" .env

# Fetch the submodules
git submodule update --init --recursive

### NOTE - You must install git-lfs, if you have not done so already

### For Ubuntu, run the following:
## sudo apt-get install git-lfs
### For Mac, run the following:
## brew install git-lfs
###
### Then, initialize by running the following:
## git lfs install
## git lfs pull
94 changes: 17 additions & 77 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,14 @@

This project is inspired by the theory that code is essentially a form of memory, and when furnished with the right tools, AI can evolve real-time capabilities which can potentially lead to the creation of AGI. The word automata comes from the Greek word αὐτόματος, denoting "self-acting, self-willed, self-moving,", and [Automata theory](https://en.wikipedia.org/wiki/Automata_theory) is the study of abstract machines and [automata](https://en.wikipedia.org/wiki/Automaton), as well as the computational problems that can be solved using them. More information follows below.

## 🧠 [Read the Docs](https://automata.readthedocs.io/en/latest/)

---

## Demo
## 🧠 [Read the Docs](https://automata.readthedocs.io/en/latest/)

## Demo

https://github.com/emrgnt-cmplxty/Automata/assets/68796651/2e1ceb8c-ac93-432b-af42-c383ea7607d7


<img width="1059" alt="Automata_Rough_Schematic_06_22_23" src="https://github.com/emrgnt-cmplxty/Automata/assets/68796651/57ae3418-c01b-4b3f-a548-2f050c234b34">

---
Expand All @@ -33,83 +31,27 @@ https://github.com/emrgnt-cmplxty/Automata/assets/68796651/2e1ceb8c-ac93-432b-af
Follow these steps to setup the Automata environment

```bash
## NOTE - the code below is contained in setup.sh.example

# Clone the repository
git clone git@github.com:emrgnt-cmplxty/Automata.git
cd Automata

# Create the local environment
python3 -m venv local_env
source local_env/bin/activate

# Install the project in editable mode
pip3 install -e .

# Setup pre-commit hooks
pre-commit install

# Set up .env
cp .env.example .env
OPEN_API_KEY=your_openai_api_key_here
GITHUB_API_KEY=your_github_api_key
CONVERSATION_DB_PATH="$PWD/conversation_db.sqlite3"
TASK_DB_PATH="$PWD/task_db.sqlite3"
TASKS_OUTPUT_PATH="$PWD/tasks"
REPOSITORY_NAME="emrgnt-cmplxty/Automata"
sed -i "s|your_openai_api_key|$OPEN_API_KEY|" .env
sed -i "s|your_github_api_key|$GITHUB_API_KEY|" .env
sed -i "s|your_conversation_db_path|$CONVERSATION_DB_PATH|" .env
sed -i "s|your_task_db_path|$TASK_DB_PATH|" .env
sed -i "s|your_tasks_output_path|$TASKS_OUTPUT_PATH|" .env
sed -i "s|your_repository_name|$REPOSITORY_NAME|" .env
# Additional Notes -
# Default Max Workers is 8, manually change the .env to update this quantity.
# For MAC users, the example should read as follows -
## sed -i '' "s|your_openai_api_key|$OPEN_API_KEY|" .env

# Fetch the submodules
git submodule update --init --recursive

### NOTE - You must install git-lfs, if you have not done so already

### For Ubuntu, run the following:
## sudo apt-get install git-lfs
### For Mac, run the following:
## brew install git-lfs
###
### Then, initialize by running the following:
## git lfs install
## git lfs pull
```

### Indexing

[SCIP indices](https://about.sourcegraph.com/blog/announcing-scip) are required to run the Automata Search. These indices are used to create the code graph which relates all dependencies. New indices are generated and uploaded periodically for the Automata Interpreter codebase, but developers must be generate them manually if necessary for their local development. If you encounter issues, we recommending referring to the [instructions here](https://github.com/sourcegraph/scip-python).

```bash
# Activate the local repository
source local_env/bin/activate
# Copy the env and setup files
cp .setup.sh.example setup.sh && cp .env.example .env

# Install scip-python locally
cd scip-python
npm install
# Allow for execution
chmod 755 setup.sh

# Build the tool
cd packages/pyright-scip
npm run build
# Update the setup and env files with your local paths
vim setup.sh
vim .env

# Return to working dir
cd ../../../

# Generate the local index
node scip-python/packages/pyright-scip/index index --project-name automata --output index_from_fork.scip --target-only automata
# Run the setup script
./setup.sh
```

# Copy into the default index location
mv index_from_fork.scip automata/config/symbol/index.scip
### Indexing

[SCIP indices](https://about.sourcegraph.com/blog/announcing-scip) are required to run the Automata Search. These indices are used to create the code graph which relates symbols by dependencies across the codebase. New indices are generated and uploaded periodically for the Automata codebase, but programmers must be generate them manually if necessary for their local development. If you encounter issues, we recommend referring to the [instructions here](https://github.com/sourcegraph/scip-python).

### Alternatively, you mean run ./regenerate_index after changing local permissions and completing the above install.
```bash
# Install dependencies and run indexing on the local codebase
./install_indexing.sh && ./regenerate_index.sh
```

### Build the embeddings + docs
Expand All @@ -122,11 +64,9 @@ automata run-code-embedding

# "L1" docs are the docstrings written into the code
# "L2" docs are generated from the L1 docs + symbol context
# Build/refresh and embed the L2 docs
automata run-doc-embedding-l2

# "L3" docs are generated from the L2 docs + symbol context
# Build/refresh and embed the L3 docs
automata run-doc-embedding-l3
```

Expand Down
139 changes: 97 additions & 42 deletions automata/docs/config/agent_config.rst
Original file line number Diff line number Diff line change
@@ -1,62 +1,117 @@
AgentConfig
===========
``AgentConfig`` Class
=====================

The ``AgentConfig`` class is a base abstraction for creating specific
configurations to be used by agent instances. It includes necessary
parameters such as instructions to be executed by the agent, a list of
tools used, a model name, and various boolean flags for stream and
verbose logging status.

In addition, it holds the max iterations and temperature settings for
the agent’s operation. It also has an optional session id attribute.

This class is an abstract base class (ABC), and it includes abstract
methods, requiring subclasses to provide concrete implementations of
these methods.

Attributes
----------

- ``config_name``: Defines the name of the configuration.
- ``tools``: Sets a list of Tools to be used by the agent.
- ``instructions``: A string set by the user to handle instructions for
the agent.
- ``description``: A string to hold any necessary description.
- ``model``: Defines the model to be used by the agent.
- ``stream``: Boolean variable to define whether to use stream
functionality.
- ``verbose``: Boolean variable to define whether verbose logging
should be used.
- ``max_iterations``: Sets the maximum iterations count for the agent
operations.
- ``temperature``: Sets the temperature scalar for the agent
operations.
- ``session_id``: (Optional) Defines the session id for the agent.

Methods
-------

``AgentConfig`` is an abstract base class that provides a template for
configurations related to providers. It contains abstract methods like
``setup()`` and ``load()`` that need to be implemented by subclasses.
This class also handles the configuration of arbitrary types during the
initialization.
setup
~~~~~

Overview
--------
A method that subclasses must implement. Its purpose is to be defined by
the subclasses.

``AgentConfig`` is designed for ensuring configurability of providers.
Subclasses need to provide implementations for the ``setup()`` and
``load()`` methods in order to properly define the behavior during the
agent setup and configuration loading processes. This class follows the
BaseModel design, making it easy to extend and customize according to
specific agent requirements.
load
~~~~

Related Symbols
---------------
A method that subclasses must implement. It should load the agent
configuration based on the provided name.

- ``automata.core.agent.instances.AutomataOpenAIAgentInstance.Config``
- ``automata.tests.unit.test_automata_agent_builder.test_builder_default_config``
- ``automata.tests.unit.test_task_environment.TestURL``
- ``automata.core.base.agent.AgentInstance.Config``
get_llm_provider
~~~~~~~~~~~~~~~~

Example
-------
A static method that subclasses must implement. The method should return
the provider for the agent.

The following example demonstrates how to create a custom agent
configuration by extending the ``AgentConfig`` class:
\_load_automata_yaml_config
~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. code:: python
This method is responsible for loading YAML configuration for the agent.
It opens a YAML file, processes its content, and loads them into an
agent configuration instance. If ``config_name`` appears in the loaded
YAML, it raises an Exception. Once the loading completes, it adds
``config_name`` to the loaded YAML and returns it.

from config.config_types import AgentConfig
Inherited Classes
-----------------

class CustomAgentConfig(AgentConfig):
The ``AutomataOpenAIAgentConfig`` is a concrete class that inherits from
``AgentConfig``. This class specifies ``OPENAI`` as the ``LLMProvider``
and allows the use of different models. It further enriches the
configuration by defining the system template, system template
variables, system template formatter, instruction version, and system
instruction.

def setup(self):
# Define your custom agent setup process
pass
Example
-------

@classmethod
def load(cls, config_name: AgentConfigName) -> "CustomAgentConfig":
# Load the config for your custom agent
pass
Creating a derived class ``AutomataOpenAIAgentConfig`` and using the
``load`` method:

.. code:: python

from automata.config.openai_agent import AutomataOpenAIAgentConfig
from automata.config.base import AgentConfigName

config = AutomataOpenAIAgentConfig.load(AgentConfigName.DEFAULT)
assert isinstance(config, AutomataOpenAIAgentConfig)

Limitations
-----------

``AgentConfig`` itself is an abstract class and cannot directly be
instantiated. It must be subclassed, and its methods need to be
implemented by the extending class according to the specific agent
requirements. Additionally, the current implementation allows for
arbitrary types, which may lead to code that is not type-safe.
The class ``AgentConfig`` is an abstract base class and cannot be
directly used to create an object. It must be subclassed, and each
subclass must provide implementations for the abstract methods.

A derived class can load YAML configurations from a specific file
location, and this could raise file operation related exceptions. For
instance, if the configuration file is not found or if the YAML file is
not in the correct format, corresponding exceptions will be raised.

When a ``config_name`` is found in the loaded_yaml, the
``_load_automata_yaml_config`` method throws an error stating:
“config_name already specified in YAML. Please remove this from the YAML
file.” This could be a limitation when the user does not have much
control over the yaml content or if the yaml modification would conflict
with other requirements.

Follow-up Questions:
--------------------

- How can we ensure type safety while maintaining the flexibility and
customizability provided by ``AgentConfig``?
- How to manage the file operation exceptions when loading yaml
configuration?
- Can we modify ``_load_automata_yaml_config`` to allow ``config_name``
in yaml or provide a mechanism to overwrite it?
- What to do when we need to set up an ``AgentConfig`` with varying
attributes not defined in existing classes?
Loading