resolved conflicts between master and feature/weaviate-memory
commit
97ac802f0c
|
@ -15,4 +15,6 @@ WEAVIATE_PORT="8080"
|
||||||
WEAVIATE_USERNAME=
|
WEAVIATE_USERNAME=
|
||||||
WEAVIATE_PASSWORD=
|
WEAVIATE_PASSWORD=
|
||||||
WEAVIATE_INDEX="Autogpt"
|
WEAVIATE_INDEX="Autogpt"
|
||||||
MEMORY_PROVIDER="weaviate"
|
MEMORY_PROVIDER="weaviate"
|
||||||
|
IMAGE_PROVIDER=dalle
|
||||||
|
HUGGINGFACE_API_TOKEN=
|
||||||
|
|
11
README.md
11
README.md
|
@ -42,6 +42,7 @@ Your support is greatly appreciated
|
||||||
- [Setting up environment variables](#setting-up-environment-variables)
|
- [Setting up environment variables](#setting-up-environment-variables)
|
||||||
- [💀 Continuous Mode ⚠️](#-continuous-mode-️)
|
- [💀 Continuous Mode ⚠️](#-continuous-mode-️)
|
||||||
- [GPT3.5 ONLY Mode](#gpt35-only-mode)
|
- [GPT3.5 ONLY Mode](#gpt35-only-mode)
|
||||||
|
- [🖼 Image Generation](#image-generation)
|
||||||
- [⚠️ Limitations](#️-limitations)
|
- [⚠️ Limitations](#️-limitations)
|
||||||
- [🛡 Disclaimer](#-disclaimer)
|
- [🛡 Disclaimer](#-disclaimer)
|
||||||
- [🐦 Connect with Us on Twitter](#-connect-with-us-on-twitter)
|
- [🐦 Connect with Us on Twitter](#-connect-with-us-on-twitter)
|
||||||
|
@ -191,6 +192,7 @@ WEAVIATE_INDEX="Autogpt" # name of the index to create for the application
|
||||||
|
|
||||||
1. View memory usage by using the `--debug` flag :)
|
1. View memory usage by using the `--debug` flag :)
|
||||||
|
|
||||||
|
|
||||||
## 💀 Continuous Mode ⚠️
|
## 💀 Continuous Mode ⚠️
|
||||||
Run the AI **without** user authorisation, 100% automated.
|
Run the AI **without** user authorisation, 100% automated.
|
||||||
Continuous mode is not recommended.
|
Continuous mode is not recommended.
|
||||||
|
@ -209,6 +211,15 @@ If you don't have access to the GPT4 api, this mode will allow you to use Auto-G
|
||||||
python scripts/main.py --gpt3only
|
python scripts/main.py --gpt3only
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## 🖼 Image Generation
|
||||||
|
By default, Auto-GPT uses DALL-e for image generation. To use Stable Diffusion, a [HuggingFace API Token](https://huggingface.co/settings/tokens) is required.
|
||||||
|
|
||||||
|
Once you have a token, set these variables in your `.env`:
|
||||||
|
```
|
||||||
|
IMAGE_PROVIDER=sd
|
||||||
|
HUGGINGFACE_API_TOKEN="YOUR_HUGGINGFACE_API_TOKEN"
|
||||||
|
```
|
||||||
|
|
||||||
## ⚠️ Limitations
|
## ⚠️ Limitations
|
||||||
This experiment aims to showcase the potential of GPT-4 but comes with some limitations:
|
This experiment aims to showcase the potential of GPT-4 but comes with some limitations:
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import yaml
|
import yaml
|
||||||
import data
|
import data
|
||||||
|
import os
|
||||||
|
|
||||||
class AIConfig:
|
class AIConfig:
|
||||||
def __init__(self, ai_name="", ai_role="", ai_goals=[]):
|
def __init__(self, ai_name="", ai_role="", ai_goals=[]):
|
||||||
|
@ -9,7 +9,7 @@ class AIConfig:
|
||||||
self.ai_goals = ai_goals
|
self.ai_goals = ai_goals
|
||||||
|
|
||||||
# Soon this will go in a folder where it remembers more stuff about the run(s)
|
# Soon this will go in a folder where it remembers more stuff about the run(s)
|
||||||
SAVE_FILE = "../ai_settings.yaml"
|
SAVE_FILE = os.path.join(os.path.dirname(__file__), '..', 'ai_settings.yaml')
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def load(cls, config_file=SAVE_FILE):
|
def load(cls, config_file=SAVE_FILE):
|
||||||
|
|
|
@ -9,6 +9,7 @@ import ai_functions as ai
|
||||||
from file_operations import read_file, write_to_file, append_to_file, delete_file, search_files
|
from file_operations import read_file, write_to_file, append_to_file, delete_file, search_files
|
||||||
from execute_code import execute_python_file
|
from execute_code import execute_python_file
|
||||||
from json_parser import fix_and_parse_json
|
from json_parser import fix_and_parse_json
|
||||||
|
from image_gen import generate_image
|
||||||
from duckduckgo_search import ddg
|
from duckduckgo_search import ddg
|
||||||
from googleapiclient.discovery import build
|
from googleapiclient.discovery import build
|
||||||
from googleapiclient.errors import HttpError
|
from googleapiclient.errors import HttpError
|
||||||
|
@ -102,6 +103,8 @@ def execute_command(command_name, arguments):
|
||||||
return ai.write_tests(arguments["code"], arguments.get("focus"))
|
return ai.write_tests(arguments["code"], arguments.get("focus"))
|
||||||
elif command_name == "execute_python_file": # Add this command
|
elif command_name == "execute_python_file": # Add this command
|
||||||
return execute_python_file(arguments["file"])
|
return execute_python_file(arguments["file"])
|
||||||
|
elif command_name == "generate_image":
|
||||||
|
return generate_image(arguments["prompt"])
|
||||||
elif command_name == "task_complete":
|
elif command_name == "task_complete":
|
||||||
shutdown()
|
shutdown()
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -61,6 +61,9 @@ class Config(metaclass=Singleton):
|
||||||
self.weaviate_scopes = os.getenv("WEAVIATE_SCOPES", None)
|
self.weaviate_scopes = os.getenv("WEAVIATE_SCOPES", None)
|
||||||
self.weaviate_index = os.getenv("WEAVIATE_INDEX", 'auto-gpt')
|
self.weaviate_index = os.getenv("WEAVIATE_INDEX", 'auto-gpt')
|
||||||
|
|
||||||
|
self.image_provider = os.getenv("IMAGE_PROVIDER")
|
||||||
|
self.huggingface_api_token = os.getenv("HUGGINGFACE_API_TOKEN")
|
||||||
|
|
||||||
# User agent headers to use when browsing web
|
# User agent headers to use when browsing web
|
||||||
# Some websites might just completely deny request with an error code if no user agent was found.
|
# Some websites might just completely deny request with an error code if no user agent was found.
|
||||||
self.user_agent_header = {"User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36"}
|
self.user_agent_header = {"User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36"}
|
||||||
|
|
|
@ -23,6 +23,7 @@ COMMANDS:
|
||||||
17. Write Tests: "write_tests", args: "code": "<full_code_string>", "focus": "<list_of_focus_areas>"
|
17. Write Tests: "write_tests", args: "code": "<full_code_string>", "focus": "<list_of_focus_areas>"
|
||||||
18. Execute Python File: "execute_python_file", args: "file": "<file>"
|
18. Execute Python File: "execute_python_file", args: "file": "<file>"
|
||||||
19. Task Complete (Shutdown): "task_complete", args: "reason": "<reason>"
|
19. Task Complete (Shutdown): "task_complete", args: "reason": "<reason>"
|
||||||
|
20. Generate Image: "generate_image", args: "prompt": "<prompt>"
|
||||||
|
|
||||||
RESOURCES:
|
RESOURCES:
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,57 @@
|
||||||
|
import requests
|
||||||
|
import io
|
||||||
|
import os.path
|
||||||
|
from PIL import Image
|
||||||
|
from config import Config
|
||||||
|
import uuid
|
||||||
|
import openai
|
||||||
|
from base64 import b64decode
|
||||||
|
|
||||||
|
cfg = Config()
|
||||||
|
|
||||||
|
working_directory = "auto_gpt_workspace"
|
||||||
|
|
||||||
|
def generate_image(prompt):
|
||||||
|
|
||||||
|
filename = str(uuid.uuid4()) + ".jpg"
|
||||||
|
|
||||||
|
# DALL-E
|
||||||
|
if cfg.image_provider == 'dalle':
|
||||||
|
|
||||||
|
openai.api_key = cfg.openai_api_key
|
||||||
|
|
||||||
|
response = openai.Image.create(
|
||||||
|
prompt=prompt,
|
||||||
|
n=1,
|
||||||
|
size="256x256",
|
||||||
|
response_format="b64_json",
|
||||||
|
)
|
||||||
|
|
||||||
|
print("Image Generated for prompt:" + prompt)
|
||||||
|
|
||||||
|
image_data = b64decode(response["data"][0]["b64_json"])
|
||||||
|
|
||||||
|
with open(working_directory + "/" + filename, mode="wb") as png:
|
||||||
|
png.write(image_data)
|
||||||
|
|
||||||
|
return "Saved to disk:" + filename
|
||||||
|
|
||||||
|
# STABLE DIFFUSION
|
||||||
|
elif cfg.image_provider == 'sd':
|
||||||
|
|
||||||
|
API_URL = "https://api-inference.huggingface.co/models/CompVis/stable-diffusion-v1-4"
|
||||||
|
headers = {"Authorization": "Bearer " + cfg.huggingface_api_token}
|
||||||
|
|
||||||
|
response = requests.post(API_URL, headers=headers, json={
|
||||||
|
"inputs": prompt,
|
||||||
|
})
|
||||||
|
|
||||||
|
image = Image.open(io.BytesIO(response.content))
|
||||||
|
print("Image Generated for prompt:" + prompt)
|
||||||
|
|
||||||
|
image.save(os.path.join(working_directory, filename))
|
||||||
|
|
||||||
|
return "Saved to disk:" + filename
|
||||||
|
|
||||||
|
else:
|
||||||
|
return "No Image Provider Set"
|
Loading…
Reference in New Issue