Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Frontend enabling work #26

Open
wants to merge 37 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
ca8b4e7
move existing repo to agents folder and update devops
foolishsailor Apr 16, 2023
466ab7b
initial project
foolishsailor Apr 16, 2023
a8e73b3
proof of concept and tooling
foolishsailor Apr 16, 2023
46218a0
proof of concept and tooling done
foolishsailor Apr 16, 2023
62f6a55
added readme
foolishsailor Apr 17, 2023
cc7a0b7
added reflecting and decision dialogue to bus
foolishsailor Apr 17, 2023
e682c5d
added reflecting and decision dialogue to bus
foolishsailor Apr 17, 2023
d073356
added reflecting and decision dialogue to bus
foolishsailor Apr 17, 2023
f046ad7
added agent split components
foolishsailor Apr 17, 2023
4dd036f
WIP
foolishsailor Apr 17, 2023
6202139
added ability to send messages
foolishsailor Apr 17, 2023
da3a32f
touch up css
foolishsailor Apr 17, 2023
901fcdd
refactorFE to best practice, tidy up css and add scroll to end for ag…
foolishsailor Apr 18, 2023
2591a00
fix type in yml
foolishsailor Apr 18, 2023
5afe5b2
fix yml directories for repos
foolishsailor Apr 18, 2023
b74929a
added default directories to jobs
foolishsailor Apr 18, 2023
664c72e
small fix to agent height calc
foolishsailor Apr 18, 2023
1fdaaf6
last css fix
foolishsailor Apr 18, 2023
79d1a58
fix indent in yml
foolishsailor Apr 18, 2023
ce53407
setup basic testing infra
foolishsailor Apr 18, 2023
1657a4d
finish infra for testing and add linting
foolishsailor Apr 18, 2023
d8dd64c
allow warnings
foolishsailor Apr 18, 2023
40324df
remove unsupported node for FE
foolishsailor Apr 18, 2023
cdbc189
remove fe from repo
foolishsailor Apr 19, 2023
caeb513
merge conflict
foolishsailor Apr 19, 2023
11d1af5
revert github actions back to old version
foolishsailor Apr 19, 2023
e2f74c2
new package.lock generated
foolishsailor Apr 19, 2023
39396c8
remove old working directory in yml
foolishsailor Apr 19, 2023
77eb392
change to node 14 lowest supported
foolishsailor Apr 19, 2023
8fa2be1
added help and test to console parameters to allow testing agents mes…
foolishsailor Apr 19, 2023
34fb6d2
updated readme
foolishsailor Apr 19, 2023
7ec2370
add test flag to web socket server
foolishsailor Apr 19, 2023
ec247a7
fix lint issue
foolishsailor Apr 19, 2023
9cbe954
prResponse
foolishsailor Apr 20, 2023
b7e2a70
revert github actions
foolishsailor Apr 20, 2023
1dafb41
lint, test, format
foolishsailor Apr 20, 2023
2baeaed
removed the test param from return of parameters
foolishsailor Apr 20, 2023
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
66 changes: 56 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
name: CI

on:
push:
branches: ["master"]
branches: ['master']
pull_request:
branches: ["master"]
branches: ['master']

jobs:
build:
build_agent_controller:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we revert this?

Suggested change
build_agent_controller:
build:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will revert

runs-on: ubuntu-latest

strategy:
Expand All @@ -22,19 +21,66 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: "npm"
cache: 'npm'

- name: Install dependencies
run: npm ci
run: |
cd src/agents-controller
npm ci

- name: Compile
run: npm run compile
run: |
cd src/agents-controller
npm run compile

- name: Test
run: |
cd src/agents-controller
npm test

- name: Lint
run: |
cd src/agents-controller
npm run lint

- name: Format
run: |
cd src/agents-controller
npm run format:check

