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.1.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.1-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for llama_index_tools_graphql-0.4.1.tar.gz
Algorithm Hash digest
SHA256 e0121cd28454c4456d5b1d63fea3010727319179cf49c04814771a240df9394b
MD5 6f3ebe4a5f14d83b47ade5fd90c01d07
BLAKE2b-256 6f306e8cc5a38224100122768e4e32c562549b6ef5ff7d9086517faf8ceab1d1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for llama_index_tools_graphql-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 879c0b00279362e88d8f9eb24a852d7574ada08cfc1b1b84bf5c0edad6d21bc9
MD5 67753eb414fc9a871c3c4709b8d86fb8
BLAKE2b-256 b8867ac80e8bd74d06fbbc8803a90f4a3aae382cc9c2323ae5c9a4e1a35aa222

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