Skip to main content

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

Project description

griptape

PyPI Version Tests Docs Griptape Discord

Griptape is a modular Python framework for LLM workflows, tools, memory, and data that enables developers to:

  1. 🤖 Build AI agents, sequential LLM pipelines and sprawling DAG workflows for complex use cases.
  2. ⛓️ Augment LLMs with chain of thought capabilities.
  3. 🧰️ Integrate other services and functionality into LLMs as tools (e.g., calculators, web scrapers, spreadsheet editors, and API connectors); run tools in any environment (local, containerized, cloud, etc.); and wrap tools with off prompt data storage that prevents LLMs from accessing your data directly.
  4. 💾 Add memory to AI pipelines for context preservation and summarization.

Documentation

Please refer to Griptape Docs for:

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

Quick Start

First, install griptape and griptape-tools:

pip install griptape griptape-tools -U

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

With Griptape, you can create structures, such as Agents, Pipelines, and Workflows, that are composed of different types of tasks. Let's define a simple two-task pipeline that uses several tools and memory:

from griptape.memory.structure import ConversationMemory
from griptape.memory.tool import TextToolMemory, BlobToolMemory
from griptape.structures import Pipeline
from griptape.tasks import ToolkitTask, PromptTask
from griptape.tools import WebScraper, TextProcessor, FileManager
from griptape import utils

# Tool memory enables LLMs to store and manipulate data
# without ever looking at it directly.
text_storage = TextToolMemory()
blob_storage = BlobToolMemory()

# Connect a web scraper to load web pages.
web_scraper = WebScraper(
    memory={
        "get_content": {
            "output": [text_storage]
        }
    }
)

# TextProcessor enables LLMs to summarize and query text.
text_processor = TextProcessor(
    memory={
        "summarize": {
            "input": [text_storage]
        },
        "query": {
            "input": [text_storage]
        }
    }
)

# File manager can load and store files locally.
file_manager = FileManager(
    memory={
        "load": {
            "output": [blob_storage]
        },
        "save": {
            "input": [text_storage, blob_storage]
        }
    }
)

# Pipelines represent sequences of tasks.
pipeline = Pipeline(
    memory=ConversationMemory()
)

pipeline.add_tasks(
    # Load up the first argument from `pipeline.run`.
    ToolkitTask(
        "{{ args[0] }}",
        tools=[web_scraper, text_processor, file_manager]
    ),
    # Augment `input` from the previous task.
    PromptTask(
        "Say the following in spanish: {{ input }}"
    )
)

result = pipeline.run(
    "Load https://www.griptape.ai, summarize it, and store it in griptape.txt"
)

print(result.output.to_text())

Our first LLM pipeline with two sequential tasks generated the following exchange:

Q: Load https://docs.griptape.ai, summarize it, and store it in griptape.txt
A: El contenido de https://docs.griptape.ai ha sido resumido y almacenado en griptape.txt.

During the run, Griptape prompted the LLM to load a webpage, store its content in temporary memory, summarize the content, and, finally, save it in griptape.txt.

Versioning

Griptape is in early development and its APIs and documentation are subject to change. Until we stabilize the API and release version 1.0.0, we will use minor versions (i.e., x.Y.z) to introduce features and breaking features, and patch versions (i.e., x.y.Z) for bug fixes.

Contributing

Contributions in the form of bug reports, feature ideas, or pull requests are super welcome! Take a look at the current issues and if you'd like to help please submit a pull request with some tests.

License

Griptape is available under the Apache 2.0 License.

Project details


Download files

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

Source Distribution

griptape-0.10.0.tar.gz (41.4 kB view hashes)

Uploaded Source

Built Distribution

griptape-0.10.0-py3-none-any.whl (75.4 kB view hashes)

Uploaded Python 3

Supported by

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