build_frontend:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [14.x, 16.x, 18.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v3

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'

- name: Install dependencies
run: |
cd src/frontend
npm ci

- name: Test
run: npm test
run: |
cd src/frontend
npm run test

- name: Lint
run: npm run lint
run: |
cd src/frontend
npm run lint

- name: Format
run: npm run format:check
run: |
cd src/frontend
npm run format:check
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
node_modules
dist
.env
.store
106 changes: 106 additions & 0 deletions .store/1/memory
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
[
{
"type": "message",
"message": {
"type": "spontaneous",
"source": {
"type": "system"
},
"targetAgentIds": [
"1"
],
"content": "Several events are omitted here to free up space in your context window, summarized as follows:\n\nYou received a message from Control asking for the temperature in San Diego. You used the `searchWeb` action to search for the current temperature in San Diego, but the search results did not provide a clear answer. You then used the `searchWeb` action again to search for the temperature in San Diego right now, and found several websites that provided the current temperature."
}
},
{
"type": "decision",
"actionText": "readPage\nthoughts: I can use this action to read a summary of a web page in markdown format.\nurl: https://www.accuweather.com/en/us/san-diego/92101/current-weather/347628"
},
{
"type": "message",
"message": {
"type": "ok",
"source": {
"type": "system"
},
"targetAgentIds": [
"1"
],
"content": "Here is a summarized markdown version of the page, in a series of summarized chunks:\n\n=== SUMMARIZED CHUNK (61 tokens) ===\n\nUnfortunately, the requested webpage is not available at the provided link. Access to the page has been denied as you do not have the required permissions to view it. The reference number 18.ae9bd817.1681485635.26537847 can be used for further troubleshooting if required.\n\n"
}
},
{
"type": "decision",
"actionText": "searchWeb\nthoughts: I can use this action to search the web for information.\nsearchString: temperature in San Diego right now accuweather"
},
{
"type": "message",
"message": {
"type": "ok",
"source": {
"type": "system"
},
"targetAgentIds": [
"1"
],
"content": "Search results:\n\n- Title: \"San Diego, CA Weather Forecast | AccuWeather\"\n URL: https://www.accuweather.com/en/us/san-diego/92101/weather-forecast/347628\n\n- Title: \"San Diego, CA Daily Weather | AccuWeather\"\n URL: https://www.accuweather.com/en/us/san-diego/92101/daily-weather-forecast/347628\n\n- Title: \"San Diego, CA Hourly Weather | AccuWeather\"\n URL: https://www.accuweather.com/en/us/san-diego/92101/hourly-weather-forecast/347628\n\n- Title: \"San Diego, CA Current Weather | AccuWeather\"\n URL: https://www.accuweather.com/en/us/san-diego/92101/current-weather/347628\n\n- Title: \"San Antonio, TX Weather Forecast | AccuWeather\"\n URL: https://www.accuweather.com/en/us/san-antonio/78205/weather-forecast/351198\n\n- Title: \"San Diego, CA Weather Radar | AccuWeather\"\n URL: https://www.accuweather.com/en/us/san-diego/92101/weather-radar/347628\n\n- Title: \"San Antonio, TX Current Weather | AccuWeather\"\n URL: https://www.accuweather.com/en/us/san-antonio/78205/current-weather/351198\n\n- Title: \"San Diego, CA Monthly Weather | AccuWeather\"\n URL: https://www.accuweather.com/en/us/san-diego/92101/february-weather/347628\n\n- Title: \"San Diego, CA Satellite Weather Map | AccuWeather\"\n URL: https://www.accuweather.com/en/us/san-diego/92101/satellite/347628\n\n- Title: \"San Diego, TX Weather Forecast | AccuWeather\"\n URL: https://www.accuweather.com/en/us/san-diego/78384/weather-forecast/335877"
}
},
{
"type": "decision",
"actionText": "readPage\nthoughts: I can use this action to read a summary of the current weather in San Diego.\nurl: https://www.accuweather.com/en/us/san-diego/92101/current-weather/347628"
},
{
"type": "message",
"message": {
"type": "ok",
"source": {
"type": "system"
},
"targetAgentIds": [
"1"
],
"content": "Here is a summarized markdown version of the page, in a series of summarized chunks:\n\n=== SUMMARIZED CHUNK (78 tokens) ===\n\nUnfortunately, you don't have permission to access the webpage \"http://www.accuweather.com/en/us/san-diego/92101/current-weather/347628\" at this time. The server is denying your access with the error message \"Reference #18.ae9bd817.1681485653.2654409a\".\n\n"
}
},
{
"type": "decision",
"actionText": "searchWeb\nthoughts: I can try searching for the temperature in San Diego using a different search engine.\nsearchString: temperature in San Diego right now"
},
{
"type": "message",
"message": {
"type": "ok",
"source": {
"type": "system"
},
"targetAgentIds": [
"1"
],
"content": "Search results:\n\n- Title: \"San Diego, CA Current Weather | AccuWeather\"\n URL: https://www.accuweather.com/en/us/san-diego/92101/current-weather/347628\n\n- Title: \"San Diego, CA 10-Day Weather Forecast - The Weather Channel ...\"\n URL: https://weather.com/weather/tenday/l/San+Diego+CA?canonicalCityId=cb5c473781cc06501376639dce8f0823a99187dcb42c79471a4303c076d66452\n\n- Title: \"Weather for San Diego, California, USA\"\n URL: https://www.timeanddate.com/weather/usa/san-diego\n\n- Title: \"San Diego 7-Day Weather Forecast | FOX 5 San Diego\"\n URL: https://fox5sandiego.com/weather/forecast/\n\n- Title: \"San Diego, CA\"\n URL: https://www.weather.gov/sgx/\n\n- Title: \"Zone Area Forecast for San Diego County Inland Valleys\"\n URL: https://forecast.weather.gov/MapClick.php?zoneid=CAZ050\n\n- Title: \"San Diego, CA Weather Conditions | Weather Underground\"\n URL: https://www.wunderground.com/weather/us/ca/san-diego\n\n- Title: \"Zone Area Forecast for San Diego County Coastal Areas\"\n URL: https://forecast.weather.gov/MapClick.php?zoneid=CAZ043\n\n- Title: \"Water temperature in San Diego in Pacific Ocean now\"\n URL: https://seatemperature.net/current/united-states/san-diego-california-united-states-sea-temperature\n\n- Title: \"San Diego, CA - Current Weather - The Weather Network\"\n URL: https://www.theweathernetwork.com/us/weather/california/san-diego"
}
},
{
"type": "decision",
"actionText": "readPage\nthoughts: I can use this action to read a summary of the current weather in San Diego from The Weather Channel website.\nurl: https://weather.com/weather/today/l/32.72,-117.16?par=google&temp=f"
},
{
"type": "message",
"message": {
"type": "agentToAgent",
"source": {
"type": "agent",
"id": "0"
},
"targetAgentIds": [
"1",
"2"
],
"content": "how heavy is the earth"
}
},
{
"type": "decision",
"actionText": "searchWeb\nthoughts: I can use this action to search the web for information.\nsearchString: weight of the earth"
}
]
38 changes: 38 additions & 0 deletions .store/2/memory
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[
{
"type": "decision",
"actionText": "noop"
},
{
"type": "message",
"message": {
"type": "agentToAgent",
"source": {
"type": "agent",
"id": "0"
},
"targetAgentIds": [
"1",
"2"
],
"content": "how heavy is the earth"
}
},
{
"type": "decision",
"actionText": "searchWeb\nthoughts: I can search the web to find the answer to this question.\nquery: how heavy is the earth?"
},
{
"type": "message",
"message": {
"type": "error",
"source": {
"type": "system"
},
"targetAgentIds": [
"2"
],
"content": "Missing required parameter `searchString`. Usage:\n\n```\nsearchWeb\nthoughts: <reasoning behind this action> (optional)\nsearchString: <the string to search for>\n```"
}
}
]
55 changes: 7 additions & 48 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,56 +4,15 @@ A framework for autonomous agents who can work together to accomplish tasks.

[![Discord](https://img.shields.io/discord/1095770840173383802?label=discord)](https://discord.gg/X9MkUEsEUC)

## Setup

You will need at least Node 10.

```
npm install
```

Rename the `.env.template` file at the root of the project to `.env` and add your secrets to it:

```
OPENAI_API_KEY=... # obtain from https://platform.openai.com/account/api-keys
# the following are needed for the agent to be able to search the web:
GOOGLE_SEARCH_ENGINE_ID=... # create a custom search engine at https://cse.google.com/cse/all
GOOGLE_API_KEY=... # obtain from https://console.cloud.google.com/apis/credentials
AGENT_DELAY=... # optionally, a delay in milliseconds following every agent action
```

You'll also need to enable the Google Custom Search API for your Google Cloud account, e.g. <https://console.cloud.google.com/apis/library/customsearch.googleapis.com>

## Running

Start the program:
The application has two parts:

```
npm run start [# of agents] [gpt-3.5-turbo|gpt-4]
```
1. agents-contoller - this is the control server for the agents
2. frontend - this is the FE that displays the information to/from the agents

Interact with the agents through the console. Anything you type will be sent as a message to all agents currently.

## Action errors

After spinning up a new agent, you will often see them make some mistakes which generate errors:

- Trying to use an action before they've asked for `help` on it to know what its parameters are
- Trying to just use a raw text response instead of a correctly-formatted action (or raw text wrapping a code block which contains a valid action)
- Trying to use a multi-line parameter value without wrapping it in the multiline delimiter (`% ff9d7713-0bb0-40d4-823c-5a66de48761b`)

This is a normal period of adjustment as they learn to operate themselves. They generally will learn from these mistakes and recover, although `gpt-3.5-turbo` agents sometimes devolve into endless error loops and can't figure out what the problem is. It's highly advised never to leave an agent unattended, since such infinite loops can eat through your tokens quickly (especially if they're stuck on a high-token-count action such as `writeFile`).

## Agent state

Each agent stores its state under the `.store` directory. Agent 1, for example, has
## Setup

```
.store/1/memory
.store/1/goals
.store/1/notes
```
[Agents-controller](./agents-controller/README.md)

You can simply delete any of these things, or the whole agent folder (or the whole `.store`) to selectively wipe whatever state you want between runs. Otherwise, agents will pick up where you left off on restart.
[frontend](./frontend/README.md)

A nice aspect of this is that when you want to debug a problem you ran into with a particular agent, you can delete the events in their memory subsequent to the point where the problem occurred, make changes to the code, and restart them to effectively replay that moment until you've fixed the bug. You can also ask an agent to implement a feature, and once they've done so you can restart, tell them that you've loaded the feature, and ask them to try it out.
#### note - You will need at least Node 10.
File renamed without changes.
12 changes: 10 additions & 2 deletions .eslintrc.js → agents-controller/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,28 @@ module.exports = {
browser: true,
es2021: true,
},
extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:react-hooks/recommended",
],
overrides: [],
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
ecmaFeatures: {
jsx: true,
},
},
plugins: ["@typescript-eslint"],
plugins: ["@typescript-eslint", "react", "react-hooks"],
rules: {
"object-shorthand": "warn",
"no-useless-rename": "warn",
"prefer-destructuring": "warn",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"react/react-in-jsx-scope": "off",
},
};
4 changes: 4 additions & 0 deletions agents-controller/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
dist
.env
.store
File renamed without changes.
File renamed without changes.
42 changes: 42 additions & 0 deletions agents-controller/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
### Install

```
npm install
```

### Configure

Create a `.env` file at the root of the project and add your secrets to it:

```
OPENAI_API_KEY=... # obtain from https://platform.openai.com/account/api-keys
# the following are needed for the agent to be able to search the web:
GOOGLE_SEARCH_ENGINE_ID=... # create a custom search engine at https://cse.google.com/cse/all
GOOGLE_API_KEY=... # obtain from https://console.cloud.google.com/apis/credentials
```

You'll also need to enable the Google Custom Search API for your Google Cloud account, e.g. <https://console.cloud.google.com/apis/library/customsearch.googleapis.com>

## Run

Start the program:

```
npm run start [# of agents] [gpt-3.5-turbo|gpt-4]
```

Interact with the agents through the console. Anything you type will be sent as a message to all agents currently.

### Agent state

Each agent stores its state under the `.store` directory. Agent 1, for example has

```
.store/1/memory
.store/1/goals
.store/1/notes
```

You can simply delete any of these things, or the whole agent folder (or the whole `.store`) to selectively wipe whatever state you want between runs. Otherwise agents will pick up where you left off on restart.

A nice aspect of this is that when you want to debug a problem you ran into with a particular agent, you can delete the events in their memory subsequent to the point where the problem occurred, make changes to the code, and restart them to effectively replay that moment until you've fixed the bug. You can also ask an agent to implement a feature, and once they've done so you can restart, tell them that you've loaded the feature and ask them to try it out.
File renamed without changes.
Loading