Skip to content

Commit

Permalink
Merge branch 'fix_remove_colors_dict_bug' of https://github.com/pr-0f…
Browse files Browse the repository at this point in the history
…3t/Auto-GPT into fix_remove_colors_dict_bug
  • Loading branch information
lc0rp committed Apr 30, 2023
2 parents 1b0efeb + 0fd225b commit 15a5fbc
Show file tree
Hide file tree
Showing 30 changed files with 2,895 additions and 238 deletions.
31 changes: 9 additions & 22 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,26 +1,13 @@
# [Choice] Python version (use -bullseye variants on local arm64/Apple Silicon): 3, 3.10, 3-bullseye, 3.10-bullseye, 3-buster, 3.10-buster
ARG VARIANT=3-bullseye
# Use an official Python base image from the Docker Hub
FROM python:3.10

RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# Remove imagemagick due to https://security-tracker.debian.org/tracker/CVE-2019-10131
&& apt-get purge -y imagemagick imagemagick-6-common
# Install browsers
RUN apt-get update && apt-get install -y \
chromium-driver firefox-esr \
ca-certificates

# Temporary: Upgrade python packages due to https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-40897
# They are installed by the base image (python) which does not have the patch.
RUN python3 -m pip install --upgrade setuptools
# Install utilities
RUN apt-get install -y curl jq wget git

# Install Chromium for web browsing
RUN apt-get install -y chromium-driver

# [Optional] If your pip requirements rarely change, uncomment this section to add them to the image.
# COPY requirements.txt /tmp/pip-tmp/
# RUN pip3 --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requirements.txt \
# && rm -rf /tmp/pip-tmp

# [Optional] Uncomment this section to install additional OS packages.
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# && apt-get -y install --no-install-recommends <your-package-list-here>

