Skip to content

Commit

Permalink
Remove Shopify admin dependency and use empty collections in product…
Browse files Browse the repository at this point in the history
… categorization
  • Loading branch information
jamalsoueidan committed Jun 28, 2024
1 parent 086b6fa commit 8db4630
Showing 1 changed file with 1 addition and 24 deletions.
25 changes: 1 addition & 24 deletions src/functions/openai/services/product-categorize.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import OpenAI from "openai";
import { shopifyAdmin } from "~/library/shopify";

const openai = new OpenAI({
apiKey: process.env.OPENAI_API_KEY,
Expand All @@ -13,12 +12,8 @@ export const OpenAIServiceProductCategorize = async ({
description?: string;
}) => {
try {
const { data } = await shopifyAdmin().request(COLLECTIONS);

const collections = data?.collections.nodes;

// Prepare collections data as context
const collectionsContext = JSON.stringify(collections, null, 2);
const collectionsContext = JSON.stringify([], null, 2);

const content = `
Given the following product title and description, response with the collection titles that this product fits into. The JSON structure should be:
Expand Down Expand Up @@ -65,21 +60,3 @@ If you think the product fits multiply collections, it's fine, include them all
console.error("Error:", error);
}
};

export const COLLECTIONS = `#graphql
query collections {
collections(first: 250, query: "-Alle AND -Subcategory AND -User") {
nodes {
id
title
description
ruleSet {
rules {
column
condition
}
}
}
}
}
` as const;

0 comments on commit 8db4630

Please sign in to comment.