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:
53
README.md
53
README.md
@@ -24,11 +24,14 @@ cp .env.example .env
|
||||
bun run src/index.ts input/<input.csv|xlsx> [--out output/results.xlsx]
|
||||
```
|
||||
|
||||
Add `--claude` to use Anthropic Claude instead of local LM Studio for LLM analysis.
|
||||
|
||||
Examples:
|
||||
|
||||
```bash
|
||||
bun run src/index.ts input/leads.xlsx
|
||||
bun run src/index.ts input/leads.csv --out output/results.xlsx
|
||||
bun run src/index.ts input/leads.xlsx --claude
|
||||
```
|
||||
|
||||
Large-file behavior:
|
||||
@@ -55,6 +58,14 @@ bun run monthly-sold
|
||||
bun run mid-range
|
||||
```
|
||||
|
||||
Use Claude for category LLM analysis:
|
||||
|
||||
```bash
|
||||
bun run bestsellers --claude
|
||||
bun run monthly-sold --claude
|
||||
bun run mid-range --claude
|
||||
```
|
||||
|
||||
Mid-range process:
|
||||
|
||||
- Script: `bun run mid-range`
|
||||
@@ -128,6 +139,12 @@ curl -X POST "http://localhost:3000/api/upc/lookup" \
|
||||
-d '{"upcs":["012345678901","098765432109"]}'
|
||||
```
|
||||
|
||||
Run the web server with Claude-backed LLM calls:
|
||||
|
||||
```bash
|
||||
bun run start:web -- --claude
|
||||
```
|
||||
|
||||
## Large UPC File Analysis (XLS/XLSX)
|
||||
|
||||
For supplier price lists that contain UPC/EAN values and unit cost, use the
|
||||
@@ -248,23 +265,25 @@ ASIN, Name, Brand, Category, Unit Cost, Current Price, Avg Price 90d, Sales Rank
|
||||
|
||||
## Environment variables
|
||||
|
||||
| Variable | Default | Description |
|
||||
| ----------------------- | -------------------------- | ----------------------------------------------------------------------- |
|
||||
| `KEEPA_API_KEY` | — | **Required.** Keepa API key |
|
||||
| `SP_API_CLIENT_ID` | — | LWA app client id from Solution Provider Portal |
|
||||
| `SP_API_CLIENT_SECRET` | — | LWA app client secret from Solution Provider Portal |
|
||||
| `SP_API_REFRESH_TOKEN` | — | Refresh token from self-authorization |
|
||||
| `SP_API_REGION` | `na` | SP-API endpoint region (`na`, `eu`, `fe`; `us` is accepted as `na`) |
|
||||
| `SP_API_MARKETPLACE_ID` | `ATVPDKIKX0DER` | Marketplace id used for pricing and fee calls (default: US) |
|
||||
| `SP_API_SELLER_ID` | — | Seller ID used for listing restrictions eligibility checks |
|
||||
| `SP_API_USE_SANDBOX` | `false` | Enable SP-API sandbox mode (`true`/`false`) |
|
||||
| `AWS_ACCESS_KEY_ID` | — | AWS credentials for SigV4 signing (required in most private app setups) |
|
||||
| `AWS_SECRET_ACCESS_KEY` | — | AWS credentials for SigV4 signing |
|
||||
| `AWS_SESSION_TOKEN` | — | Optional session token when using STS credentials |
|
||||
| `REDIS_URL` | `redis://localhost:6379` | Redis connection URL |
|
||||
| `LLM_URL` | `http://localhost:1234/v1` | LM Studio API base URL |
|
||||
| `LLM_MODEL` | `default` | Model name to pass to LM Studio |
|
||||
| `CACHE_TTL` | `86400` | Redis cache TTL in seconds |
|
||||
| Variable | Default | Description |
|
||||
| ----------------------- | ---------------------------- | ----------------------------------------------------------------------- |
|
||||
| `KEEPA_API_KEY` | — | **Required.** Keepa API key |
|
||||
| `SP_API_CLIENT_ID` | — | LWA app client id from Solution Provider Portal |
|
||||
| `SP_API_CLIENT_SECRET` | — | LWA app client secret from Solution Provider Portal |
|
||||
| `SP_API_REFRESH_TOKEN` | — | Refresh token from self-authorization |
|
||||
| `SP_API_REGION` | `na` | SP-API endpoint region (`na`, `eu`, `fe`; `us` is accepted as `na`) |
|
||||
| `SP_API_MARKETPLACE_ID` | `ATVPDKIKX0DER` | Marketplace id used for pricing and fee calls (default: US) |
|
||||
| `SP_API_SELLER_ID` | — | Seller ID used for listing restrictions eligibility checks |
|
||||
| `SP_API_USE_SANDBOX` | `false` | Enable SP-API sandbox mode (`true`/`false`) |
|
||||
| `AWS_ACCESS_KEY_ID` | — | AWS credentials for SigV4 signing (required in most private app setups) |
|
||||
| `AWS_SECRET_ACCESS_KEY` | — | AWS credentials for SigV4 signing |
|
||||
| `AWS_SESSION_TOKEN` | — | Optional session token when using STS credentials |
|
||||
| `REDIS_URL` | `redis://localhost:6379` | Redis connection URL |
|
||||
| `LLM_URL` | `http://localhost:1234/v1` | LM Studio API base URL |
|
||||
| `LLM_MODEL` | `default` | Model name to pass to LM Studio |
|
||||
| `ANTHROPIC_API_KEY` | — | Required when running any LLM script with `--claude` |
|
||||
| `ANTHROPIC_MODEL` | `claude-3-5-sonnet-20241022` | Claude model ID used with `--claude` |
|
||||
| `CACHE_TTL` | `86400` | Redis cache TTL in seconds |
|
||||
|
||||
## Notes
|
||||
|
||||
|
||||
Reference in New Issue
Block a user