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.adapters import LangchainToolAdapter, ChatgptPluginAdapter
from griptape.executors import LocalExecutor
from griptape_tools import (
Calculator, GoogleSearch
)
tool_executor = LocalExecutor()
google_search = GoogleSearch(
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(google_search.search),
LangchainToolAdapter(executor=tool_executor).generate(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.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d52904773458d10320db1824c0ace6fae969b0dc8fc9502294f9a7f9d55e128b |
|
MD5 | ccca6de493d05f168ca7df327a33f765 |
|
BLAKE2b-256 | 93b5e96073169f563b5e6fc29c6e1bf96c1086a3f8afa88c21985d1328aab157 |