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.agent.openai import OpenAIAgent

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 = OpenAIAgent.from_tools(
    [*shopify_tool.to_tool_list(), documentation_tool],
    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
    """,
    verbose=True,
    max_function_calls=20,
)

agent.chat("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.3.0.tar.gz (2.9 kB view details)

Uploaded Source

Built Distribution

File details

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

File metadata

  • Download URL: llama_index_tools_shopify-0.3.0.tar.gz
  • Upload date:
  • Size: 2.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.11.10 Darwin/22.3.0

File hashes

Hashes for llama_index_tools_shopify-0.3.0.tar.gz
Algorithm Hash digest
SHA256 4224702d10c8467fedf26cb0018b41bab51c512baf68567bd6b2755fdd35ea6d
MD5 acd9c7699fcb3af773bf47a84ad87293
BLAKE2b-256 55641db64da7ec81371da5c4b7e11d952e8e8efff60d5f9a7a15bfe4ec64a7ed

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for llama_index_tools_shopify-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4f77a9655a7750edbf13bddc1f5fcc3fb3ba176da59a196f8c1a7e491d4d8d24
MD5 01ba0d6399e4d9283c515fcbf95d603c
BLAKE2b-256 b19ca4477972cf78e7ebd84b0fcca832d99dff4ebea4e8bf90dc927627ace812

See more details on using hashes here.

Supported by

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