Skip to content

Commit d64f866

Browse files
dhensenwaynehamadi
authored andcommitted
Convert to python module named autogpt.
Also fixed the Dockerfile. Converting to module makes development easier. Fixes coverage script in CI and test imports.
1 parent a17a850 commit d64f866

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+352
-90
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ jobs:
3232
3333
- name: Lint with flake8
3434
continue-on-error: false
35-
run: flake8 scripts/ tests/ --select E303,W293,W291,W292,E305,E231,E302
35+
run: flake8 autogpt/ tests/ --select E303,W293,W291,W292,E305,E231,E302
3636

3737
- name: Run unittest tests with coverage
3838
run: |
39-
coverage run --source=scripts -m unittest discover tests
39+
coverage run --source=autogpt -m unittest discover tests
4040
4141
- name: Generate coverage report
4242
run: |

.gitignore

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
scripts/keys.py
2-
scripts/*json
3-
scripts/node_modules/
4-
scripts/__pycache__/keys.cpython-310.pyc
1+
autogpt/keys.py
2+
autogpt/*json
3+
autogpt/node_modules/
4+
autogpt/__pycache__/keys.cpython-310.pyc
55
package-lock.json
66
*.pyc
77
auto_gpt_workspace/*

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ COPY --chown=appuser:appuser requirements.txt .
1717
RUN pip install --no-cache-dir --user -r requirements.txt
1818

1919
# Copy the application files
20-
COPY --chown=appuser:appuser scripts/ .
20+
COPY --chown=appuser:appuser autogpt/ .
2121

2222
# Set the entrypoint
23-
ENTRYPOINT ["python", "main.py"]
23+
ENTRYPOINT ["python", "-m", "autogpt"]

README.md

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,11 @@ pip install -r requirements.txt
119119

120120
## 🔧 Usage
121121

122-
1. Run the `main.py` Python script in your terminal:
122+
1. Run the `autogpt` Python module in your terminal:
123123
_(Type this into your CMD window)_
124124

125125
```
126-
python scripts/main.py
126+
python -m autogpt
127127
```
128128

129129
2. After each of action, enter 'y' to authorise command, 'y -N' to run N continuous commands, 'n' to exit program, or enter additional feedback for the AI.
@@ -136,7 +136,21 @@ You will find activity and error logs in the folder `./output/logs`
136136
To output debug logs:
137137

138138
```
139-
python scripts/main.py --debug
139+
python -m autogpt --debug
140+
```
141+
142+
### Docker
143+
144+
You can also build this into a docker image and run it:
145+
146+
```
147+
docker build -t autogpt .
148+
docker run -it --env-file=./.env -v $PWD/auto_gpt_workspace:/app/auto_gpt_workspace autogpt
149+
```
150+
151+
You can pass extra arguments, for instance, running with `--gpt3only` and `--continuous` mode:
152+
```
153+
docker run -it --env-file=./.env -v $PWD/auto_gpt_workspace:/app/auto_gpt_workspace autogpt --gpt3only --continuous
140154
```
141155
### Command Line Arguments
142156
Here are some common arguments you can use when running Auto-GPT:
@@ -152,7 +166,7 @@ Here are some common arguments you can use when running Auto-GPT:
152166
Use this to use TTS for Auto-GPT
153167

154168
```
155-
python scripts/main.py --speak
169+
python -m autogpt --speak
156170
```
157171

158172
## 🔍 Google API Keys Configuration
@@ -328,10 +342,10 @@ Continuous mode is not recommended.
328342
It is potentially dangerous and may cause your AI to run forever or carry out actions you would not usually authorise.
329343
Use at your own risk.
330344

331-
1. Run the `main.py` Python script in your terminal:
345+
1. Run the `autogpt` python module in your terminal:
332346

333347
```
334-
python scripts/main.py --continuous
348+
python -m autogpt --speak --continuous
335349
336350
```
337351

@@ -342,7 +356,7 @@ python scripts/main.py --continuous
342356
If you don't have access to the GPT4 api, this mode will allow you to use Auto-GPT!
343357

344358
```
345-
python scripts/main.py --gpt3only
359+
python -m autogpt --speak --gpt3only
346360
```
347361

348362
It is recommended to use a virtual machine for tasks that require high security measures to prevent any potential harm to the main computer's system and data.
@@ -415,8 +429,8 @@ This project uses [flake8](https://flake8.pycqa.org/en/latest/) for linting. We
415429
To run the linter, run the following command:
416430

417431
```
418-
flake8 scripts/ tests/
432+
flake8 autogpt/ tests/
419433
420434
# Or, if you want to run flake8 with the same configuration as the CI:
421-
flake8 scripts/ tests/ --select E303,W293,W291,W292,E305,E231,E302
435+
flake8 autogpt/ tests/ --select E303,W293,W291,W292,E305,E231,E302
422436
```
File renamed without changes.

scripts/main.py renamed to autogpt/__main__.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import json
22
import random
3-
import commands as cmd
4-
import utils
5-
from memory import get_memory, get_supported_memory_backends
6-
import chat
3+
from autogpt import commands as cmd
4+
from autogpt import utils
5+
from autogpt.memory import get_memory, get_supported_memory_backends
6+
from autogpt import chat
77
from colorama import Fore, Style
8-
from spinner import Spinner
8+
from autogpt.spinner import Spinner
99
import time
10-
import speak
11-
from config import Config
12-
from json_parser import fix_and_parse_json
13-
from ai_config import AIConfig
10+
from autogpt import speak
11+
from autogpt.config import Config
12+
from autogpt.json_parser import fix_and_parse_json
13+
from autogpt.ai_config import AIConfig
1414
import traceback
1515
import yaml
1616
import argparse

scripts/agent_manager.py renamed to autogpt/agent_manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from llm_utils import create_chat_completion
1+
from autogpt.llm_utils import create_chat_completion
22

33
next_key = 0
44
agents = {} # key, (task, full_message_history, model)
File renamed without changes.

scripts/ai_functions.py renamed to autogpt/ai_functions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from typing import List
22
import json
3-
from config import Config
4-
from call_ai_function import call_ai_function
3+
from autogpt.config import Config
4+
from autogpt.call_ai_function import call_ai_function
55
cfg = Config()
66

77

scripts/browse.py renamed to autogpt/browse.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import requests
22
from bs4 import BeautifulSoup
3-
from memory import get_memory
4-
from config import Config
5-
from llm_utils import create_chat_completion
3+
from autogpt.memory import get_memory
4+
from autogpt.config import Config
5+
from autogpt.llm_utils import create_chat_completion
66
from urllib.parse import urlparse, urljoin
77

88
cfg = Config()

scripts/call_ai_function.py renamed to autogpt/call_ai_function.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
from config import Config
2-
1+
from autogpt.config import Config
32
cfg = Config()
43

5-
from llm_utils import create_chat_completion
4+
from autogpt.llm_utils import create_chat_completion
65

76

87
# This is a magic function that can do anything with no-code. See

scripts/chat.py renamed to autogpt/chat.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import time
22
import openai
33
from dotenv import load_dotenv
4-
from config import Config
5-
import token_counter
6-
from llm_utils import create_chat_completion
7-
from logger import logger
4+
from autogpt.config import Config
5+
from autogpt import token_counter
6+
from autogpt.llm_utils import create_chat_completion
7+
from autogpt.logger import logger
88
import logging
99

1010
cfg = Config()

scripts/commands.py renamed to autogpt/commands.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
import browse
1+
from autogpt import browse
22
import json
3-
from memory import get_memory
3+
from autogpt.memory import get_memory
44
import datetime
5-
import agent_manager as agents
6-
import speak
7-
from config import Config
8-
import ai_functions as ai
9-
from file_operations import read_file, write_to_file, append_to_file, delete_file, search_files
10-
from execute_code import execute_python_file, execute_shell
11-
from json_parser import fix_and_parse_json
12-
from image_gen import generate_image
5+
import autogpt.agent_manager as agents
6+
from autogpt import speak
7+
from autogpt.config import Config
8+
import autogpt.ai_functions as ai
9+
from autogpt.file_operations import read_file, write_to_file, append_to_file, delete_file, search_files
10+
from autogpt.execute_code import execute_python_file, execute_shell
11+
from autogpt.json_parser import fix_and_parse_json
12+
from autogpt.image_gen import generate_image
1313
from duckduckgo_search import ddg
1414
from googleapiclient.discovery import build
1515
from googleapiclient.errors import HttpError
File renamed without changes.

scripts/data_ingestion.py renamed to autogpt/data_ingestion.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import argparse
22
import logging
3-
from config import Config
4-
from memory import get_memory
5-
from file_operations import ingest_file, search_files
3+
from autogpt.config import Config
4+
from autogpt.memory import get_memory
5+
from autogpt.file_operations import ingest_file, search_files
66

77
cfg = Config()
88

File renamed without changes.
File renamed without changes.

scripts/image_gen.py renamed to autogpt/image_gen.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import io
33
import os.path
44
from PIL import Image
5-
from config import Config
5+
from autogpt.config import Config
66
import uuid
77
import openai
88
from base64 import b64decode

scripts/json_parser.py renamed to autogpt/json_parser.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import json
22
from typing import Any, Dict, Union
3-
from call_ai_function import call_ai_function
4-
from config import Config
5-
from json_utils import correct_json
6-
from logger import logger
3+
from autogpt.call_ai_function import call_ai_function
4+
from autogpt.config import Config
5+
from autogpt.json_utils import correct_json
6+
from autogpt.logger import logger
77

88
cfg = Config()
99

scripts/json_utils.py renamed to autogpt/json_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import re
22
import json
3-
from config import Config
3+
from autogpt.config import Config
44

55
cfg = Config()
66

scripts/llm_utils.py renamed to autogpt/llm_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import time
22
import openai
33
from colorama import Fore
4-
from config import Config
4+
from autogpt.config import Config
55

66
cfg = Config()
77

scripts/logger.py renamed to autogpt/logger.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88

99
from colorama import Style
1010

11-
import speak
12-
from config import Config
13-
from config import Singleton
11+
from autogpt import speak
12+
from autogpt.config import Config
13+
from autogpt.config import Singleton
1414

1515
cfg = Config()
1616

scripts/memory/__init__.py renamed to autogpt/memory/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
from memory.local import LocalCache
2-
from memory.no_memory import NoMemory
1+
from autogpt.memory.local import localcache
2+
from autogpt.memory.no_memory import NoMemory
33

44
# List of supported memory backends
55
# Add a backend to this list if the import attempt is successful

scripts/memory/base.py renamed to autogpt/memory/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Base class for memory providers."""
22
import abc
3-
from config import AbstractSingleton, Config
3+
from autogpt.config import AbstractSingleton, Config
44
import openai
55

66
cfg = Config()

scripts/memory/local.py renamed to autogpt/memory/local.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from typing import Any, List, Optional
44
import numpy as np
55
import os
6-
from memory.base import MemoryProviderSingleton, get_ada_embedding
6+
from autogpt.memory.base import MemoryProviderSingleton, get_ada_embedding
77

88

99
EMBED_DIM = 1536
File renamed without changes.

scripts/memory/pinecone.py renamed to autogpt/memory/pinecone.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from autogpt.config import Config, Singleton
12

23
import pinecone
34

scripts/memory/redismem.py renamed to autogpt/memory/redismem.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
from redis.commands.search.indexDefinition import IndexDefinition, IndexType
77
import numpy as np
88

9-
from memory.base import MemoryProviderSingleton, get_ada_embedding
10-
from logger import logger
9+
from autogpt.memory.base import MemoryProviderSingleton, get_ada_embedding
10+
from autogpt.logger import logger
1111
from colorama import Fore, Style
1212

1313

File renamed without changes.
File renamed without changes.

scripts/speak.py renamed to autogpt/speak.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import os
22
from playsound import playsound
33
import requests
4-
from config import Config
4+
from autogpt.config import Config
55
cfg = Config()
66
import gtts
77
import threading
File renamed without changes.
File renamed without changes.
File renamed without changes.

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ services:
88
- redis
99
build: ./
1010
volumes:
11-
- "./scripts:/app"
11+
- "./autogpt:/app"
1212
- ".env:/app/.env"
1313
profiles: ["exclude-from-up"]
1414

main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
from scripts.main import main
1+
from autogpt import main

0 commit comments

Comments
 (0)