Skip to main content

Modular Python framework for LLM workflows, tools, memory, and data.

Project description

Griptape

PyPI Version Tests Docs Checked with pyright Ruff codecov Griptape Discord

Griptape is a Python framework designed to simplify the development of generative AI (genAI) applications. It offers a set of straightforward, flexible abstractions for working with areas such as Large Language Models (LLMs), Retrieval-Augmented Generation (RAG), and much more.

๐Ÿ› ๏ธ Core Components

๐Ÿ—๏ธ Structures

  • ๐Ÿค– Agents consist of a single Task, configured for Agent-specific behavior.
  • ๐Ÿ”„ Pipelines organize a sequence of Tasks so that the output from one Task may flow into the next.
  • ๐ŸŒ Workflows configure Tasks to operate in parallel.

๐Ÿ“ Tasks

Tasks are the core building blocks within Structures, enabling interaction with Engines, Tools, and other Griptape components.

๐Ÿง  Memory

  • ๐Ÿ’ฌ Conversation Memory enables LLMs to retain and retrieve information across interactions.
  • ๐Ÿ—ƒ๏ธ Task Memory keeps large or sensitive Task outputs off the prompt that is sent to the LLM.
  • ๐Ÿ“Š Meta Memory enables passing in additional metadata to the LLM, enhancing the context and relevance of the interaction.

๐Ÿš— Drivers

Drivers facilitate interactions with external resources and services in Griptape. They allow you to swap out functionality and providers with minimal changes to your business logic.

LLM & Orchestration

  • ๐Ÿ—ฃ๏ธ Prompt Drivers: Manage textual and image interactions with LLMs.
  • ๐Ÿค– Assistant Drivers: Enable interactions with various โ€œassistantโ€ services.
  • ๐Ÿ“œ Ruleset Drivers: Load and apply rulesets from external sources.
  • ๐Ÿง  Conversation Memory Drivers: Store and retrieve conversational data.
  • ๐Ÿ“ก Event Listener Drivers: Forward framework events to external services.
  • ๐Ÿ—๏ธ Structure Run Drivers: Execute structures locally or in the cloud.

Retrieval & Storage

  • ๐Ÿ”ข Embedding Drivers: Generate vector embeddings from textual inputs.
  • ๐Ÿ”€ Rerank Drivers: Rerank search results for improved relevance.
  • ๐Ÿ’พ Vector Store Drivers: Manage the storage and retrieval of embeddings.
  • ๐Ÿ—‚๏ธ File Manager Drivers: Handle file operations on local and remote storage.
  • ๐Ÿ’ผ SQL Drivers: Interact with SQL databases.

Multimodal

  • ๐ŸŽจ Image Generation Drivers: Create images from text descriptions.
  • ๐Ÿ—ฃ๏ธ Text to Speech Drivers: Convert text to speech.
  • ๐ŸŽ™๏ธ Audio Transcription Drivers: Convert audio to text.

Web

  • ๐Ÿ” Web Search Drivers: Search the web for information.
  • ๐ŸŒ Web Scraper Drivers: Extract data from web pages.

Observability

  • ๐Ÿ“ˆ Observability Drivers: Send trace and event data to observability platforms.

๐Ÿ”ง Tools

Tools provide capabilities for LLMs to interact with data and services. Griptape includes a variety of built-in Tools, and makes it easy to create custom Tools.

๐Ÿš‚ Engines

Engines wrap Drivers and provide use-case-specific functionality:

  • ๐Ÿ“Š RAG Engine is an abstraction for implementing modular Retrieval Augmented Generation (RAG) pipelines.
  • ๐Ÿ› ๏ธ Extraction Engine extracts JSON or CSV data from unstructured text.
  • ๐Ÿ“ Summary Engine generates summaries from textual content.
  • โœ… Eval Engine evaluates and scores the quality of generated text.

๐Ÿ“ฆ Additional Components

  • ๐Ÿ“ Rulesets steer LLM behavior with minimal prompt engineering.
  • ๐Ÿ”„ Loaders load data from various sources.
  • ๐Ÿบ Artifacts allow for passing data of different types between Griptape components.
  • โœ‚๏ธ Chunkers segment texts into manageable pieces for diverse text types.
  • ๐Ÿ”ข Tokenizers count the number of tokens in a text to not exceed LLM token limits.

Documentation

Please visit the docs for information on installation and usage.

Check out Griptape Trade School for free online courses.

Hello World Example

Here's a minimal example of griptape:

from griptape.drivers.prompt.openai import OpenAiChatPromptDriver
from griptape.rules import Rule
from griptape.tasks import PromptTask

task = PromptTask(
    prompt_driver=OpenAiChatPromptDriver(model="gpt-4o"),
    rules=[Rule("Keep your answer to a few sentences.")],
)

result = task.run("How do I do a kickflip?")

print(result.value)
To do a kickflip, start by positioning your front foot slightly angled near the middle of the board and your back foot on the tail.
Pop the tail down with your back foot while flicking the edge of the board with your front foot to make it spin.
Jump and keep your body centered over the board, then catch it with your feet and land smoothly. Practice and patience are key!

