Skip to main content

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

llama_index_tools_openapi-0.4.0.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

llama_index_tools_openapi-0.4.0-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file llama_index_tools_openapi-0.4.0.tar.gz.

File metadata

File hashes

Hashes for llama_index_tools_openapi-0.4.0.tar.gz
Algorithm Hash digest
SHA256 dca240dd3ef96ae090d319072ea297bb65db854987250843ba3ab8d4e6b0d04c
MD5 f935e375fc4d5ec8bfb75f55090f40e3
BLAKE2b-256 df01221b9212b7f915196a7d19a9b4ba888b8cdd592b4db88b7163f110ac2cff

See more details on using hashes here.

File details

Details for the file llama_index_tools_openapi-0.4.0-py3-none-any.whl.

File metadata

File hashes

Hashes for llama_index_tools_openapi-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e622340ba631a69def178fce322b41c355c615722ef67df5beb02a325a9d08b9
MD5 44090cf071a8ff6b352e589a7a813eb0
BLAKE2b-256 c3b62a7f14ad3e2c5af6c577c3d6e00714c0510b6128486451090fcafe5c47e3

See more details on using hashes here.

Supported by

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