Class: ContextDev::Resources::AI

Inherits:
Object
  • Object
show all
Defined in:
lib/context_dev/resources/ai.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ AI

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of AI.

Parameters:



94
95
96
# File 'lib/context_dev/resources/ai.rb', line 94

def initialize(client:)
  @client = client
end

Instance Method Details

#ai_query(data_to_extract:, domain:, specific_pages: nil, timeout_ms: nil, request_options: {}) ⇒ ContextDev::Models::AIAIQueryResponse

Some parameter documentations has been truncated, see Models::AIAIQueryParams for more details.

Use AI to extract specific data points from a brand’s website. The AI will crawl the website and extract the requested information based on the provided data points.

Parameters:

Returns:

See Also:



28
29
30
31
32
33
34
35
36
37
# File 'lib/context_dev/resources/ai.rb', line 28

def ai_query(params)
  parsed, options = ContextDev::AIAIQueryParams.dump_request(params)
  @client.request(
    method: :post,
    path: "brand/ai/query",
    body: parsed,
    model: ContextDev::Models::AIAIQueryResponse,
    options: options
  )
end

#extract_product(url:, timeout_ms: nil, request_options: {}) ⇒ ContextDev::Models::AIExtractProductResponse

Some parameter documentations has been truncated, see Models::AIExtractProductParams for more details.

Beta feature: Given a single URL, determines if it is a product detail page, classifies the platform/product type, and extracts the product information. Supports Amazon, TikTok Shop, Etsy, and generic ecommerce sites.

Parameters:

  • url (String)

    The product page URL to extract product data from.

  • timeout_ms (Integer)

    Optional timeout in milliseconds for the request. Maximum allowed value is 30000

  • request_options (ContextDev::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



57
58
59
60
61
62
63
64
65
66
# File 'lib/context_dev/resources/ai.rb', line 57

def extract_product(params)
  parsed, options = ContextDev::AIExtractProductParams.dump_request(params)
  @client.request(
    method: :post,
    path: "brand/ai/product",
    body: parsed,
    model: ContextDev::Models::AIExtractProductResponse,
    options: options
  )
end

#extract_products(body:, request_options: {}) ⇒ ContextDev::Models::AIExtractProductsResponse

Beta feature: Extract product information from a brand’s website. We will analyze the website and return a list of products with details such as name, description, image, pricing, features, and more.



80
81
82
83
84
85
86
87
88
89
# File 'lib/context_dev/resources/ai.rb', line 80

def extract_products(params)
  parsed, options = ContextDev::AIExtractProductsParams.dump_request(params)
  @client.request(
    method: :post,
    path: "brand/ai/products",
    body: parsed[:body],
    model: ContextDev::Models::AIExtractProductsResponse,
    options: options
  )
end