Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
nalbion committed Feb 13, 2024
1 parent 287aefb commit a91f41c
Show file tree
Hide file tree
Showing 5 changed files with 298 additions and 1 deletion.
26 changes: 26 additions & 0 deletions OAI_CONFIG_LIST.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# OAI_CONFIG_LIST

The `OAI_CONFIG_LIST.json` file is shared with [AutoGen] and allows you to keep your API keys separate from the `agent.yml` file which you may want to share with others.

You can also define `base_url`, `api_type`, `api_version` for use with Open Source models.

You can get your Open AI API key from the [API keys](https://platform.openai.com/api-keys) section in the platform site.

The `model` names here are sent to the Chat Completion service, so must match with the model names they use.

Example:

```json
[
{
"model": "gpt-4",
"api_key": "sk-1234"
},
{
"model": "gpt-4-1106-preview",
"api_key": "sk-7890"
}
]
```

[AutoGen]: https://github.com/microsoft/autogen
29 changes: 28 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# agent-adapters

Framework for configurable AI Agents.

Inspired by with [AutoGen](https://github.com/microsoft/autogen) and compatible with [AIConfig](https://aiconfig.lastmileai.dev/) and [Agent Protocol](https://agentprotocol.ai/). Can also download invoke and invoke arbitrary Agents as a subprocess.

## Installation

To install this library, you can use npm:
Expand All @@ -13,9 +17,32 @@ npm install agent-adapters
Import the library in your TypeScript/JavaScript file:

```typescript
import * as agentAdapters from "agent-adapters";
import { readAgentConfig, createAgent } from "agent-adapters";
```

## agents.yml

The `agents.yml` file is inspired by [AutoGen](https://github.com/microsoft/autogen) and is compatible with [AIConfig](https://aiconfig.lastmileai.dev/), with the additional condition that the `description` field must be provided as it is used by GitHub Copilot Chat and LLM-based routing.

`createAgent()` uses some of the optional properties of the `AgentConfig` to determine which type of Agent to create:

- `agent.routing.team` -> `RouterAgent` - see **Routing** below.
- `agent.remote` -> `AgentProtocolAgent` - refer [agentprotocol.ai](https://agentprotocol.ai/)
- `agent.cli.command` -> `CliClientAgent` - executes an Agent from a command line (useful for calling Python agents from Node.JS etc)
- `agent.llm_config.config_list` -> If an LLM has been configured will use OpenAI, local LLMs etc
- If No LLM has been configured, will attempt to use GitHub Copilot

If `agent.vscode === true` the Agent will be available by mentioning it by `@{name}` in VS Github Copilot Chat (when [ChatAgents2 proposal](https://code.visualstudio.com/api/advanced-topics/using-proposed-api#using-a-proposed-api) is released).

### Routing

All Agents automatically register themselves with the `AgentRegistry` upon construction.
Agents may use `AgentRegistry.searchAgents()` to search by name or `role`, and matching Agents will be ranked based on the `context`.

Note: Name your agents carefully - if an Agent attempts to send a message to another Agent by `role` (eg "developer") and an Agent exists with a **name** matching that role, it will receive the message.

- role: "developer", "tester" etc
- context: `{ language: ["javascript", "typescript"], platform: ["web"], framework: ["react"], ... }`

## Development

Expand Down
133 changes: 133 additions & 0 deletions agents.yml.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
# agents.yml Usage Guide

The `agents.yml` configuration file is inspired by [AutoGen] and is compatible with [AIConfig], with the additional condition that the `description` field must be provided as it is used by GitHub Copilot Chat and LLM-based routing.

When this extension first starts up, it will look in the following locations for an `agents.yml` file in the your home directory and in `~/.agents/`. If it does not find one it will create a new default config file.

You can ask to see your config file at any time:

> @agents /config
Any changes to this file will be immediately applied.

This extension will also scan for and read any [AIConfig] files (ending in `aiconfig.json`) in `~/` and `~/.agents/`.

# Structure of agents.yml

## config_list

This section is used to define the models and their corresponding [API keys](https://platform.openai.com/api-keys). For example:

```yaml
config_list:
- model: gpt-4
api_key: YOUR_API_KEY
- model: gpt-3.5-turbo
api_key: YOUR_API_KEY
```
This section is *optional* if you have a `OAI_CONFIG_LIST` environment variable or JSON file in `~/` or `~/.agents/` which could be shared by [AutoGen] and other libraries/frameworks.

## agents

`Copilot Agents` uses some of the optional properties of the `agent` descriptors to determine which type of Agent to create:

- `agent.routing.team` creates a `RouterAgent` - see **Routing** below.
- `agent.remote` creates an `AgentProtocolAgent` - refer [agentprotocol.ai](https://agentprotocol.ai)
- `agent.cli.command` creates a `CliClientAgent` - executes an Agent from a command line (useful for calling Python agents from Node.JS etc)
- `agent.llm_config.config_list` - If an LLM has been configured the agent will use OpenAI, local LLMs etc
- If No LLM has been configured, will attempt to use GitHub Copilot's chat completion service.

If `agent.vscode === true`

## Agent Properties

Each agent can have the following properties:

- `name`: The name of the agent. `/[a-zA-Z_]+/` - avoid dots, slashes etc.
- `description`: This will appear after the agent name when you mention it by `@name`.
- `schema_version`: Required, only if you want to use with [AIConfig]
- `metadata`: Skip this unless you're using with [AIConfig]
- `prompts`: Named prompts which your model can use. Some of the agents provided by this extension attempt to use a prompt named `background`.

- `vscode`: Set to `true` to have the Agent available by mentioning it by `@{name}` in VS Github Copilot Chat.
- `icon`: One of the [VS Code icon codes](https://code.visualstudio.com/api/references/icons-in-labels#icon-listing) or a URL to an online image.
- `models`: A list of model names to filter - eg `['gpt-4', 'gpt-3.5-turbo']`
These reference models defined in `agents[i].metadata.models`, `config_list` and `OAI_CONFIG_LIST`.
- `sample_request`: When the user clicks this agent in `/help`, this text will be submitted to this slash command.
- `commands`: A list of `{ name, description }` and optionally `sampleRequest`. The agent needs to be coded to process these.

The `metadata/models` section can be used to give aliases to the models, eg:

```yaml
agents:
- name: 10xDeveloper
description: An experienced software developer
metadata:
default_model: default
models:
default:
model: gpt-4
temperature: 0.5
fast:
model: gpt-3.5-turbo
temperature: 0.1
fun:
model: gpt-3.5-turbo
temperature: 2.0
```

## Agent Protocol

You can connect to an Agent running locally or remotely using `agents[i]/remote`.

Example:

```yaml
- name: AutoGPT
description: The power of AI accessible to everyone
icon: https://avatars.githubusercontent.com/u/130738209?s=32
vscode: true
remote:
base_url: http://localhost:8000
````
## Agent as CLI Process
You can spawn a new process to run an Agent written in any language.
```yaml
- name: evo_ninja
description: Research, analyse and build software
icon: https://evo.ninja/favicon.ico
vscode: true
git:
repo: https://github.com/polywrap/evo.ninja
branch: dev
baseDir: ~/.agents/evo.ninja
cli:
command: cmd.exe
args: ["/K", "yarn", "start"]
cwd: ~/.agents/evo.ninja
wait_for: "Enter another goal: "
```
The example above downloads and installs the agent from source, pulling the latest changes on every launch.
# Routing
All Agents automatically register themselves with the `AgentRegistry` upon construction.

*Note*: Name your agents carefully - if an Agent attempts to send a message to another Agent by `role` (eg "developer") and an Agent exists with a **name** matching that role, it will receive the message.

The RouterAgent and WorkflowManager use context fields to determine which Agent to route each user message to.

For example, a request to "create a new react web app" may result in the following context fields being set:

- role: "developer", "tester" etc
- language: ["javascript", "typescript"]
- platform: ["web"]
- framework: ["react"]

[AIConfig]: https://aiconfig.lastmileai.dev/
[AutoGen]: https://github.com/microsoft/autogen
30 changes: 30 additions & 0 deletions examples/default/agents.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
config_list:
- model: gpt-4
api_key: YOUR_API_KEY
- model: gpt-3.5-turbo
api_key: YOUR_API_KEY

agents:
- name: my-agent
description: Uses OpenAI's GPT-4 LLM
vscode: true
models: ["gpt-4"]
prompts:
- name: background
input: You are a helpful assistant
routing:
roles:
- developer

- name: evo_ninja
description: Research, analyse and build software
vscode: true
git:
repo: https://github.com/polywrap/evo.ninja
branch: dev
baseDir: ~/.agents/evo.ninja
cli:
command: cmd.exe
args: ["/K", "yarn", "start"]
cwd: ~/.agents/evo.ninja
wait_for: "Enter another goal: "
81 changes: 81 additions & 0 deletions examples/full/agents.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
config_list:
- model: gpt-4
api_key: YOUR_API_KEY
- model: gpt-3.5-turbo
api_key: YOUR_API_KEY

agents:
- name: 10xDeveloper
description: An experienced software developer
# /agents/[]/metadata/models is an AIConfig convention (https://aiconfig.lastmileai.dev)
metadata:
default_model: default
models:
default:
model: gpt-4
temperature: 0.5
fast:
model: gpt-3.5-turbo
temperature: 0.3

# /agents/[]/models can be used to filter the OAI_CONFIG_LIST model configs in /config_list
models: ["gpt-4"]

# /agents/[]/llm_config is used at runtime, but if not provided can be generated on initialisation
# from /config_list, /agents/[]/models and/or /agents/[]/metadata/models
llm_config:
config_list:
- model: gpt-4
api_key: YOUR_API_KEY
model_settings:
default:
model: gpt-4
temperature: 0.5

# Should the agent be available in the VSCode extension
vscode: true
# Fields used by the RouterAgent to determine which agent to use
routing:
roles: ["developer"]
context:
languages: ["c++", "python", "javascript", "java", "c#"]
prompts:
- name: "background"
input: |
You are an experienced software engineer who practices TDD and CI/CD.
You are familiar with the following:
- languages: C++, Python, JavaScript, Java, and C#.
- frameworks: React, Angular, Vue, Django, Flask, Spring, and .NET.
- databases: MySQL, PostgreSQL, MongoDB, and Redis.
- cloud platforms: AWS, Azure, and GCP.
- CI/CD tools: Jenkins, CircleCI, and TravisCI.
- containerization tools: Docker and Kubernetes.
- name: router
description: A router agent
vscode: true
models: ["gpt-4"]
routing:
team: ["10xDeveloper", "python_demo"]

- name: scrum
description: My AI scrum team
vscode: true
workflow_base_path: ~/.agents/workflows/scrum

- name: command_line
description: Talk to the command line
vscode: true
cli:
command: cmd.exe
args: ["/K"] # /K keeps the process open
# args: ["/C"] # /C closes the process after execution
# daemon: true

- name: python_demo
description: Python CLI client demo
vscode: true
cli:
# command: %HOME_PATH%\.pyenv\pyenv-win\shims\python
command: python
args: ["../AutoGen_Agent_Demo/agents/demo.py"]

0 comments on commit a91f41c

Please sign in to comment.