Skip to content

Shopify

ShopifyToolSpec #

Bases: BaseToolSpec

Shopify工具规范。

Source code in llama_index/tools/shopify/base.py
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
class ShopifyToolSpec(BaseToolSpec):
    """Shopify工具规范。"""

    spec_functions = ["run_graphql_query"]

    def __init__(self, shop_url: str, api_version: str, admin_api_key: str):
        # Currently only supports Admin API auth
        # https://shopify.dev/docs/apps/auth/admin-app-access-tokens
        from shopify import Session, ShopifyResource

        session = Session(shop_url, api_version, admin_api_key)
        ShopifyResource.activate_session(session)

    def run_graphql_query(self, graphql_query: str):
        """针对Shopify Admin API运行一个GraphQL查询。

示例graphql查询: {
      products (first: 3) {
        edges {
          node {
            id
            title
            handle
          }
        }
      }
    }

提供这个查询将返回前3个产品的id、标题和句柄。
"""
        from shopify import GraphQL

        return GraphQL().execute(graphql_query)

run_graphql_query #

run_graphql_query(graphql_query: str)

针对Shopify Admin API运行一个GraphQL查询。

{

products (first: 3) { edges { node { id title handle } } }

}

提供这个查询将返回前3个产品的id、标题和句柄。

Source code in llama_index/tools/shopify/base.py
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
    def run_graphql_query(self, graphql_query: str):
        """针对Shopify Admin API运行一个GraphQL查询。

示例graphql查询: {
      products (first: 3) {
        edges {
          node {
            id
            title
            handle
          }
        }
      }
    }

提供这个查询将返回前3个产品的id、标题和句柄。
"""
        from shopify import GraphQL

        return GraphQL().execute(graphql_query)