Skip to content

Switch scraper text generation to DeepSeek with generic LLM interface#87

Open
ThatXliner wants to merge 1 commit into
mainfrom
use-deepseek
Open

Switch scraper text generation to DeepSeek with generic LLM interface#87
ThatXliner wants to merge 1 commit into
mainfrom
use-deepseek

Conversation

@ThatXliner
Copy link
Copy Markdown
Collaborator

Summary

Changes

  • provider.ts: Export single llm model (currently DeepSeek V4 Flash)
  • costs.ts: Generic trackLLMUsage() and llmCost (not provider-specific)
  • metrics.ts: Display 'LLM tokens' instead of provider name
  • All AI files now import llm instead of provider-specific model

Why generic naming?

Vercel AI SDK lets us swap providers easily. Generic naming means future switches (OpenAI, Anthropic, etc.) only require changing provider.ts — no renaming across codebase.

Env vars

  • DEEPSEEK_API_KEY (required)
  • GOOGLE_VERTEX_* (still needed for Imagen)
  • LLM_INPUT_PRICE, LLM_OUTPUT_PRICE (optional, for cost tracking)

Test plan

  • Set DEEPSEEK_API_KEY env var
  • Run scraper and verify text generation works
  • Verify image generation still works with Imagen

🤖 Generated with Claude Code

@vercel
Copy link
Copy Markdown

vercel Bot commented May 27, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
billion-nextjs Ready Ready Preview, Comment May 27, 2026 5:46am

… LLM interface

Replace Vertex AI Gemini with DeepSeek V4 Flash for text generation.
Use generic 'llm' export and 'LLM' naming throughout for easy provider
swaps via Vercel AI SDK. Imagen 3 retained for images until Flux (#86).

- Add @ai-sdk/deepseek, export single 'llm' model from provider.ts
- Rename cost tracking to generic LLM (not provider-specific)
- Update metrics display to show 'LLM tokens'

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR switches the scraper’s text generation from Vertex Gemini to DeepSeek V4 Flash while standardizing the codebase on a generic llm export so LLM providers can be swapped by editing a single module. It also generalizes cost tracking and metrics output away from provider-specific naming, while keeping Vertex Imagen 3 for image generation.

Changes:

  • Introduce DeepSeek provider and export a generic llm model for all text-generation call sites.
  • Rename Gemini-specific cost tracking/state to generic LLM token/cost tracking and update the metrics summary output.
  • Add @ai-sdk/deepseek dependency and update example environment variables for the new text-generation provider.

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pnpm-lock.yaml Adds DeepSeek SDK and its dependency snapshots.
apps/scraper/src/utils/db/metrics.ts Renames “Gemini tokens” reporting to generic “LLM tokens”.
apps/scraper/src/utils/costs.ts Renames Gemini usage tracking and pricing to generic LLM tracking.
apps/scraper/src/utils/ai/text-generation.ts Switches text generation model import to llm and updates usage tracking.
apps/scraper/src/utils/ai/provider.ts Adds DeepSeek provider initialization and exports llm; retains Vertex provider for Imagen.
apps/scraper/src/utils/ai/marketing-generation.ts Switches structured generation to use llm and generic usage tracking.
apps/scraper/src/utils/ai/image-keywords.ts Switches keyword generation to use llm and generic usage tracking.
apps/scraper/package.json Adds @ai-sdk/deepseek dependency.
.env.example Updates example env vars to include DeepSeek and Vertex (Imagen) configuration.
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +4 to +8
const deepseekApiKey = process.env.DEEPSEEK_API_KEY;

if (!deepseekApiKey) {
throw new Error("DEEPSEEK_API_KEY environment variable is required");
}
Comment thread .env.example
Comment on lines +30 to 38
# DeepSeek API key — used for AI text generation (summaries, articles, keywords)
# https://platform.deepseek.com/
DEEPSEEK_API_KEY=your_deepseek_api_key_here

# Google Vertex AI — used for Imagen 3 image generation
# https://console.cloud.google.com/vertex-ai
GOOGLE_VERTEX_PROJECT=your_gcp_project_id
GOOGLE_VERTEX_LOCATION=us-central1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants