Skip to content

Commit

Permalink
Merge pull request #275 from griptape-ai:274-error-creating-agent-non…
Browse files Browse the repository at this point in the history
…etype-object-has-no-attribute-update

274-error-creating-agent-nonetype-object-has-no-attribute-update
  • Loading branch information
shhlife authored Feb 27, 2025
2 parents 0d2a38b + 7935120 commit a591cad
Show file tree
Hide file tree
Showing 16 changed files with 63 additions and 32 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
### Security -->

## [2.2.10] - 2025-27-02
### Added
- Added ability to use key value pair replacement with Griptape Cloud Assistant as well.
### Fixed
- Fixed issue with agent getting the following message: `Error creating agent: 'NoneType' object has no attribute 'update'`

## [2.2.09] - 2025-27-02
### Added
- `Key Value Pair` node to allow you to create a key/value pair and output it as a dictionary.
Expand Down
8 changes: 4 additions & 4 deletions nodes/agent/BaseAgent.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,10 @@ def rag_tool_ruleset(self, tools):

def add_context(self, **kwargs):
context = kwargs.get("key_value_replacement", None)
if isinstance(context, str):
context = ast.literal_eval(context)
self.agent.tasks[0].context = context
if context:
if isinstance(context, str):
context = ast.literal_eval(context)
self.agent.tasks[0].context = context

def tool_check(self, config, tools):
tool_list = []
Expand Down Expand Up @@ -221,7 +222,6 @@ def run(self, **kwargs):
create_dict["rulesets"] = []
# Now create the agent
self.agent = gtComfyAgent(**create_dict)

self.add_context(**kwargs)

# Warn for models
Expand Down
11 changes: 10 additions & 1 deletion nodes/agent/gtUICloudAssistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from griptape.tasks import AssistantTask

from ...py.griptape_settings import GriptapeSettings
from ..utilities import replace_with_context


class AnyType(str):
Expand Down Expand Up @@ -114,6 +115,12 @@ def INPUT_TYPES(cls):
"tooltip": "Additional text be appended to the STRING with a newline character.",
},
),
"key_value_replacement": (
"DICT",
{
"tooltip": "The will replace the {{ key }} with a value.",
},
),
"STRING": (
"STRING",
{
Expand Down Expand Up @@ -165,12 +172,14 @@ def run(self, **kwargs) -> Tuple[Any, ...]:
split_input_into_args = kwargs.get("split_input_into_args", False)

prompt_text = self.get_prompt_text(STRING, input_string).strip()
context = kwargs.get("key_value_replacement", None)
if context:
prompt_text = replace_with_context(prompt_text, context)
if split_input_into_args:
prompt_texts = prompt_text.split("\n")
else:
prompt_texts = [prompt_text]

print("Setting thread name")
self.assistant.set_thread_name(prompt_texts[0])

pipeline = Pipeline(
Expand Down
11 changes: 6 additions & 5 deletions nodes/tasks/gtUIBaseTask.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,10 @@ def INPUT_TYPES(cls):
# else:
# return ""
def get_context_as_dict(self, context):
if isinstance(context, str):
context = ast.literal_eval(context)
return context
if context:
if isinstance(context, str):
context = ast.literal_eval(context)
return context

def get_prompt_text(self, STRING, input_string):
# Get the prompt text
Expand Down Expand Up @@ -100,8 +101,8 @@ def run(self, **kwargs):
result = None
if not agent:
agent = Agent()
print(context)
agent.tasks[0].context = self.get_context_as_dict(context)
if context:
agent.tasks[0].context = self.get_context_as_dict(context)
prompt_text = self.get_prompt_text(STRING, input_string)
if deferred_evaluation:
try:
Expand Down
5 changes: 4 additions & 1 deletion nodes/tasks/gtUICloudStructureRunTask.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,11 @@ def run(self, **kwargs) -> Tuple[Any, ...]:
)
task = StructureRunTask(
structure_run_driver=structure_run_driver,
context=self.get_context_as_dict(kwargs.get("key_value_replacement", None)),
)
context = kwargs.get("key_value_replacement", None)
if context:
task.context = self.get_context_as_dict(context)

prev_task = agent.tasks[0]
try:
agent.add_task(task)
Expand Down
5 changes: 4 additions & 1 deletion nodes/tasks/gtUIExtractionTask.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,11 @@ def run(self, **kwargs):

task = ExtractionTask(
extraction_engine=engine,
context=self.get_context_as_dict(kwargs.get("key_value_replacement", None)),
) # type: ignore[reportArgumentType]
context = kwargs.get("key_value_replacement", None)
if context:
task.context = self.get_context_as_dict(context)

try:
agent.add_task(task)
except Exception as e:
Expand Down
5 changes: 4 additions & 1 deletion nodes/tasks/gtUIInpaintingImageGenerationTask.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,11 @@ def run(self, **kwargs):
input=(prompt_text, image_artifact, mask_artifact),
image_generation_driver=driver,
output_dir=output_dir,
context=self.get_context_as_dict(kwargs.get("key_value_replacement", None)),
)
context = kwargs.get("key_value_replacement", None)
if context:
inpainting_task.context = self.get_context_as_dict(context)

# if deferred_evaluation:
# return (None, "Image Variation Task Created", variation_task)
try:
Expand Down
6 changes: 3 additions & 3 deletions nodes/tasks/gtUIParallelImageQueryTask.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ def run(self, **kwargs):
task = PromptTask(
(prompt, [image_artifact]),
prompt_driver=prompt_driver,
context=self.get_context_as_dict(
kwargs.get("key_value_replacement", None)
),
)
context = kwargs.get("key_value_replacement", None)
if context:
task.context = self.get_context_as_dict(context)
prompt_tasks.append(task)

structure.insert_tasks(start_task, prompt_tasks, end_task)
Expand Down
4 changes: 3 additions & 1 deletion nodes/tasks/gtUIPromptImageGenerationTask.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,10 @@ def run(self, **kwargs) -> Tuple[Any, ...]:
input=prompt_text,
image_generation_driver=driver,
output_dir=output_dir,
context=self.get_context_as_dict(kwargs.get("key_value_replacement", None)),
)
context = self.get_context_as_dict(kwargs.get("key_value_replacement", None))
if context:
prompt_task.context = context
try:
pipeline = Pipeline()
pipeline.add_task(prompt_task)
Expand Down
4 changes: 3 additions & 1 deletion nodes/tasks/gtUIPromptImageVariationTask.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,10 @@ def run(self, **kwargs):
input=(prompt_text, image_artifact),
image_generation_driver=driver,
output_dir=output_dir,
context=self.get_context_as_dict(kwargs.get("key_value_replacement", None)),
)
context = self.get_context_as_dict(kwargs.get("key_value_replacement", None))
if context:
variation_task.context = context

