Deekseek integration#468
Conversation
|
@codex review |
There was a problem hiding this comment.
Pull request overview
Adds a new DeepSeek provider plugin to OpenUsage, enabling users to display their DeepSeek account balance as a progress line (using a user-supplied starting balance) and wiring up the necessary docs and host env-var access.
Changes:
- Added a new
deepseekplugin (manifest, JS probe, icon) and accompanying Vitest coverage. - Documented the provider and linked it from the main README.
- Whitelisted
DEEPSEEK_API_KEYandDEEPSEEK_INITIAL_BALANCEfor the Tauri host env API.
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
src-tauri/src/plugin_engine/host_api.rs |
Whitelists DeepSeek-related env vars for plugin access. |
README.md |
Adds DeepSeek to the providers list. |
plugins/deepseek/plugin.test.js |
Introduces unit tests for DeepSeek probe behavior and error handling. |
plugins/deepseek/plugin.json |
Adds the DeepSeek plugin manifest and declares the output line(s). |
plugins/deepseek/plugin.js |
Implements the DeepSeek balance probe against /user/balance. |
plugins/deepseek/icon.svg |
Adds the provider icon. |
docs/providers/deepseek.md |
Adds provider documentation (auth, endpoint, mapping, errors). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const remainingBalance = findBalance(json.balance_infos) | ||
| if (remainingBalance === null) { | ||
| throw "Could not find balance in response." | ||
| } | ||
|
|
||
| const used = Math.max(0, initialBalance - remainingBalance) | ||
|
|
||
| const line = { | ||
| label: "Balance", | ||
| used: used, | ||
| limit: initialBalance, | ||
| format: { kind: "dollars" }, | ||
| } |
| const USAGE_URL = "https://api.deepseek.com/user/balance" | ||
|
|
| const plugin = await loadPlugin() | ||
| const result = plugin.probe(ctx) | ||
|
|
||
| // remaining = 55.00, initial = 100, used = 45.00 |
| it("reads key from all env vars", async () => { | ||
| const ctx = makeCtx() | ||
| setEnv(ctx, { DEEPSEEK_API_KEY: "sk-from-key", DEEPSEEK_INITIAL_BALANCE: "10" }) | ||
|
|
||
| const payload = successPayload() | ||
| ctx.util.request = vi.fn(() => ({ | ||
| status: 200, | ||
| bodyText: JSON.stringify(payload), | ||
| })) | ||
|
|
||
| const plugin = await loadPlugin() | ||
| expect(() => plugin.probe(ctx)).not.toThrow() | ||
| }) |
| | Variable | Required | Description | | ||
| |---|---|---| | ||
| | `DEEPSEEK_API_KEY` | yes | DeepSeek API key from [platform.deepseek.com](https://platform.deepseek.com/) | | ||
| | `DEEPSEEK_INITIAL_BALANCE` | yes | Your starting balance (e.g. `10.00`). Must be > 0. | | ||
|
|
| - [**Codex**](docs/providers/codex.md) / session, weekly, reviews, credits | ||
| - [**Copilot**](docs/providers/copilot.md) / premium, chat, completions | ||
| - [**Cursor**](docs/providers/cursor.md) / credits, total usage, auto usage, API usage, on-demand, CLI auth | ||
| - [**DeepSeek**](docs/providers/deepseek.md) / balance (USD) |
|
Codex Review: Something went wrong. Try again later by commenting “@codex review”. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 30e4d020c4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (info.currency === "USD") return balance | ||
| if (info.currency === "CNY") cnyBalance = balance | ||
| } | ||
| return cnyBalance |
There was a problem hiding this comment.
Reject or convert CNY before reporting dollar usage
DeepSeek’s /user/balance can return CNY balances, but findBalance falls back to CNY and the plugin still reports the metric with format: { kind: "dollars" }. In that case, the app subtracts a CNY amount from DEEPSEEK_INITIAL_BALANCE and presents the result as USD, which produces incorrect spend values for CNY-only accounts. Handle non-USD explicitly (convert with a reliable rate or fail with a clear error) before emitting a dollars-formatted progress line.
Useful? React with 👍 / 👎.
Description
Add Deepseek as a provider
Related Issue
Address #467
Type of Change
Testing
bun run buildand it succeededbun run testand all tests passbun tauri devScreenshots
Checklist
mainbranchSummary by cubic
Adds the
deepseekprovider plugin to fetch account balance from DeepSeek’s API and show it as a dollar progress line. Includes docs, tests, icon, and env var whitelist support for seamless setup.New Features
deepseekprovider plugin (GEThttps://api.deepseek.com/user/balance) showing Balance as dollars (used =DEEPSEEK_INITIAL_BALANCE− remaining).docs/providers/deepseek.md), README entry, icon, and tests.DEEPSEEK_API_KEYandDEEPSEEK_INITIAL_BALANCEin the Tauri host.Migration
DEEPSEEK_API_KEY.DEEPSEEK_INITIAL_BALANCEto your starting balance (e.g.,10.00).Written for commit 30e4d02. Summary will update on new commits.