Python framework for LLM middleware tools. Build once, run anywhere.
Project description
Griptape
Griptape is a Python framework that enables developers to write tools for generative AI middleware once and use it anywhere.
Griptape has three core components:
- Tools: call external APIs, access databases, and run arbitrary code or CLI commands.
- Executors: run your tools safely in any environment: local, containerized, or serverless in the cloud.
- Adapters: convert tools into underlying middleware abstractions, such as ChatGPT Plugins, LangChain tools, and Fixie.ai agents.
Getting Started
Griptape separates the core framework from tools into two Python packages: griptape-core
and griptape-tools
. Explore Griptape tools in the griptape-tools repo
First, install those packages:
pip install griptape-core
pip install griptape-tools
Next, initialize an executor and some tools:
from griptape.core.adapters import LangchainToolAdapter, ChatgptPluginAdapter
from griptape.core.executors import LocalExecutor
from griptape.tools import (
Calculator, WebSearch
)
tool_executor = LocalExecutor()
google_search = WebSearch(
api_search_key="<search key>",
api_search_id="<search ID>"
)
calculator = Calculator()
You can execute tool actions directly:
tool_executor.execute(calculator.calculate, "42**42".encode())
Convert tool actions into LangChain tools:
agent = initialize_agent(
[
LangchainToolAdapter(executor=tool_executor).generate_tool(google_search.search),
LangchainToolAdapter(executor=tool_executor).generate_tool(calculator.calculate)
],
OpenAI(temperature=0.5, model_name="text-davinci-003"),
agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
verbose=True
)
agent.run("What is 42^42?")
Or generate and run a ChatGPT Plugin:
app = ChatgptPluginAdapter(
host="localhost:8000",
path_prefix="/search-tool/",
executor=tool_executor
).generate_api(google_search)
# run with `uvicorn app:app --reload`
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
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
Built Distribution
Hashes for griptape_core-0.9.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b00bdbf5ac1fdbda2600b1fdecbb1738aff96b83e10aafd32022b471b66b506a |
|
MD5 | e0cdfff5a4678545d9df34d389445dc4 |
|
BLAKE2b-256 | 204556c2a75e3cddb23f32fe3bb620a125eb77cb10c6cb604b1904ef93d2c6de |