Enhanced Functionality and Streamlined Operations V0.29.0

Griptape’s latest software update is packed with enhancements designed to boost the efficiency and flexibility of your applications. From new Drivers to critical API updates, this release focuses on improving your development experience and expanding the capabilities of your projects. Let's delve into the key updates and explore how they can transform the way you work.

Prompt Drivers Now Support Native Function Calling

One of the standout features of this release is the introduction of native function calling support across several of our Prompt Drivers, including the OpenAiChatPromptDriver, AzureOpenAiChatPromptDriver, and others. This new capability allows these Drivers to execute native functions effortlessly, greatly enhancing their integration capabilities. For instance, an application using the OpenAiChatPromptDriver can now directly call native functions to fetch real-time data or perform computations without needing intermediary scripts or tools. This direct integration helps in reducing latency, simplifying the codebase, and speeding up the overall response time of applications.

Streamlined API Usage Through Keyword-Only Arguments

To enhance clarity and prevent errors in API usage, we have updated several functions in the BaseVectorStoreDriver to require keyword-only arguments. This change forces clearer specification of parameters, reducing bugs and misunderstandings in function calls. It promotes better coding practices and improves the maintainability of the code by making the functions' intentions and requirements explicit.

OllamaEmbeddingDriver: Powering Advanced Language Understanding

The new OllamaEmbeddingDriver is a game-changer for applications that rely on deep language understanding. This Driver specializes in generating high-quality embeddings, which are critical for tasks that involve semantic analysis, such as content recommendation systems or customer service bots. By accurately understanding the context and nuances of language, the OllamaEmbeddingDriver enables applications to deliver more relevant and personalized content, enhancing user engagement and satisfaction.

from griptape.drivers import OllamaEmbeddingDriver

driver = OllamaEmbeddingDriver(
    model="all-minilm",
)

results = driver.embed_string("Hello world!")

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

Simplifying Data Retrieval with GriptapeCloudKnowledgeBaseVectorStoreDriver

Our GriptapeCloudKnowledgeBaseVectorStoreDriver simplifies how you interact with large volumes of structured knowledge stored in the cloud, it’s specifically used with the Knowledge Bases in Griptape Cloud. This Driver allows for efficient querying of cloud-based knowledge bases, enabling quick retrieval of relevant information. This is particularly beneficial for applications in fields such as research or data analytics, where accessing vast amounts of data quickly and accurately is crucial. For example, a research Tool could use this Driver to pull the latest studies or data points relevant to a specific query, significantly speeding up the research process.

import os 
from griptape.drivers import GriptapeCloudKnowledgeBaseVectorStoreDriver


# Initialize environment variables
gt_cloud_api_key = os.environ["GRIPTAPE_CLOUD_API_KEY"]
gt_cloud_knowledge_base_id = os.environ["GRIPTAPE_CLOUD_KB_ID"]

vector_store_driver = GriptapeCloudKnowledgeBaseVectorStoreDriver(api_key=gt_cloud_api_key, knowledge_base_id=gt_cloud_knowledge_base_id)

results = vector_store_driver.query(query="What is griptape?")

values = [r.to_artifact().value for r in results]

print("\n\n".join(values))

New Observability Drivers and Tools

Observability in software systems is crucial for monitoring performance and troubleshooting issues. This release introduces several new observability Drivers like the OpenTelemetryObservabilityDriver and DatadogObservabilityDriver, each tailored to specific monitoring needs and platforms. Additionally, the new observability context manager and @observable decorator make it easier to implement and manage observability across your applications. These Tools allow you to specify which functions or methods should be monitored, helping you keep a close eye on critical parts of your application without overwhelming the system with unnecessary data. 

The following code is an example of how to use the @observable keyword in your own code. This will include a span for my_function in the trace when invoked in the context of the observability context manager.

# ... your code here

@observable # adds custom functions to Griptape's observability capabilities
def my_function():
    print("Hello World!")

The GriptapeCloudObservabilityDriver specifically caters to sending data to Griptape Cloud, ensuring that your data is integrated seamlessly within the Griptape ecosystem.

from griptape.drivers import GriptapeCloudObservabilityDriver
from griptape.rules import Rule
from griptape.structures import Agent
from griptape.observability import Observability

observability_driver = GriptapeCloudObservabilityDriver()

with Observability(observability_driver=observability_driver):
    agent = Agent(rules=[Rule("Output one word")])
    agent.run("Name an animal")

More On GenericArtifact

The advanced capabilities of Google Gemini's native video input features now allows users to upload a video and ask specific questions about its content. Utilizing the GenericArtifact to pass the video as input, the system can analyze the video data directly and respond to queries about specific scenes or details, such as identifying characters with earrings or describing actions at a given timestamp. This functionality demonstrates a significant leap in interactive AI, enabling a more dynamic and engaging user experience by allowing direct questioning and receiving detailed insights about video content.

GenericArtifact streamlines how data is stored and managed, ensuring consistency across different types of data and simplifying interactions with data artifacts.

StableDiffusion Support

We've introduced the StableDiffusion3ImageGenerationPipelineDriver and related Drivers for image-to-image and ControlNet image generation, harnessing the power of Stable Diffusion 3 for creating high-quality images directly from textual descriptions or modifying existing images. This Driver accepts a text prompt, a control image, and standard Stable Diffusion 3 configurations to give users granular control over the images generated.

from pathlib import Path

from griptape.structures import Pipeline
from griptape.tasks import VariationImageGenerationTask
from griptape.engines import VariationImageGenerationEngine
from griptape.drivers import HuggingFacePipelineImageGenerationDriver, \
    StableDiffusion3ControlNetImageGenerationPipelineDriver
from griptape.artifacts import TextArtifact, ImageArtifact
from griptape.loaders import ImageLoader

prompt_artifact = TextArtifact("landscape photograph, verdant, countryside, 8k")
control_image_artifact = ImageLoader().load(Path("canny_control_image.png").read_bytes())

controlnet_task = VariationImageGenerationTask(
    input=(prompt_artifact, control_image_artifact),
    image_generation_engine=PromptImageGenerationEngine(
        image_generation_driver=HuggingFacePipelineImageGenerationDriver(
            model="stabilityai/stable-diffusion-3-medium-diffusers",
            device="cuda",
            pipeline_driver=StableDiffusion3ControlNetImageGenerationPipelineDriver(
                controlnet_model="InstantX/SD3-Controlnet-Canny",
                control_strength=0.8,
                height=768,
                width=1024,
            )
        )
    )
)

output_artifact = Pipeline(tasks=[controlnet_task]).run().output

Conclusion

This update is designed to empower developers by providing more powerful Tools, simplifying complex processes, and enhancing the overall reliability of applications. Whether you're developing AI-driven chatbots, sophisticated data analysis Tools, or dynamic web applications, the new features and enhancements in this release are here to help you achieve more with less effort. We're excited to see how these new capabilities will improve your projects and drive innovation in your work.