Skip to content

Commit

Permalink
Merge pull request #172 from griptape-ai:removing_custom_config
Browse files Browse the repository at this point in the history
Removing_custom_config
  • Loading branch information
shhlife authored Nov 28, 2024
2 parents da0bf86 + 72d5586 commit aebc5ee
Show file tree
Hide file tree
Showing 17 changed files with 92 additions and 257 deletions.
13 changes: 2 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ You can previous and download more examples [here](examples/README.md).

### Nov 28, 2024
* ⚠️ **Temporarily removed BlackForestLabs Driver nodes while resolving install issues**. There appears to be an installation issue for these nodes, so I'm _temporarily_ removing them until it's resolved.
* Removed old configuration settings - now relying completely on ComfyUI's official settings

### Nov 27, 2024

Expand All @@ -116,19 +117,9 @@ You can previous and download more examples [here](examples/README.md).
### Nov 26, 2024
* Upgrade to Griptape Framework v0.34.3
* New Nodes:
* `Griptape Driver: Black Forest Labs Image Generation` - Now generate images with the incredible Flux models - `flux-pro-1.1`, `flux-pro`, `flux-dev`, and `flux-pro-1.1-ultra`.
- Requires an API_KEY from Black Forest Labs (https://docs.bfl.ml/)
- Utilizes new Griptape Extension: https://github.com/griptape-ai/griptape-black-forest

![Black Forest Labs - Create Image](examples/griptape_black_forest_labs_create_image.png)

- It also works with the `Griptape Create: Image Variation` node.

![Black Forest Labs - Image Variation](examples/griptape_black_forest_labs_create_variation.png)

* `Griptape Create: Image Inpainting Variation` to the Griptape -> Image menu. Gives the ability to paint a mask and replace that part of the image.

![Black Forest Labs - Inpainting](examples/griptape_black_forest_flux_inpainting.png)
![Inpainting](examples/inpainting.png)

* `Griptape Run: Task` - Combines/Replaces `Griptape Run: Prompt Task`, `Griptape Run: Tool Task`, and `Griptape Run Toolkit Task` into a single node that knows what to do.
* `Griptape Run: Text Extraction` to the Griptape -> Text menu
Expand Down
22 changes: 7 additions & 15 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,19 +291,8 @@
from .nodes.utils.gtUICreateAgentModelfile import gtUICreateAgentModelfile
from .nodes.utils.gtUICreateModelFromModelfile import gtUICreateModelFromModelfile
from .nodes.utils.gtUIRemoveOllamaModel import gtUIRemoveOllamaModel

# CONFIG
from .py.griptape_config import (
load_and_prepare_config,
)
from .py.griptape_settings import GriptapeSettings

# Setup to compute file paths relative to the directory containing this script

THIS_DIR = os.path.dirname(os.path.abspath(__file__))
DEFAULT_CONFIG_FILE = os.path.join(THIS_DIR, "griptape_config.json.default")
USER_CONFIG_FILE = os.path.join(THIS_DIR, "griptape_config.json")

# Load existing environment variables
load_dotenv()

Expand All @@ -312,9 +301,6 @@
# Initialize the routes
init_routes()

# Now load and prepare the configuration
config = load_and_prepare_config(DEFAULT_CONFIG_FILE, USER_CONFIG_FILE)

NODE_CLASS_MAPPINGS = {}
NODE_DISPLAY_NAME_MAPPINGS = {}
WEB_DIRECTORY = "./js"
Expand Down Expand Up @@ -483,15 +469,21 @@
}

# Let's do the settings

print(" \033[32m- Creating Settings\033[0m")
root = "Griptape"
print(" \033[32m- Instantiating\033[0m")
settings = GriptapeSettings()

print(" \033[32m- Getting key configuration\033[0m")
settings.get_key_config()
print(" \033[32m- Getting all services\033[0m")
settings.get_all_services()
for service in settings.all_services:
keys = settings.get_keys_for_service(service)
for key in keys:
settings.set_settings_key(f"{root}.{key}", os.getenv(key))

print(" \033[32m- Saving settings\033[0m")
settings.save_settings()

