Skip to content

Commit

Permalink
Merge pull request #209 from griptape-ai:fix/structure-run
Browse files Browse the repository at this point in the history
Fix/structure-run
  • Loading branch information
shhlife authored Jan 1, 2025
2 parents 4580062 + 843390e commit 664559b
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 11 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
### Security -->

## [2.0.16] - 2025-02-01
### Added
- [Example](examples/README.md#sorting-a-csv---by-using-generic-python) for using the `Griptape Code: Run Python` node.
![](examples/sort_list_with_python_code.png)
### Fixed
- Templates not listed for `Griptape Code: Run Python` node.

## [2.0.15] - 2025-02-01
### Added
- `Griptape Code: Run Griptape Cloud Structure` - Runs a structure from [Griptape Cloud Structures](https://cloud.griptape.ai/structures). Requres a `GRIPTAPE_CLOUD_API_KEY` and a `structure_id`.
Expand Down
10 changes: 9 additions & 1 deletion examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,12 @@ Download: [OffPrompt.json](OffPromopt.json)
Use Retrieval Augmented Generation to have more control over the data your agents can query. Check out this example which demonstrates multiple data sources, reranking results, and controlling the responses.

![RAG](retrieval_augmented_generation.png)
Download: [retrieval_augmented_generation.json](retrieval_augmented_generation.json)
Download: [retrieval_augmented_generation.json](retrieval_augmented_generation.json)

## Sorting a CSV - by using generic Python!
With the `Griptape Code: Run Python` node, you can use generic Python code to work with data. This node requires turning on the `Enable Griptape Code: Run Python Nodes` setting to be enabled.

![alt text](run_python_nodes.png)

![Run Python](sort_list_with_python_code.png)
Download: [sort_list_with_python_code.png](sort_list_with_python_code.png)
Binary file added examples/run_python_nodes.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/sort_list_with_python_code.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion js/CodeExecutionNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { code_execution_templates } from "./CodeExecutionNodeTemplates.js";
const code_execution_template_keys = Object.keys(code_execution_templates);

export function setupCodeExecutionNode(nodeType, nodeData, app) {
if (nodeData.name.includes("Code Execution"))
if (nodeData.name.includes("Run Python"))
{
// Add menu items to examples dropdown
const onNodeCreated = nodeType.prototype.onNodeCreated;
Expand Down
5 changes: 3 additions & 2 deletions nodes/tasks/gtUICloudStructureRunTask.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def INPUT_TYPES(cls):
"STRING",
{
"placeholder": "xxxx-xxxx-xxxx-xxxx",
"default": "101b5ee6-ba7c-412d-9833-1d663981ced2",
"default": "",
},
),
"split_input_into_args": (
Expand Down Expand Up @@ -73,8 +73,9 @@ def run(self, **kwargs) -> Tuple[Any, ...]:
try:
agent.add_task(task)
result = agent.run([arg for arg in prompt_texts if arg.strip()])
value = result.output_task.output.value
agent.add_task(prev_task)
return (result.output_task.output.value, agent)
return (value, agent)
except Exception as e:
return (str(e), None)
print(e)
10 changes: 5 additions & 5 deletions nodes/tasks/gtUICodeExecutionTask.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,6 @@ def sort_numbers(numbers):
def run(self, **kwargs) -> Tuple[Any, ...]:
STRING = kwargs.get("input")
unique_id = kwargs.get("unique_id", None)
print(unique_id)
# input_string = kwargs.get("input_string", None)
code = kwargs.get("code", None)
agent = kwargs.get("agent", None)
Expand All @@ -310,7 +309,6 @@ def run(self, **kwargs) -> Tuple[Any, ...]:
code_execution_dangerous = settings.get_settings_key(
"allow_code_execution_dangerous"
)
print(code_execution)
# code_execution = kwargs.get("code_execution", False)
if not code_execution:
return (
Expand All @@ -336,11 +334,13 @@ def run(self, **kwargs) -> Tuple[Any, ...]:

# Build the task
dynamic_task = build_CodeExecutionTask(code)

prev_task = agent.tasks[0]
try:
agent.add_task(dynamic_task)
result = agent.run(prompt)
return (result.output_task.output.value, agent, dynamic_task)
value = result.output_task.output.value
agent.add_task(prev_task)
return (value, agent)
except Exception as e:
return (str(e), None, None)
return (str(e), None)
print(e)
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.0.15"
version = "2.0.16"
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.0.15"
version = "2.0.16"
license = {file = "LICENSE"}
dependencies = ["griptape[all]==^1.0.2", "python-dotenv", "poetry==1.8.4", "griptape-black-forest @ git+https://github.com/griptape-ai/griptape-black-forest.git"]

Expand Down

0 comments on commit 664559b

Please sign in to comment.