Skip to main content

llama-index tools shopify integration

Project description

Shopify Tool

This tool acts as a custom app for Shopify stores, allowing the Agent to execute GraphQL queries to gather information or perform mutations against the Shopify store.

Usage

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

In particular, the tool is very effective when combined with a method of retrieving data from the GraphQL schema definition.

pip install llama-index llama-index-readers-file llama-index-tools-shopify unstructured
from llama_index.tools.shopify import ShopifyToolSpec
from llama_index.core.agent.workflow import FunctionAgent
from llama_index.llms.openai import OpenAI

from llama_index.readers.file import UnstructuredReader
from llama_index.core.tools.ondemand_loader_tool import OnDemandLoaderTool

documentation_tool = OnDemandLoaderTool.from_defaults(
    UnstructuredReader(),
    name="graphql_writer",
    description="""
        The GraphQL schema file is located at './data/shopify_graphql.txt', this is always the file argument.
        A tool for processing the Shopify GraphQL spec, and writing queries from the documentation.

        You should pass a query_str to this tool in the form of a request to write a GraphQL query.

        Examples:
            file: './data/shopify_graphql.txt', query_str='Write a graphql query to find unshipped orders'
            file: './data/shopify_graphql.txt', query_str='Write a graphql query to retrieve the stores products'
            file: './data/shopify_graphql.txt', query_str='What fields can you retrieve from the orders object'
        """,
)


shopify_tool = ShopifyToolSpec(
    "your-store.myshopify.com", "2023-04", "your-api-key"
)

agent = FunctionAgent(
    tools=[*shopify_tool.to_tool_list(), documentation_tool],
    llm=OpenAI(model="gpt-4.1"),
    system_prompt=f"""
    You are a specialized Agent with access to the Shopify Admin GraphQL API for this Users online store.
    Your job is to chat with store owners and help them run GraphQL queries, interpreting the results for the user

    You can use graphql_writer to query the schema and assist in writing queries.

    If the GraphQL you execute returns an error, either directly fix the query, or directly ask the graphql_writer questions about the schema instead of writing graphql queries.
    Then use that information to write the correct graphql query
    """,
)

print(await agent.run("What products are in my store?"))

run_graphql_query: Executes a GraphQL query against the Shopify store

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_shopify-0.5.0.tar.gz (4.4 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_shopify-0.5.0-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file llama_index_tools_shopify-0.5.0.tar.gz.

File metadata

  • Download URL: llama_index_tools_shopify-0.5.0.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for llama_index_tools_shopify-0.5.0.tar.gz
Algorithm Hash digest
SHA256 1295ea275509a6f90d4f8bd584b0f6c8079cd04b67c28bd1c5d23ff3f56090f1
MD5 d4416a0ea48a95ef152228123ade1e46
BLAKE2b-256 1260138416f7a70806e9427ca4f088c30de7a7a86009963a43a2e292b4c82ffe

See more details on using hashes here.

File details

Details for the file llama_index_tools_shopify-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: llama_index_tools_shopify-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for llama_index_tools_shopify-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7a1f0c8393d9e22f5d7b0957618bf8a0ebb64d03c62e7425286efbdce68aea86
MD5 9d3e0c0b3836bebca8b2093b26160b6b
BLAKE2b-256 b41963e3350cb252100f8a06b444b6be4075fdda641eb9c439b07c33091e045d

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