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 modular Python framework for building AI-powered applications that securely connect to your enterprise data and APIs. It offers developers the ability to maintain control and flexibility at every step.

๐Ÿ› ๏ธ Core Components

๐Ÿ—๏ธ Structures

  • ๐Ÿค– Agents consist of a single Task.
  • ๐Ÿ”„ 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.

๐Ÿ”ง 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.

๐Ÿง  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:

  • ๐Ÿ—ฃ๏ธ Prompt Drivers manage textual and image interactions with LLMs.
  • ๐Ÿ”ข Embedding Drivers generate vector embeddings from textual inputs.
  • ๐Ÿ’พ Vector Store Drivers manage the storage and retrieval of embeddings.
  • ๐Ÿ”€ Rerank Drivers rerank search results based for relevance.
  • ๐ŸŽจ Image Generation Drivers create images from text descriptions.
  • ๐Ÿ’ผ SQL Drivers interact with SQL databases.
  • ๐ŸŒ Web Scraper Drivers extract information from web pages.
  • ๐Ÿง  Conversation Memory Drivers manage the storage and retrieval of conversational data.
  • ๐Ÿ“ก Event Listener Drivers forward framework events to external services.
  • ๐Ÿ—๏ธ Structure Run Drivers execute structures both locally and in the cloud.
  • ๐Ÿค– Assistant Drivers enable interactions with various "assistant" services.
  • ๐Ÿ—ฃ๏ธ Text to Speech Drivers convert text to speech.
  • ๐ŸŽ™๏ธ Audio Transcription Drivers convert audio to text.
  • ๐Ÿ” Web Search Drivers search the web for information.
  • ๐Ÿ“ˆ Observability Drivers send trace and event data to observability platforms.
  • ๐Ÿ“œ Ruleset Drivers load and apply rulesets from external sources.
  • ๐Ÿ—‚๏ธ File Manager Drivers handle file operations on local and remote storage.

๐Ÿš‚ 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 refer to Griptape Docs for:

  • Getting started guides.
  • Core concepts and design overviews.
  • Examples.
  • Contribution guidelines.

Please check out Griptape Trade School for free online courses.

Quick Start

First, install griptape:

pip install "griptape[all]" -U

Second, configure an OpenAI client by getting an API key and adding it to your environment as OPENAI_API_KEY. By default, Griptape uses OpenAI Chat Completions API to execute LLM prompts.

With Griptape, you can create Structures, such as Agents, Pipelines, and Workflows, composed of different types of Tasks. Let's build a simple creative Agent that dynamically uses three tools and moves the data around in Task Memory.

from griptape.structures import Agent
from griptape.tools import WebScraperTool, FileManagerTool, PromptSummaryTool

agent = Agent(
    input="Load {{ args[0] }}, summarize it, and store it in a file called {{ args[1] }}.",
    tools=[
        WebScraperTool(off_prompt=True),
        PromptSummaryTool(off_prompt=True),
        FileManagerTool()
    ]
)
agent.run("https://griptape.ai", "griptape.txt")

And here is the output:

[08/12/24 14:48:15] INFO     PromptTask c90d263ec69046e8b30323c131ae4ba0
                             Input: Load https://griptape.ai, summarize it, and store it in a file called griptape.txt.
[08/12/24 14:48:16] INFO     Subtask ebe23832cbe2464fb9ecde9fcee7c30f
                             Actions: [
                               {
                                 "tag": "call_62kBnkswnk9Y6GH6kn1GIKk6",
                                 "name": "WebScraperTool",
                                 "path": "get_content",
                                 "input": {
                                   "values": {
                                     "url": "https://griptape.ai"
                                   }
                                 }
                               }
                             ]
[08/12/24 14:48:17] INFO     Subtask ebe23832cbe2464fb9ecde9fcee7c30f
                             Response: Output of "WebScraperTool.get_content" was stored in memory with memory_name "TaskMemory" and artifact_namespace
                             "cecca28eb0c74bcd8c7119ed7f790c95"
