Switch scraper text generation to DeepSeek with generic LLM interface#87
Open
ThatXliner wants to merge 1 commit into
Open
Switch scraper text generation to DeepSeek with generic LLM interface#87ThatXliner wants to merge 1 commit into
ThatXliner wants to merge 1 commit into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
… 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>
Contributor
There was a problem hiding this comment.
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
llmmodel 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/deepseekdependency 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 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 | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
llmexport andLLMnaming for easy provider swapsChanges
provider.ts: Export singlellmmodel (currently DeepSeek V4 Flash)costs.ts: GenerictrackLLMUsage()andllmCost(not provider-specific)metrics.ts: Display 'LLM tokens' instead of provider namellminstead of provider-specific modelWhy 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
DEEPSEEK_API_KEYenv var🤖 Generated with Claude Code