feat: add support for Claude LLM integration across multiple modules
- Introduced `useClaude` option in `AnalysisPipelineOptions` to toggle Claude LLM usage. - Updated `processProductChunk` and `analyzeProducts` functions to accept and handle `useClaude` parameter. - Modified argument parsing in various scripts (`bestsellers-by-category`, `mid-range-sellers-by-category`, `top-monthly-sold-by-category`, etc.) to include `--claude` flag. - Enhanced `analyzeProductsInternal` to differentiate between LLM providers and handle requests to Claude API. - Added error handling for Claude API responses and ensured proper configuration for using Claude. - Updated documentation and usage messages to reflect the new `--claude` flag.
This commit is contained in:
@@ -22,6 +22,7 @@ export type AnalysisPipelineOptions = {
|
||||
llmBatchDelayMs?: number;
|
||||
llmRetryDelayMs?: number;
|
||||
sellability?: SellabilityFilter;
|
||||
useClaude?: boolean;
|
||||
};
|
||||
|
||||
export function chunkArray<T>(items: T[], chunkSize: number): T[][] {
|
||||
@@ -60,6 +61,7 @@ export async function processProductChunk(
|
||||
const llmBatchDelayMs = Math.max(0, options.llmBatchDelayMs ?? 5_000);
|
||||
const llmRetryDelayMs = Math.max(0, options.llmRetryDelayMs ?? 10_000);
|
||||
const sellabilityFilter = options.sellability ?? "available";
|
||||
const useClaude = options.useClaude === true;
|
||||
|
||||
console.log(`\nChecking cache for ${products.length} products...`);
|
||||
const cached = new Map<string, EnrichedProduct>();
|
||||
@@ -242,6 +244,7 @@ export async function processProductChunk(
|
||||
try {
|
||||
verdicts = await analyzeProducts(batch, {
|
||||
ignoreSellability: sellabilityFilter === "all",
|
||||
useClaude,
|
||||
});
|
||||
} catch {
|
||||
if (llmRetryDelayMs > 0) {
|
||||
@@ -250,6 +253,7 @@ export async function processProductChunk(
|
||||
try {
|
||||
verdicts = await analyzeProducts(batch, {
|
||||
ignoreSellability: sellabilityFilter === "all",
|
||||
useClaude,
|
||||
});
|
||||
} catch {
|
||||
verdicts = null;
|
||||
|
||||
Reference in New Issue
Block a user