[08/12/24 14:48:18] INFO     Subtask dca04901436d49d2ade86cd6b4e1038a
                             Actions: [
                               {
                                 "tag": "call_o9F1taIxHty0mDlWLcAjTAAu",
                                 "name": "PromptSummaryTool",
                                 "path": "summarize",
                                 "input": {
                                   "values": {
                                     "summary": {
                                       "memory_name": "TaskMemory",
                                       "artifact_namespace": "cecca28eb0c74bcd8c7119ed7f790c95"
                                     }
                                   }
                                 }
                               }
                             ]
[08/12/24 14:48:21] INFO     Subtask dca04901436d49d2ade86cd6b4e1038a
                             Response: Output of "PromptSummaryTool.summarize" was stored in memory with memory_name "TaskMemory" and artifact_namespace
                             "73765e32b8404e32927822250dc2ae8b"
[08/12/24 14:48:22] INFO     Subtask c233853450fb4fd6a3e9c04c52b33bf6
                             Actions: [
                               {
                                 "tag": "call_eKvIUIw45aRYKDBpT1gGKc9b",
                                 "name": "FileManagerTool",
                                 "path": "save_memory_artifacts_to_disk",
                                 "input": {
                                   "values": {
                                     "dir_name": ".",
                                     "file_name": "griptape.txt",
                                     "memory_name": "TaskMemory",
                                     "artifact_namespace": "73765e32b8404e32927822250dc2ae8b"
                                   }
                                 }
                               }
                             ]
                    INFO     Subtask c233853450fb4fd6a3e9c04c52b33bf6
                             Response: Successfully saved memory artifacts to disk
[08/12/24 14:48:23] INFO     PromptTask c90d263ec69046e8b30323c131ae4ba0
                             Output: The content from https://griptape.ai has been summarized and stored in a file called `griptape.txt`.

During the run, the Griptape Agent loaded a webpage with a Tool, stored its full content in Task Memory, queried it to answer the original question, and finally saved the answer to a file.

The important thing to note here is that no matter how big the webpage is it can never blow up the prompt token limit because the full content of the page never goes back to the LLM. Additionally, no data from the subsequent subtasks were returned back to the prompt either. So, how does it work?

In the above example, we set off_prompt to True, which means that the LLM can never see the data it manipulates, but can send it to other Tools.

[!IMPORTANT] This example uses Griptape's PromptTask with tools, which requires a highly capable LLM to function correctly. By default, Griptape uses the OpenAiChatPromptDriver; for another powerful LLM try swapping to the AnthropicPromptDriver! If you're using a less powerful LLM, consider using the ToolTask instead, as the PromptTask with tools might not work properly or at all.

Check out our docs to learn more about how to use Griptape with other LLM providers like Anthropic, Claude, Hugging Face, and Azure.

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.4.0.tar.gz (181.7 kB view details)

Uploaded Source

Built Distribution

griptape-1.4.0-py3-none-any.whl (401.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: griptape-1.4.0.tar.gz
  • Upload date:
  • Size: 181.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.9.21 Linux/6.8.0-1021-azure

File hashes

Hashes for griptape-1.4.0.tar.gz
Algorithm Hash digest
SHA256 6c222e3663ad560210f7d1c6d06a1a7a612e50a9202d1d283763159137b9711d
MD5 658d6d081079e45b700006927262e3f7
BLAKE2b-256 70a045e9c0dd519e86f969fc5373a9e6dceee0fcad228d9c01d229f3ee667c8c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: griptape-1.4.0-py3-none-any.whl
  • Upload date:
  • Size: 401.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.9.21 Linux/6.8.0-1021-azure

File hashes

Hashes for griptape-1.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 08ce3d45027b610bda2b45431d81534b7a42216cf1cd3a60eea8f3118d608ca6
MD5 122e01aa40fb9273b0fd81a1cf4eb193
BLAKE2b-256 950e871bcf9723e681f91805bbd94a15a20bb59ca09cffe31d7971159849ea63

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