__all__ = ["NODE_CLASS_MAPPINGS", "WEB_DIRECTORY"]
Expand Down
41 changes: 21 additions & 20 deletions examples/Photographer-Workflow-Comparison-Example.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,14 @@
"type": "Griptape Create: Rules",
"pos": [
-100,
50
25
],
"size": [
400,
200
],
"flags": {},
"order": 0,
"order": 9,
"mode": 0,
"inputs": [],
"outputs": [
Expand All @@ -115,7 +115,7 @@
},
"widgets_values": [
"Cinematographer Ruleset",
"You identify as a cinematographer\nThe main subject of the image should be well framed\nIf no environment is specified, set the image in a location that will evoke a deep and meaningful connection to the viewer.\nYou care deeply about light, shadow, color, and composition\nWhen coming up with image prompts, you always specify the position of the camera, the lens, and the color\nYou are specific about the technical details of a shot.\nYour responses are brief and concise\nAlways respond with your identity so the agent knows who you are."
"You identify as a cinematographer\nThe main subject of the image should be well framed\nIf no environment is specified, set the image in a location that will evoke a deep and meaningful connection to the viewer.\nYou care deeply about light, shadow, color, and composition\nWhen coming up with image prompts, you always specify the position of the camera, the lens, and the color\nYou are specific about the technical details of a shot.\nYou like to add atmosphere to your shots, so you include depth of field, haze, dust particles in the air close to and far away from camera, and the way lighting reacts with each item.\nYour responses are brief and concise\nAlways respond with your identity so the agent knows who you are."
],
"color": "#233",
"bgcolor": "#355"
Expand All @@ -132,7 +132,7 @@
200
],
"flags": {},
"order": 1,
"order": 0,
"mode": 0,
"inputs": [],
"outputs": [
Expand Down Expand Up @@ -249,7 +249,7 @@
168.68878173828125
],
"flags": {},
"order": 2,
"order": 1,
"mode": 0,
"inputs": [],
"outputs": [
Expand Down Expand Up @@ -408,7 +408,7 @@
58
],
"flags": {},
"order": 3,
"order": 2,
"mode": 0,
"inputs": [],
"outputs": [
Expand Down Expand Up @@ -623,7 +623,7 @@
219.29710388183594
],
"flags": {},
"order": 9,
"order": 8,
"mode": 0,
"inputs": [],
"outputs": [
Expand All @@ -648,7 +648,7 @@
},
"widgets_values": [
"Agent Rules",
"You are creating a prompot for an image generation engine.\nYou have access to topic experts in their respective fields\nWork with the experts to get the results you need\nYou facilitate communication between them.\nIf they ask for feedback, you can provide it.\nAsk the expert on image prompting for the final prompt.\nOutput only the final image generation prompt. Do not wrap in markdown context."
"You are creating a prompt for an image generation engine.\nYou have access to topic experts in their respective fields\nWork with the experts to get the results you need\nYou facilitate communication between them.\nIf they ask for feedback, you can provide it.\nAsk the expert on image prompting for the final prompt.\nOutput only the final image generation prompt. Do not wrap in markdown context."
],
"color": "#233",
"bgcolor": "#355"
Expand Down Expand Up @@ -829,7 +829,7 @@
},
"widgets_values": [
"",
"High-angle shot from above of a faded lavender-colored stuffed bunny with a torn and frayed pink satin bow, sitting on a vintage, ornate music box in a dimly lit antique shop. The bunny has glassy plastic eyes and a worn velvet patch on its left ear, giving it a soft, dreamy appearance. Captured with a Red Epic-W camera using an 85mm T1.8 lens, the image features muted colors with blue undertones and pastel shades of pale pink or baby blue, creating a nostalgic and ethereal atmosphere."
"Stuffed bunny sitting on a worn, wooden workbench in an old, dimly lit antique shop. Camera at a 45-degree angle with a medium telephoto lens (50mm). Warm, golden light from a nearby window creates a soft, nostalgic glow on the bunny's fur, casting deep shadows across the workbench. Worn, velvety texture with a hand-sewn patch on its left ear, bright red rubber button nose, tiny golden bell around its neck. Colors clash with bright pink and white, creating visual tension. Dust particles float in the air, hint of old wood polish on the workbench, subtle haze outside the window."
],
"color": "#222",
"bgcolor": "#000"
Expand Down Expand Up @@ -964,7 +964,7 @@
106
],
"flags": {},
"order": 4,
"order": 3,
"mode": 0,
"inputs": [],
"outputs": [
Expand Down Expand Up @@ -1001,7 +1001,7 @@
200
],
"flags": {},
"order": 5,
"order": 4,
"mode": 0,
"inputs": [],
"outputs": [
Expand Down Expand Up @@ -1162,7 +1162,7 @@
26
],
"flags": {},
"order": 6,
"order": 5,
"mode": 0,
"inputs": [],
"outputs": [
Expand Down Expand Up @@ -1271,7 +1271,7 @@
106
],
"flags": {},
"order": 7,
"order": 6,
"mode": 0,
"inputs": [],
"outputs": [
Expand Down Expand Up @@ -1348,10 +1348,10 @@
],
"size": [
466.1999816894531,
332
356
],
"flags": {},
"order": 8,
"order": 7,
"mode": 0,
"inputs": [],
"outputs": [
Expand All @@ -1372,14 +1372,15 @@
"http://127.0.0.1",
"11434",
"Prompt Driver",
"llama3.1:latest",
"llama3.2:latest",
10,
0.1,
2048,
"fixed",
true,
-1,
"Embedding Driver",
240,
"nomic-embed-text:latest",
"nomic-embed-text:latest"
],
"color": "#2a363b",
Expand Down Expand Up @@ -1759,10 +1760,10 @@
"config": {},
"extra": {
"ds": {
"scale": 0.5644739300537773,
"scale": 0.23525020508613764,
"offset": [
-848.1325481151173,
359.3482043102513
1204.3115464816442,
1977.246169189889
]
},
"info": {
Expand Down
Binary file modified examples/Photographer-Workflow-Comparison-Example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/inpainting.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 11 additions & 11 deletions js/griptape_api_keys.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
export const keys_organized = {
"@Griptape": ["GRIPTAPE_CLOUD_API_KEY"],
OpenAI: ["OPENAI_API_KEY"],
Amazon: [
"OpenAI": ["OPENAI_API_KEY"],
"Amazon": [
"AWS_ACCESS_KEY_ID",
"AWS_SECRET_ACCESS_KEY",
"AWS_DEFAULT_REGION",
"AMAZON_OPENSEARCH_HOST",
"AMAZON_OPENSEARCH_INDEX_NAME",
],
Anthropic: ["ANTHROPIC_API_KEY"],
"Anthropic": ["ANTHROPIC_API_KEY"],
"Microsoft Azure": [
"AZURE_OPENAI_ENDPOINT",
"AZURE_OPENAI_DALL_E_3_ENDPOINT",
"AZURE_OPENAI_DALL_E_3_API_KEY",
"AZURE_OPENAI_API_KEY",
],
Cohere: ["COHERE_API_KEY"],
"Cohere": ["COHERE_API_KEY"],
"Eleven Labs": ["ELEVEN_LABS_API_KEY"],
Exa: ["EXA_API_KEY"],
Groq: ["GROQ_API_KEY"],
Google: ["GOOGLE_API_KEY", "GOOGLE_API_SEARCH_ID"],
Huggingface: ["HUGGINGFACE_HUB_ACCESS_TOKEN"],
LeonardoAI: ["LEONARDO_API_KEY"],
Pinecone: ["PINECONE_API_KEY", "PINECONE_ENVIRONMENT", "PINECONE_INDEX_NAME"],
Tavily: ["TAVILY_API_KEY"],
"Exa": ["EXA_API_KEY"],
"Groq": ["GROQ_API_KEY"],
"Google": ["GOOGLE_API_KEY", "GOOGLE_API_SEARCH_ID"],
"Huggingface": ["HUGGINGFACE_HUB_ACCESS_TOKEN"],
"LeonardoAI": ["LEONARDO_API_KEY"],
"Pinecone": ["PINECONE_API_KEY", "PINECONE_ENVIRONMENT", "PINECONE_INDEX_NAME"],
"Tavily": ["TAVILY_API_KEY"],
};
7 changes: 7 additions & 0 deletions js/gtUINodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ app.registerExtension({
api.addEventListener("comfy.gtUI.runagent", messageHandler);

// Create the settings
app.ui.settings.addSetting({
id: `Griptape.default_config`,
category: ["Griptape", "@Griptape", "default_config"],
name: "default_config",
type: "dict",
defaultValue: "",
});
Object.entries(keys_organized).forEach(([category, keys]) => {
keys.forEach((key) => {
app.ui.settings.addSetting({
Expand Down
6 changes: 4 additions & 2 deletions nodes/agent/BaseAgent.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,18 @@
from griptape.tools import QueryTool, RagTool, VectorStoreTool
from openai import OpenAIError

from ...py.griptape_settings import GriptapeSettings

# from server import PromptServer
from ...py.griptape_config import get_config
from .gtComfyAgent import gtComfyAgent

default_prompt = "{{ input_string }}"
max_attempts_default = 10


def get_default_config():
return get_config("agent_config")
settings = GriptapeSettings()
return settings.get_settings_key("default_config")


class BaseAgent:
Expand Down
28 changes: 0 additions & 28 deletions nodes/agent/SetDefaultAgent.py

This file was deleted.

Loading

0 comments on commit aebc5ee

Please sign in to comment.