# if deferred_evaluation:
# return (None, "Image Variation Task Created", variation_task)
Expand Down
3 changes: 2 additions & 1 deletion nodes/tasks/gtUITask.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ def run(self, **kwargs):
agent.add_task(task)
except Exception as e:
print(e)
agent.tasks[0].context = self.get_context_as_dict(context)
if context:
agent.tasks[0].context = self.get_context_as_dict(context)
result = agent.run()
output = result.output_task.output.value
if isinstance(output, str):
Expand Down
4 changes: 3 additions & 1 deletion nodes/tasks/gtUITextSummaryTask.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ def run(self, **kwargs) -> Tuple[Any, ...]:
prompt_text = self.get_prompt_text(STRING, input_string)
task = TextSummaryTask(
prompt_text,
context=self.get_context_as_dict(kwargs.get("key_value_replacement", None)),
)
context = kwargs.get("key_value_replacement", None)
if context:
task.context = self.get_context_as_dict(context)
# if deferred_evaluation:
# return ("Text Summary Task Created", agent, task)
try:
Expand Down
4 changes: 3 additions & 1 deletion nodes/tasks/gtUITextToSpeechTask.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@ def run(self, **kwargs) -> Tuple[Any, ...]:
task = TextToSpeechTask(
prompt_text,
text_to_speech_driver=driver,
context=self.get_context_as_dict(kwargs.get("key_value_replacement", None)),
)
context = self.get_context_as_dict(kwargs.get("key_value_replacement", None))
if context:
task.context = context
pipeline = Pipeline()
pipeline.add_task(task)
result = pipeline.run()
Expand Down
6 changes: 3 additions & 3 deletions nodes/tasks/gtUIToolTask.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ def run(self, **kwargs):
agent.add_task(
ToolTask(
tool=tool[0],
context=self.get_context_as_dict(
kwargs.get("key_value_replacement", None)
),
)
)
context = self.get_context_as_dict(kwargs.get("key_value_replacement", None))
if context:
agent.tasks[0].context = context
result = agent.run(prompt_text)
if isinstance(result.output_task.output.value, list):
output = result.output_task.output.value[0]
Expand Down
9 changes: 3 additions & 6 deletions nodes/tasks/gtUIToolkitTask.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,15 @@ def run(self, **kwargs):
if len(tools) == 0:
task = PromptTask(
prompt_text,
context=self.get_context_as_dict(
kwargs.get("key_value_replacement", None)
),
)
else:
task = ToolkitTask(
prompt_text,
tools=tools,
context=self.get_context_as_dict(
kwargs.get("key_value_replacement", None)
),
)
context = self.get_context_as_dict(kwargs.get("key_value_replacement", None))
if context:
task.context = context
# if deferred_evaluation:
# return ("Toolkit Task Created.", task)
try:
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "comfyui-griptape"
version = "2.2.09"
version = "2.2.10"
description = "Griptape LLM(Large Language Model) Nodes for ComfyUI."
authors = ["Jason Schleifer <[email protected]>"]
readme = "README.md"
Expand All @@ -9,7 +9,7 @@ readme = "README.md"
[project]
name = "comfyui-griptape"
description = "Griptape LLM(Large Language Model) Nodes for ComfyUI."
version = "2.2.09"
version = "2.2.10"
license = {file = "LICENSE"}
dependencies = ["attrs>=24.3.0,<26.0.0", "openai>=1.58.1,<2.0.0", "griptape[all]>=1.4.0", "python-dotenv", "poetry==1.8.5", "griptape-black-forest @ git+https://github.com/griptape-ai/griptape-black-forest.git", "griptape_serper_driver_extension @ git+https://github.com/mertdeveci5/griptape-serper-driver-extension.git"]

Expand Down

0 comments on commit a591cad

Please sign in to comment.