Skip to main content

llama-index tools graphql integration

Project description

GraphQL Tool

This tool provides agents the ability to easily execute GraphQL queries against a server. The tool can be initialized with the server url and any required headers and thereafter perform queries against the server

Usage

This tool has a more extensive example usage documented in a Jupyter notebook here

Here's an example usage of the GraphQLToolSpec.

This tool works best when the Agent has access to the GraphQL schema for the server. See here for an example of using a tool with a file loader to create even more powerful Agents.

from llama_index.tools.graphql import GraphQLToolSpec
from llama_index.core.agent.workflow import FunctionAgent
from llama_index.llms.openai import OpenAI

tool_spec = GraphQLToolSpec(
    url="https://spacex-production.up.railway.app/",
    headers={
        "content-type": "application/json",
    },
)

agent = FunctionAgent(
    tools=tool_spec.to_tool_list(),
    llm=OpenAI(model="gpt-4.1"),
)

await agent.run(
    "get the id, model, name and type of the Ships from the graphql endpoint"
)

graphql_request: Runs a GraphQL query against the configured server

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_graphql-0.4.0.tar.gz (3.9 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_graphql-0.4.0-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for llama_index_tools_graphql-0.4.0.tar.gz
Algorithm Hash digest
SHA256 ff809665d1762e8421109c384588035aad0bcf3bf19075a3d82c55491ddaf478
MD5 8387a3e6456e946fdc1ef7c1ea986f65
BLAKE2b-256 7eb1f9fb066bac40cebd8fb80a9f2008ab9a3c7bda77f85577c92c8331f1a752

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for llama_index_tools_graphql-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 97a99d460411c559564f62d19ee707f9599190724bd3895c516fdd3a934e48bb
MD5 cffe166a32e2383942da08af139e05d7
BLAKE2b-256 eb12a9835c8d1a13551530c31bbad5a3b8b563bd7dd79111ab51874f993a67d1

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