Connecting the Dots: Simplifying Workflow Relationships with Ease v0.27.0

It’s time to unveil Griptape’s v0.27.0, a significant update packed with new features and enhancements that consolidate project Workflows, integrate AI, and improve overall system performance. Here’s a closer look into each of these features and how they can amplify your development projects.

We've also updated the default model in the Prompt Driver within both the AnthropicStructureConfig and AmazonBedrockStructureConfig to Claude 3.5 Sonnet. This change ensures that users benefit from the latest advancements in LLMs.

Smarter Task Management

Starting off, we introduce new methods to manage Task relationships within your projects more effectively. With BaseTask.add_child() and BaseTask.add_children(), you can easily structure your Tasks in a hierarchical order. For example, if you’re building a project that processes data and then generates reports, you can set the data processing Tasks as parents and the report generation Tasks as their children. This ensures Tasks are executed in the correct sequence, enhancing efficiency.

On the other hand, BaseTask.add_parent() and BaseTask.add_parents() allow you to link Tasks backwards by assigning parent Tasks after child Tasks have already been created. This flexibility is crucial for adapting to changes in project scopes where Tasks may evolve and depend on the outcomes of multiple predecessors. 

Additionally, the Structure.resolve_relationships() feature is available to ensure all necessary bi-directional relationships are established. This function automatically adds any missing links between Tasks, so if a parent Task has declared a child without a reciprocal declaration, it will be correctly recognized, ensuring that your project's Task hierarchy is complete and accurate.

It's also worth noting that Workflows and Pipelines automatically manage this logic for you. When you utilize these Structures to organize your Tasks, Structure.resolve_relationships() is applied to ensure all parent and child relationships are accurately established throughout your project's flow.

Visualization and Custom Controls

The new griptape.utils.StructureVisualizer offers a graphical representation of your Workflows using Mermaid.js, making it easier to visualize and communicate the flow and dependencies of various Tasks within your projects. This Tool is particularly helpful during team reviews or project audits, providing a clear and understandable diagram of complex processes. It’s also very useful when debugging Workflows. 

Additionally, ToolkitTask.response_stop_sequence introduces the ability to customize the conclusion of Tasks. This is especially useful in AI-driven conversational applications, where you might need to fine-tune how and when a dialogue should end based on user interactions.

from griptape.tasks import PromptTask
from griptape.structures import Workflow
from griptape.utils import StructureVisualizer


world_task = PromptTask(
    "Create a fictional world based on the following key words {{ keywords|join(', ') }}",
    context={
        "keywords": ["fantasy", "ocean", "tidal lock"]
    },
    id="world"
)

def character_task(task_id, character_name) -> PromptTask:
    return PromptTask(
        "Based on the following world description create a character named {{ name }}:\n{{ parent_outputs['world'] }}",
        context={
            "name": character_name
        },
        id=task_id,
        parent_ids=["world"]
    )

scotty_task = character_task("scotty", "Scotty")
annie_task = character_task("annie", "Annie")

story_task = PromptTask(
    "Based on the following description of the world and characters, write a short story:\n{{ parent_outputs['world'] }}\n{{ parent_outputs['scotty'] }}\n{{ parent_outputs['annie'] }}",
    id="story",
    parent_ids=["world", "scotty", "annie"]
)

workflow = Workflow(tasks=[world_task, story_task, scotty_task, annie_task, story_task])

print(StructureVisualizer(workflow).to_url())

workflow.run()

Enhanced AI Integration

Get excited — this update also enhances how you can integrate and leverage AI within your applications:

  • CohereEmbeddingDriver and CohereStructureConfig: Integrate Cohere’s language models into your applications to harness advanced natural language understanding specifically optimized for enterprise environments. Cohere's models excel in handling complex prompting and use cases such as automated customer support, sophisticated content curation, and dynamic interaction systems. This precision allows for enhanced accuracy in customer interactions and improved efficiency in content management, making them invaluable tools for businesses looking to leverage AI in their operations.
  • Amazon SageMaker Jumpstart Drivers: These Drivers have been refined to allow for more granular control when using Amazon SageMaker models. By specifying inference_component_name and custom_attributes, you can tailor model interactions to your specific needs, such as adjusting inference parameters for better performance in financial forecasting or image recognition Tasks.

import os

from dotenv import load_dotenv
from griptape.config import CohereStructureConfig
from griptape.drivers import CohereEmbeddingDriver
from griptape.structures import Agent

load_dotenv()

agent = Agent(config=CohereStructureConfig(api_key=os.environ["COHERE_API_KEY"]))

agent.run(
    'What is the sentiment of this review? Review: "I really enjoyed this movie!"'
)

embedding_driver=CohereEmbeddingDriver(
    model="embed-english-v3.0",
    api_key=os.environ["COHERE_API_KEY"],
    input_type="search_document",
)

embeddings = embedding_driver.embed_string("Hello world!")

# display the first 3 embeddings
print(embeddings[:3])

Breaking Changes and Improvements

We've made several breaking changes in this release to simplify and enhance the platform’s architecture. Notably, the Workflow system has been renovated to require explicit declaration of Task relationships, ensuring more precise and error-free configuration. This change helps eliminate unexpected behaviors in Task execution, leading to more predictable and reliable outcomes.

Learn more about this through Griptape’s TradeSchool!

We've also removed several outdated components and Drivers, such as the Bedrock model line and various tokenizers, to focus on more efficient and modern alternatives that offer enhanced performance and easier integration.

See our Changelog to look at the complete list of breaking changes.

Conclusion

Version 27 is designed to make your projects more efficient, your AI integrations smoother, and your management of complex systems clearer. By incorporating these new features and updates, developers can build applications that are not only powerful but also intuitive and aligned with current technology trends. We look forward to seeing how these enhancements will impact your projects for the better.