# [Optional] Uncomment this line to install global node packages.
# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1
# Declare working directory
WORKDIR /workspace/Auto-GPT
12 changes: 6 additions & 6 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"build": {
"dockerfile": "./Dockerfile",
"context": "."
},
"dockerComposeFile": "./docker-compose.yml",
"service": "auto-gpt",
"workspaceFolder": "/workspace/Auto-GPT",
"shutdownAction": "stopCompose",
"features": {
"ghcr.io/devcontainers/features/common-utils:2": {
"installZsh": "true",
"username": "vscode",
"userUid": "1000",
"userGid": "1000",
"userUid": "6942",
"userGid": "6942",
"upgradePackages": "true"
},
"ghcr.io/devcontainers/features/desktop-lite:1": {},
Expand Down
19 changes: 19 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# To boot the app run the following:
# docker-compose run auto-gpt
version: '3.9'

services:
auto-gpt:
depends_on:
- redis
build:
dockerfile: .devcontainer/Dockerfile
context: ../
tty: true
environment:
MEMORY_BACKEND: ${MEMORY_BACKEND:-redis}
REDIS_HOST: ${REDIS_HOST:-redis}
volumes:
- ../:/workspace/Auto-GPT
redis:
image: 'redis/redis-stack-server:latest'
19 changes: 19 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,22 @@ When you run Pytest locally:
- Or: The test might be poorly written. In that case, you can make suggestions to change the test.

In our CI pipeline, Pytest will use the cassettes and not call paid API providers, so we need your help to record the replays that you break.


### Community Challenges
Challenges are goals we need Auto-GPT to achieve.
To pick the challenge you like, go to the tests/integration/challenges folder and select the areas you would like to work on.
- a challenge is new if level_currently_beaten is None
- a challenge is in progress if level_currently_beaten is greater or equal to 1
- a challenge is beaten if level_currently_beaten = max_level

Here is an example of how to run the memory challenge A and attempt to beat level 3.

pytest -s tests/integration/challenges/memory/test_memory_challenge_a.py --level=3

To beat a challenge, you're not allowed to change anything in the tests folder, you have to add code in the autogpt folder

Challenges use cassettes. Cassettes allow us to replay your runs in our CI pipeline.
Don't hesitate to delete the cassettes associated to the challenge you're working on if you need to. Otherwise it will keep replaying the last run.

Once you've beaten a new level of a challenge, please create a pull request and we will analyze how you changed Auto-GPT to beat the challenge.
3 changes: 1 addition & 2 deletions autogpt/agent/agent_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
from typing import List

from autogpt.config.config import Config
from autogpt.llm import create_chat_completion
from autogpt.llm import Message, create_chat_completion
from autogpt.singleton import Singleton
from autogpt.types.openai import Message


class AgentManager(metaclass=Singleton):
Expand Down
2 changes: 1 addition & 1 deletion autogpt/commands/file_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ def download_file(url, filename):
progress = f"{readable_file_size(downloaded_size)} / {readable_file_size(total_size)}"
spinner.update_message(f"{message} {progress}")

return f'Successfully downloaded and locally stored file: "{filename}"! (Size: {readable_file_size(total_size)})'
return f'Successfully downloaded and locally stored file: "{filename}"! (Size: {readable_file_size(downloaded_size)})'
except requests.HTTPError as e:
return f"Got an HTTP Error whilst trying to download file: {e}"
except Exception as e:
Expand Down
12 changes: 6 additions & 6 deletions autogpt/commands/git_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,25 @@
@command(
"clone_repository",
"Clone Repository",
'"repository_url": "<repository_url>", "clone_path": "<clone_path>"',
'"url": "<repository_url>", "clone_path": "<clone_path>"',
CFG.github_username and CFG.github_api_key,
"Configure github_username and github_api_key.",
)
@validate_url
def clone_repository(repository_url: str, clone_path: str) -> str:
def clone_repository(url: str, clone_path: str) -> str:
"""Clone a GitHub repository locally.
Args:
repository_url (str): The URL of the repository to clone.
url (str): The URL of the repository to clone.
clone_path (str): The path to clone the repository to.
Returns:
str: The result of the clone operation.
"""
split_url = repository_url.split("//")
split_url = url.split("//")
auth_repo_url = f"//{CFG.github_username}:{CFG.github_api_key}@".join(split_url)
try:
Repo.clone_from(auth_repo_url, clone_path)
return f"""Cloned {repository_url} to {clone_path}"""
Repo.clone_from(url=auth_repo_url, to_path=clone_path)
return f"""Cloned {url} to {clone_path}"""
except Exception as e:
return f"Error: {str(e)}"
16 changes: 16 additions & 0 deletions autogpt/llm/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
from autogpt.llm.api_manager import ApiManager
from autogpt.llm.base import (
ChatModelInfo,
ChatModelResponse,
EmbeddingModelInfo,
EmbeddingModelResponse,
LLMResponse,
Message,
ModelInfo,
)
from autogpt.llm.chat import chat_with_ai, create_chat_message, generate_context
from autogpt.llm.llm_utils import (
call_ai_function,
Expand All @@ -10,6 +19,13 @@

__all__ = [
"ApiManager",
"Message",
"ModelInfo",
"ChatModelInfo",
"EmbeddingModelInfo",
"LLMResponse",
"ChatModelResponse",
"EmbeddingModelResponse",
"create_chat_message",
"generate_context",
"chat_with_ai",
Expand Down
65 changes: 65 additions & 0 deletions autogpt/llm/base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
from dataclasses import dataclass, field
from typing import List, TypedDict


class Message(TypedDict):
"""OpenAI Message object containing a role and the message content"""

role: str
content: str


@dataclass
class ModelInfo:
"""Struct for model information.
Would be lovely to eventually get this directly from APIs, but needs to be scraped from
websites for now.
"""

name: str
prompt_token_cost: float
completion_token_cost: float
max_tokens: int


@dataclass
class ChatModelInfo(ModelInfo):
"""Struct for chat model information."""

pass


@dataclass
class EmbeddingModelInfo(ModelInfo):
"""Struct for embedding model information."""

embedding_dimensions: int


@dataclass
class LLMResponse:
"""Standard response struct for a response from an LLM model."""

model_info: ModelInfo
prompt_tokens_used: int = 0
completion_tokens_used: int = 0


@dataclass
class EmbeddingModelResponse(LLMResponse):
"""Standard response struct for a response from an embedding model."""

embedding: List[float] = field(default_factory=list)

def __post_init__(self):
if self.completion_tokens_used:
raise ValueError("Embeddings should not have completion tokens used.")


@dataclass
class ChatModelResponse(LLMResponse):
"""Standard response struct for a response from an LLM model."""

content: str = None
2 changes: 1 addition & 1 deletion autogpt/llm/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@

from autogpt.config import Config
from autogpt.llm.api_manager import ApiManager
from autogpt.llm.base import Message
from autogpt.llm.llm_utils import create_chat_completion
from autogpt.llm.token_counter import count_message_tokens
from autogpt.logs import logger
from autogpt.memory_management.store_memory import (
save_memory_trimmed_from_context_window,
)
from autogpt.types.openai import Message

cfg = Config()

Expand Down
2 changes: 1 addition & 1 deletion autogpt/llm/llm_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

from autogpt.config import Config
from autogpt.llm.api_manager import ApiManager
from autogpt.llm.base import Message
from autogpt.logs import logger
from autogpt.types.openai import Message


def retry_openai_api(
Expand Down
Empty file.
37 changes: 37 additions & 0 deletions autogpt/llm/providers/openai.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
from autogpt.llm.base import ChatModelInfo, EmbeddingModelInfo

OPEN_AI_CHAT_MODELS = {
"gpt-3.5-turbo": ChatModelInfo(
name="gpt-3.5-turbo",
prompt_token_cost=0.002,
completion_token_cost=0.002,
max_tokens=4096,
),
"gpt-4": ChatModelInfo(
name="gpt-4",
prompt_token_cost=0.03,
completion_token_cost=0.06,
max_tokens=8192,
),
"gpt-4-32k": ChatModelInfo(
name="gpt-4-32k",
prompt_token_cost=0.06,
completion_token_cost=0.12,
max_tokens=32768,
),
}

OPEN_AI_EMBEDDING_MODELS = {
"text-embedding-ada-002": EmbeddingModelInfo(
name="text-embedding-ada-002",
prompt_token_cost=0.0004,
completion_token_cost=0.0,
max_tokens=8191,
embedding_dimensions=1536,
),
}

OPEN_AI_MODELS = {
**OPEN_AI_CHAT_MODELS,
**OPEN_AI_EMBEDDING_MODELS,
}
2 changes: 1 addition & 1 deletion autogpt/llm/token_counter.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

import tiktoken

from autogpt.llm.base import Message
from autogpt.logs import logger
from autogpt.types.openai import Message


def count_message_tokens(
Expand Down
9 changes: 0 additions & 9 deletions autogpt/types/openai.py

This file was deleted.

2 changes: 1 addition & 1 deletion docs/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ python -m pytest
:::shell
pytest --cov=autogpt --without-integration --without-slow-integration

## Runing the linter
## Running the linter

This project uses [flake8](https://flake8.pycqa.org/en/latest/) for linting.
We currently use the following rules: `E303,W293,W291,W292,E305,E231,E302`.
Expand Down
23 changes: 20 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,25 @@
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "auto-gpt"
version = "0.1.0"
description = "A GPT based ai agent"
name = "agpt"
version = "0.2.2"
authors = [
{ name="Torantulino", email="[email protected]" },
]
readme = "README.md"
requires-python = ">=3.10"
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
]
description = "An open-source attempt to make GPT-4 autonomous"

[project.urls]
"Homepage" = "https://github.com/Significant-Gravitas/Auto-GPT"
"Bug Tracker" = "https://github.com/Significant-Gravitas/Auto-GPT"

[tool.black]
line-length = 88
Expand Down
29 changes: 0 additions & 29 deletions tests/browse_tests.py

This file was deleted.

Loading

0 comments on commit 15a5fbc

Please sign in to comment.