Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

Merge branch 'master' into command_registry

Peter Kreneskybcc1b5f8bf81
diff --cc scripts/image_gen.py
index 0000000000,185ed4278b..5bfbe3fc7b
mode 000000,100644..100644
--- a/scripts/image_gen.py
+++ b/scripts/image_gen.py
@@@ -1,0 -1,57 +1,58 @@@
+ 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"
+
++@command("generate_image", "Generate Image", '"prompt": "<prompt>"')
+ 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"
diff --cc scripts/main.py
index 4d7faa51b8,17385bf339..a27f22e367
--- a/scripts/main.py
+++ b/scripts/main.py
@@@ -285,17 -287,8 +286,16 @@@ if not cfg.pinecone_api_key or not cfg.
# this is particularly important for indexing and referencing pinecone memory
memory = PineconeMemory()
memory.clear()
-
print('Using memory of type: ' + memory.__class__.__name__)
+# Create a CommandRegistry instance and scan default folder
+command_registry = CommandRegistry()
+command_registry.import_commands('scripts.ai_functions')
+command_registry.import_commands('scripts.commands')
+command_registry.import_commands('scripts.execute_code')
+command_registry.import_commands('scripts.agent_manager')
+command_registry.import_commands('scripts.file_operations')
+
# Interaction Loop
while True:
# Send message to AI, get response