Task and Workflow Example

Here is a concise example using griptape to research open source projects:

from griptape.drivers.prompt.openai_chat_prompt_driver import OpenAiChatPromptDriver
from griptape.drivers.web_search.duck_duck_go import DuckDuckGoWebSearchDriver
from griptape.rules import Rule, Ruleset
from griptape.structures import Workflow
from griptape.tasks import PromptTask, TextSummaryTask
from griptape.tools import WebScraperTool, WebSearchTool
from griptape.utils import StructureVisualizer
from pydantic import BaseModel


class Feature(BaseModel):
    name: str
    description: str
    emoji: str


class Output(BaseModel):
    answer: str
    key_features: list[Feature]


projects = ["griptape", "langchain", "crew-ai", "pydantic-ai"]

prompt_driver = OpenAiChatPromptDriver(model="gpt-4o")
workflow = Workflow(
    tasks=[
        [
            PromptTask(
                id=f"project-{project}",
                input="Tell me about the open source project: {{ project }}.",
                prompt_driver=prompt_driver,
                context={"project": projects},
                output_schema=Output,
                tools=[
                    WebSearchTool(
                        web_search_driver=DuckDuckGoWebSearchDriver(),
                    ),
                    WebScraperTool(),
                ],
                child_ids=["summary"],
            )
            for project in projects
        ],
        TextSummaryTask(
            input="{{ parents_output_text }}",
            id="summary",
            rulesets=[
                Ruleset(
                    name="Format", rules=[Rule("Be detailed."), Rule("Include emojis.")]
                )
            ],
        ),
    ]
)

workflow.run()

print(StructureVisualizer(workflow).to_url())
 Output: Here's a detailed summary of the open-source projects mentioned:

 1. **Griptape** ๐Ÿ› ๏ธ:                                                                                                            
    - Griptape is a modular Python framework designed for creating AI-powered applications. It focuses on securely connecting to
 enterprise data and APIs. The framework provides structured components like Agents, Pipelines, and Workflows, allowing for both
 parallel and sequential operations. It includes built-in tools and supports custom tool creation for data and service
 interaction.

 2. **LangChain** ๐Ÿ”—:
    - LangChain is a framework for building applications powered by Large Language Models (LLMs). It offers a standard interface
 for models, embeddings, and vector stores, facilitating real-time data augmentation and model interoperability. LangChain
 integrates with various data sources and external systems, making it adaptable to evolving technologies.

 3. **CrewAI** ๐Ÿค–:
    - CrewAI is a standalone Python framework for orchestrating multi-agent AI systems. It allows developers to create and
 manage AI agents that collaborate on complex tasks. CrewAI emphasizes ease of use and scalability, providing tools and
 documentation to help developers build AI-powered solutions.

 4. **Pydantic-AI** ๐Ÿงฉ:
    - Pydantic-AI is a Python agent framework that simplifies the development of production-grade applications with Generative
 AI. Built on Pydantic, it supports various AI models and provides features like type-safe design, structured response
 validation, and dependency injection. Pydantic-AI aims to bring the ease of FastAPI development to AI applications.

 These projects offer diverse tools and frameworks for developing AI applications, each with unique features and capabilities
 tailored to different aspects of AI development.
    graph TD;
    griptape-->summary;
    langchain-->summary;
    pydantic-ai-->summary;
    crew-ai-->summary;

Versioning

Griptape uses Semantic Versioning.

Contributing

Thank you for considering contributing to Griptape! Before you start, please review our Contributing Guidelines.

License

Griptape is available under the Apache 2.0 License.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

griptape-1.5.0.tar.gz (179.3 kB view details)

Uploaded Source

Built Distribution

griptape-1.5.0-py3-none-any.whl (405.8 kB view details)

Uploaded Python 3

File details

Details for the file griptape-1.5.0.tar.gz.

File metadata

  • Download URL: griptape-1.5.0.tar.gz
  • Upload date:
  • Size: 179.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.6

File hashes

Hashes for griptape-1.5.0.tar.gz
Algorithm Hash digest
SHA256 1cd292fc74c94ce53c6dacd9e8a80c98725e11dc6abd2f3cecca4e5e0c249b92
MD5 2c3d982dfcd094660472a9b4667c8e9c
BLAKE2b-256 0f5fa0e8e78b8332f8d663bc1443c3bf50d057ef9f909a4a8a618c86e090d707

See more details on using hashes here.

File details

Details for the file griptape-1.5.0-py3-none-any.whl.

File metadata

File hashes

Hashes for griptape-1.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0fddc48f40d9d54a147217995af9ed657fdf02c3836d059b82ff21b4932bb908
MD5 d58fbfdb18bd20a7443efef09d3549bc
BLAKE2b-256 8f2944d033ef6bdd8d4ff4dd548f4201f7f534e20631c32de9878fa53a3dde03

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page