llama-index tools openapi integration
Project description
OpenAPI Tool
pip install llama-index-tools-openapi
This tool loads an OpenAPI spec and allow the Agent to retrieve endpoints and details about endpoints. The RequestsToolSpec can also be loaded into the agent to allow the agent to hit the necessary endpoints with a REST request.
Usage
This tool has more extensive example usage documented in a Jupyter notebook here
Here's an example usage of the OpenAPIToolSpec.
from llama_index.tools.openapi import OpenAPIToolSpec
from llama_index.agent.openai import OpenAIAgent
f = requests.get(
"https://raw.githubusercontent.com/APIs-guru/openapi-directory/main/APIs/openai.com/1.2.0/openapi.yaml"
).text
open_api_spec = yaml.safe_load(f)
# OR
open_spec = OpenAPIToolSpec(
url="https://raw.githubusercontent.com/APIs-guru/openapi-directory/main/APIs/openai.com/1.2.0/openapi.yaml"
)
tool_spec = OpenAPIToolSpec(open_api_spec)
agent = OpenAIAgent.from_tools(tool_spec.to_tool_list())
agent.chat("What is the base url for the API")
agent.chat("What parameters does the x endpoint need?")
load_openapi_spec
: Returns the parsed OpenAPI spec that the class was initialized with
This loader is designed to be used as a way to load data as a Tool in a Agent.
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
Built Distribution
File details
Details for the file llama_index_tools_openapi-0.3.0.tar.gz
.
File metadata
- Download URL: llama_index_tools_openapi-0.3.0.tar.gz
- Upload date:
- Size: 3.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.11.10 Darwin/22.3.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6daab10685eccd1da815b7bc97430f77f7a8866deaa675e3527bbcd067e18ec2 |
|
MD5 | 5fe9e48f640f5478801c0eef7b496652 |
|
BLAKE2b-256 | 1375590befece5a7e346b1d47c18746f3ea6b3ea651c59ab6d5c224e75b1cf9b |
File details
Details for the file llama_index_tools_openapi-0.3.0-py3-none-any.whl
.
File metadata
- Download URL: llama_index_tools_openapi-0.3.0-py3-none-any.whl
- Upload date:
- Size: 3.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.11.10 Darwin/22.3.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ef91be052516e61ce594169969717b8bbf66dbab337df31f4fe263fa07c0ea4f |
|
MD5 | 4bef972bd1d961d7e7acb9596b51de14 |
|
BLAKE2b-256 | e714ae969e235bce8b4a98259657c5c654d5bf4c35dda471aabfbaf205bd1221 |