-
-
Notifications
You must be signed in to change notification settings - Fork 110
feat: add Deepseek support #221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
π WalkthroughWalkthroughAdds a new TypeScript package Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Adapter as DeepSeekTextAdapter
participant Converter as Option/Message Converter
participant DeepSeekAPI as DeepSeek API (OpenAI-compatible)
participant Processor as StreamProcessor
Client->>Adapter: chatStream(options)
Adapter->>Converter: mapTextOptionsToDeepSeek(options)
Converter->>Adapter: mapped request payload
Adapter->>DeepSeekAPI: POST /chat/completions (stream=true)
DeepSeekAPI-->>Adapter: streaming chunks (events)
Adapter->>Processor: processDeepSeekStreamChunks(stream)
loop per chunk
Processor-->>Client: yield StreamChunk (content / tool_call / done)
end
Estimated code review effortπ― 4 (Complex) | β±οΈ ~45 minutes Suggested reviewers
Poem
π₯ Pre-merge checks | β 3β Passed checks (3 passed)
βοΈ Tip: You can configure your own custom pre-merge checks in the settings. β¨ Finishing touches
π§Ή Recent nitpick comments
π Recent review detailsConfiguration used: defaults Review profile: CHILL Plan: Pro π Files selected for processing (19)
π§ Files skipped from review as they are similar to previous changes (9)
π§° Additional context usedπ Path-based instructions (5)**/*.{ts,tsx}π CodeRabbit inference engine (CLAUDE.md)
Files:
**/*.{ts,tsx,js,jsx}π CodeRabbit inference engine (CLAUDE.md)
Files:
packages/typescript/*/src/model-meta.tsπ CodeRabbit inference engine (CLAUDE.md)
Files:
packages/typescript/*/src/adapters/*.tsπ CodeRabbit inference engine (CLAUDE.md)
Files:
**/*.test.tsπ CodeRabbit inference engine (CLAUDE.md)
Files:
π§ Learnings (13)π Common learningsπ Learning: 2025-12-13T17:09:09.794ZApplied to files:
π Learning: 2025-12-13T17:09:09.794ZApplied to files:
π Learning: 2025-12-13T17:09:09.794ZApplied to files:
π Learning: 2025-12-13T17:09:09.794ZApplied to files:
π Learning: 2025-12-27T20:22:51.232ZApplied to files:
π Learning: 2025-12-27T21:39:29.563ZApplied to files:
π Learning: 2025-12-13T17:09:09.794ZApplied to files:
π Learning: 2025-12-13T17:09:09.794ZApplied to files:
π Learning: 2025-12-13T17:09:09.794ZApplied to files:
π Learning: 2025-12-13T17:09:09.794ZApplied to files:
π Learning: 2025-12-13T17:09:09.794ZApplied to files:
π Learning: 2025-12-13T17:09:09.794ZApplied to files:
𧬠Code graph analysis (6)packages/typescript/ai-deepseek/src/utils/schema-converter.ts (1)
packages/typescript/ai-deepseek/src/message-types.ts (1)
packages/typescript/ai-deepseek/src/model-meta.ts (1)
packages/typescript/ai-deepseek/src/tools/function-tool.ts (2)
packages/typescript/ai-deepseek/src/utils/client.ts (1)
packages/typescript/ai-deepseek/tests/deepseek-adapter.test.ts (4)
πͺ Biome (2.1.2)packages/typescript/ai-deepseek/src/message-types.ts[error] 46-46: An empty interface is equivalent to {}. Safe fix: Use a type alias instead. (lint/suspicious/noEmptyInterface) [error] 52-52: An empty interface is equivalent to {}. Safe fix: Use a type alias instead. (lint/suspicious/noEmptyInterface) [error] 58-58: An empty interface is equivalent to {}. Safe fix: Use a type alias instead. (lint/suspicious/noEmptyInterface) πͺ markdownlint-cli2 (0.18.1)packages/typescript/ai-deepseek/README.md2-2: Images should have alternate text (alt text) (MD045, no-alt-text) 12-12: Hard tabs (MD010, no-hard-tabs) 23-23: Hard tabs (MD010, no-hard-tabs) 24-24: Hard tabs (MD010, no-hard-tabs) 25-25: Hard tabs (MD010, no-hard-tabs) 46-46: Heading levels should only increment by one level at a time (MD001, heading-increment) π Additional comments (26)
βοΈ Tip: You can disable this entire section by setting Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 8
π€ Fix all issues with AI agents
In @packages/typescript/ai-deepseek/package.json:
- Around line 41-51: The package.json for ai-deepseek is missing zod in
devDependencies; add "zod": "^4.2.0" to the devDependencies section (alongside
@vitest/coverage-v8 and vite) so test/dev tooling matches ai-openai and
ai-anthropic and the peerDependency entry remains as-is.
In @packages/typescript/ai-deepseek/README.md:
- Around line 248-253: The README example uses eval(expression) inside the
tool.server implementation (serverTool) which promotes a security risk; replace
the eval call with a safe expression evaluator or parser (e.g., a math
expression parser) and update the serverTool/tool.server example to parse and
evaluate only numeric expressions, validate inputs (the expression parameter)
and return the numeric result object ({ result: number }) without executing
arbitrary JS code.
In @packages/typescript/ai-deepseek/src/adapters/summarize.ts:
- Around line 49-76: The summarize method is ignoring the provider-level
DeepSeekSummarizeProviderOptions (temperature and maxTokens) and instead
hardcodes temperature: 0.3 and uses options.maxLength; update summarize to use
the configured provider options (e.g., this.options.temperature and
this.options.maxTokens or a merged fallback) when calling
this.textAdapter.chatStream so temperature and maxTokens come from
DeepSeekSummarizeProviderOptions with sensible fallbacks to the per-call
SummarizationOptions (such as options.maxLength) if not set.
In @packages/typescript/ai-deepseek/src/adapters/text.ts:
- Around line 363-373: The tool message mapping currently uses
message.toolCallId || '' which can produce an empty tool_call_id and break
DeepSeek API calls; inside the block handling message.role === 'tool' (the tool
message mapping), validate that message.toolCallId exists and is non-empty and
throw a clear error if it is missing (instead of returning an empty string),
then populate tool_call_id with message.toolCallId; ensure the error message
references the message or context so callers can trace which tool message lacked
an id.
In @packages/typescript/ai-deepseek/src/model-meta.ts:
- Around line 45-62: DEEPSEEK_REASONER's metadata incorrectly advertises
tool_calling support; edit the DEEPSEEK_REASONER constant and remove
'tool_calling' from the supports.capabilities array so it only lists
['reasoning'] (retain other fields unchanged) to prevent consumers from
attempting unsupported OpenAI-style function/tool calls and direct tool-calling
workflows to deepseek-chat instead.
In @packages/typescript/ai-deepseek/src/utils/schema-converter.ts:
- Around line 64-91: The current else-if chain in
makeDeepSeekStructuredOutputCompatible leaves optional nested objects/arrays
non-nullable because recursion occurs before nullable handling; modify the
function so that when wasOptional is true you add 'null' to the property's type
regardless of whether prop.type === 'object' or prop.type === 'array' (either by
applying the nullable transformation before recursing into prop (for
objects/arrays) or by post-processing the already-recursed properties[propName]
to union its type with 'null'); update the branches handling prop.type ===
'object' and prop.type === 'array' to incorporate this nullable union for
optional propName and ensure Array.isArray checks use prop.type on the final
properties[propName] if you choose post-processing.
In @packages/typescript/ai-deepseek/tests/deepseek-adapter.test.ts:
- Around line 31-43: The test overwrites process.env.DEEPSEEK_API_KEY without
preserving the prior value; update the test that calls
deepseekText('deepseek-chat') to first store the original
process.env.DEEPSEEK_API_KEY (e.g., orig = process.env.DEEPSEEK_API_KEY), set
the env var to 'test-env-api-key', run the assertions on the returned adapter
(adapter.name, adapter.kind, adapter.model), and finally restore
process.env.DEEPSEEK_API_KEY to the saved original (or delete it if original was
undefined) so the environment is not mutated after the test.
π§Ή Nitpick comments (4)
packages/typescript/ai-deepseek/src/message-types.ts (1)
46-58: Consider converting empty interfaces to type aliases or adding a brief justification comment.The static analysis tool flags these empty interfaces. While keeping them as interfaces is valid for declaration merging and future extensibility, you could either:
- Add a brief comment explaining they're placeholders for future extension, or
- Convert to type aliases if declaration merging isn't needed
This is a minor stylistic preference; the current approach is acceptable.
β»οΈ Option: Convert to type aliases
-export interface DeepSeekVideoMetadata {} +/** Placeholder for future video metadata options */ +export type DeepSeekVideoMetadata = Record<string, never> -export interface DeepSeekDocumentMetadata {} +/** Placeholder for future document metadata options */ +export type DeepSeekDocumentMetadata = Record<string, never> -export interface DeepSeekTextMetadata {} +/** Placeholder for future text metadata options */ +export type DeepSeekTextMetadata = Record<string, never>packages/typescript/ai-deepseek/package.json (1)
15-20: Consider adding/adapterssubpath export for tree-shaking.Based on learnings, the package should expose adapters via a dedicated subpath export (e.g.,
@tanstack/ai-deepseek/adapters) to enable optimal tree-shaking and align with other adapter packages in the ecosystem.β»οΈ Suggested exports configuration
"exports": { ".": { "types": "./dist/esm/index.d.ts", "import": "./dist/esm/index.js" + }, + "./adapters": { + "types": "./dist/esm/adapters/index.d.ts", + "import": "./dist/esm/adapters/index.js" } },packages/typescript/ai-deepseek/src/utils/client.ts (1)
43-45:generateIdmay produce inconsistent ID lengths.
Math.random().toString(36).substring(7)can produce variable-length strings (0-6 characters) depending on the random value. For consistent, predictable IDs, consider usingsubstring(2, 8)to always get 6 characters from the base-36 representation.β»οΈ Suggested fix
export function generateId(prefix: string): string { - return `${prefix}-${Date.now()}-${Math.random().toString(36).substring(7)}` + return `${prefix}-${Date.now()}-${Math.random().toString(36).substring(2, 8)}` }packages/typescript/ai-deepseek/src/adapters/text.ts (1)
78-85: Consider removing verbose console logging in production adapter.The error handling logs the full error, stack trace, and message to console. While useful for debugging, this verbose logging may expose sensitive information and clutter production logs. Consider using a configurable debug mode or structured logging.
β»οΈ Suggested minimal logging
} catch (error: unknown) { const err = error as Error - console.error('>>> chatStream: Fatal error during response creation <<<') - console.error('>>> Error message:', err.message) - console.error('>>> Error stack:', err.stack) - console.error('>>> Full error:', err) throw error }
π Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
π Files selected for processing (19)
.changeset/add-deepseek-adapter.mdpackages/typescript/ai-deepseek/CHANGELOG.mdpackages/typescript/ai-deepseek/README.mdpackages/typescript/ai-deepseek/package.jsonpackages/typescript/ai-deepseek/src/adapters/summarize.tspackages/typescript/ai-deepseek/src/adapters/text.tspackages/typescript/ai-deepseek/src/index.tspackages/typescript/ai-deepseek/src/message-types.tspackages/typescript/ai-deepseek/src/model-meta.tspackages/typescript/ai-deepseek/src/text/text-provider-options.tspackages/typescript/ai-deepseek/src/tools/function-tool.tspackages/typescript/ai-deepseek/src/tools/index.tspackages/typescript/ai-deepseek/src/tools/tool-converter.tspackages/typescript/ai-deepseek/src/utils/client.tspackages/typescript/ai-deepseek/src/utils/index.tspackages/typescript/ai-deepseek/src/utils/schema-converter.tspackages/typescript/ai-deepseek/tests/deepseek-adapter.test.tspackages/typescript/ai-deepseek/tsconfig.jsonpackages/typescript/ai-deepseek/vite.config.ts
π§° Additional context used
π Path-based instructions (6)
**/*.{ts,tsx}
π CodeRabbit inference engine (CLAUDE.md)
**/*.{ts,tsx}: Use tree-shakeable adapter architecture for provider implementations - export specialized adapters (text, embedding, summarize, image) as separate imports from/adapterssubpath rather than monolithic adapters
Use Zod for runtime schema validation and type inference, particularly for tool input/output definitions withtoolDefinition()and Zod schema inference
Implement isomorphic tool system usingtoolDefinition()with.server()and.client()implementations for dual-environment execution
Use type-safe per-model configuration with provider options typed based on selected model to ensure compile-time safety
Implement stream processing with StreamProcessor for handling chunked responses and support partial JSON parsing for streaming AI responses
Files:
packages/typescript/ai-deepseek/src/tools/index.tspackages/typescript/ai-deepseek/src/tools/tool-converter.tspackages/typescript/ai-deepseek/src/text/text-provider-options.tspackages/typescript/ai-deepseek/src/message-types.tspackages/typescript/ai-deepseek/src/index.tspackages/typescript/ai-deepseek/vite.config.tspackages/typescript/ai-deepseek/tests/deepseek-adapter.test.tspackages/typescript/ai-deepseek/src/utils/schema-converter.tspackages/typescript/ai-deepseek/src/utils/client.tspackages/typescript/ai-deepseek/src/adapters/text.tspackages/typescript/ai-deepseek/src/utils/index.tspackages/typescript/ai-deepseek/src/model-meta.tspackages/typescript/ai-deepseek/src/tools/function-tool.tspackages/typescript/ai-deepseek/src/adapters/summarize.ts
**/*.{ts,tsx,js,jsx}
π CodeRabbit inference engine (CLAUDE.md)
Use camelCase for function and variable names throughout the codebase
Files:
packages/typescript/ai-deepseek/src/tools/index.tspackages/typescript/ai-deepseek/src/tools/tool-converter.tspackages/typescript/ai-deepseek/src/text/text-provider-options.tspackages/typescript/ai-deepseek/src/message-types.tspackages/typescript/ai-deepseek/src/index.tspackages/typescript/ai-deepseek/vite.config.tspackages/typescript/ai-deepseek/tests/deepseek-adapter.test.tspackages/typescript/ai-deepseek/src/utils/schema-converter.tspackages/typescript/ai-deepseek/src/utils/client.tspackages/typescript/ai-deepseek/src/adapters/text.tspackages/typescript/ai-deepseek/src/utils/index.tspackages/typescript/ai-deepseek/src/model-meta.tspackages/typescript/ai-deepseek/src/tools/function-tool.tspackages/typescript/ai-deepseek/src/adapters/summarize.ts
packages/typescript/*/src/index.ts
π CodeRabbit inference engine (CLAUDE.md)
Export tree-shakeable adapters with clear subpath exports in package.json (e.g.,
@tanstack/ai/adapters,@tanstack/ai-openai/adapters) to minimize bundle size
Files:
packages/typescript/ai-deepseek/src/index.ts
**/*.test.ts
π CodeRabbit inference engine (CLAUDE.md)
Write unit tests using Vitest alongside source files with
.test.tsnaming convention
Files:
packages/typescript/ai-deepseek/tests/deepseek-adapter.test.ts
packages/typescript/*/src/adapters/*.ts
π CodeRabbit inference engine (CLAUDE.md)
Create individual adapter implementations for each provider capability (text, embed, summarize, image) with separate exports to enable tree-shaking
Files:
packages/typescript/ai-deepseek/src/adapters/text.tspackages/typescript/ai-deepseek/src/adapters/summarize.ts
packages/typescript/*/src/model-meta.ts
π CodeRabbit inference engine (CLAUDE.md)
Maintain model metadata files that define provider options and capabilities per model for per-model type safety
Files:
packages/typescript/ai-deepseek/src/model-meta.ts
π§ Learnings (16)
π Common learnings
Learnt from: CR
Repo: TanStack/ai PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-13T17:09:09.794Z
Learning: Applies to packages/typescript/*/src/index.ts : Export tree-shakeable adapters with clear subpath exports in package.json (e.g., `tanstack/ai/adapters`, `tanstack/ai-openai/adapters`) to minimize bundle size
Learnt from: CR
Repo: TanStack/ai PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-13T17:09:09.794Z
Learning: Applies to packages/typescript/*/src/adapters/*.ts : Create individual adapter implementations for each provider capability (text, embed, summarize, image) with separate exports to enable tree-shaking
Learnt from: CR
Repo: TanStack/ai PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-13T17:09:09.794Z
Learning: Applies to **/*.{ts,tsx} : Use tree-shakeable adapter architecture for provider implementations - export specialized adapters (text, embedding, summarize, image) as separate imports from `/adapters` subpath rather than monolithic adapters
Learnt from: CR
Repo: TanStack/ai PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-13T17:09:09.794Z
Learning: Implement framework integrations using the headless `tanstack/ai-client` for state management with framework-specific hooks (useChat) on top
π Learning: 2025-12-13T17:09:09.794Z
Learnt from: CR
Repo: TanStack/ai PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-13T17:09:09.794Z
Learning: Applies to packages/typescript/*/src/index.ts : Export tree-shakeable adapters with clear subpath exports in package.json (e.g., `tanstack/ai/adapters`, `tanstack/ai-openai/adapters`) to minimize bundle size
Applied to files:
packages/typescript/ai-deepseek/src/tools/index.tspackages/typescript/ai-deepseek/src/index.tspackages/typescript/ai-deepseek/vite.config.tspackages/typescript/ai-deepseek/tests/deepseek-adapter.test.tspackages/typescript/ai-deepseek/src/utils/schema-converter.tspackages/typescript/ai-deepseek/README.mdpackages/typescript/ai-deepseek/src/utils/client.tspackages/typescript/ai-deepseek/src/adapters/text.ts.changeset/add-deepseek-adapter.mdpackages/typescript/ai-deepseek/src/utils/index.tspackages/typescript/ai-deepseek/tsconfig.jsonpackages/typescript/ai-deepseek/CHANGELOG.mdpackages/typescript/ai-deepseek/package.jsonpackages/typescript/ai-deepseek/src/adapters/summarize.ts
π Learning: 2025-12-13T17:09:09.794Z
Learnt from: CR
Repo: TanStack/ai PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-13T17:09:09.794Z
Learning: Applies to packages/typescript/*/src/adapters/*.ts : Create individual adapter implementations for each provider capability (text, embed, summarize, image) with separate exports to enable tree-shaking
Applied to files:
packages/typescript/ai-deepseek/src/tools/index.tspackages/typescript/ai-deepseek/src/tools/tool-converter.tspackages/typescript/ai-deepseek/src/text/text-provider-options.tspackages/typescript/ai-deepseek/src/index.tspackages/typescript/ai-deepseek/tests/deepseek-adapter.test.tspackages/typescript/ai-deepseek/README.mdpackages/typescript/ai-deepseek/src/adapters/text.ts.changeset/add-deepseek-adapter.mdpackages/typescript/ai-deepseek/src/utils/index.tspackages/typescript/ai-deepseek/tsconfig.jsonpackages/typescript/ai-deepseek/src/model-meta.tspackages/typescript/ai-deepseek/CHANGELOG.mdpackages/typescript/ai-deepseek/package.jsonpackages/typescript/ai-deepseek/src/tools/function-tool.tspackages/typescript/ai-deepseek/src/adapters/summarize.ts
π Learning: 2025-12-13T17:09:09.794Z
Learnt from: CR
Repo: TanStack/ai PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-13T17:09:09.794Z
Learning: Applies to **/*.{ts,tsx} : Use tree-shakeable adapter architecture for provider implementations - export specialized adapters (text, embedding, summarize, image) as separate imports from `/adapters` subpath rather than monolithic adapters
Applied to files:
packages/typescript/ai-deepseek/src/tools/index.tspackages/typescript/ai-deepseek/src/tools/tool-converter.tspackages/typescript/ai-deepseek/src/text/text-provider-options.tspackages/typescript/ai-deepseek/src/index.tspackages/typescript/ai-deepseek/tests/deepseek-adapter.test.tspackages/typescript/ai-deepseek/README.mdpackages/typescript/ai-deepseek/src/adapters/text.ts.changeset/add-deepseek-adapter.mdpackages/typescript/ai-deepseek/CHANGELOG.mdpackages/typescript/ai-deepseek/package.jsonpackages/typescript/ai-deepseek/src/adapters/summarize.ts
π Learning: 2025-12-13T17:09:09.794Z
Learnt from: CR
Repo: TanStack/ai PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-13T17:09:09.794Z
Learning: Applies to **/*.{ts,tsx} : Implement isomorphic tool system using `toolDefinition()` with `.server()` and `.client()` implementations for dual-environment execution
Applied to files:
packages/typescript/ai-deepseek/src/tools/index.tspackages/typescript/ai-deepseek/src/tools/tool-converter.tspackages/typescript/ai-deepseek/src/tools/function-tool.ts
π Learning: 2025-12-13T17:09:09.794Z
Learnt from: CR
Repo: TanStack/ai PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-13T17:09:09.794Z
Learning: Applies to **/*.{ts,tsx} : Use type-safe per-model configuration with provider options typed based on selected model to ensure compile-time safety
Applied to files:
packages/typescript/ai-deepseek/src/text/text-provider-options.tspackages/typescript/ai-deepseek/src/model-meta.ts
π Learning: 2025-12-13T17:09:09.794Z
Learnt from: CR
Repo: TanStack/ai PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-13T17:09:09.794Z
Learning: Applies to packages/typescript/*/src/model-meta.ts : Maintain model metadata files that define provider options and capabilities per model for per-model type safety
Applied to files:
packages/typescript/ai-deepseek/src/text/text-provider-options.tspackages/typescript/ai-deepseek/src/message-types.tspackages/typescript/ai-deepseek/src/index.tspackages/typescript/ai-deepseek/src/adapters/text.tspackages/typescript/ai-deepseek/src/model-meta.ts
π Learning: 2025-12-13T17:09:09.794Z
Learnt from: CR
Repo: TanStack/ai PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-13T17:09:09.794Z
Learning: Maintain type safety through multimodal content support (image, audio, video, document) with model capability awareness
Applied to files:
packages/typescript/ai-deepseek/src/message-types.ts
π Learning: 2025-12-27T20:22:51.232Z
Learnt from: harry-whorlow
Repo: TanStack/ai PR: 117
File: packages/typescript/ai-ollama/src/meta/model-meta-gpt-oss.ts:92-97
Timestamp: 2025-12-27T20:22:51.232Z
Learning: In the ai-ollama package's model-meta files (packages/typescript/ai-ollama/src/meta/model-meta-*.ts), capability-related comments follow a standard template format across all files for consistency, even if the comment text doesn't precisely match individual model capabilities. This is an intentional design choice to maintain uniformity across the codebase.
Applied to files:
packages/typescript/ai-deepseek/src/message-types.tspackages/typescript/ai-deepseek/src/model-meta.ts
π Learning: 2025-12-27T21:39:29.563Z
Learnt from: harry-whorlow
Repo: TanStack/ai PR: 117
File: packages/typescript/ai-ollama/src/meta/model-meta-llama-guard3.ts:70-75
Timestamp: 2025-12-27T21:39:29.563Z
Learning: The standard template comments in ai-ollama model-meta files (like "Models with text, image, audio, video (no document)") should not be modified to match individual model capabilities, as they are intentionally kept uniform across all model-meta-*.ts files for consistency, regardless of what each specific model actually supports.
Applied to files:
packages/typescript/ai-deepseek/src/message-types.tspackages/typescript/ai-deepseek/src/model-meta.ts
π Learning: 2025-12-13T17:09:09.794Z
Learnt from: CR
Repo: TanStack/ai PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-13T17:09:09.794Z
Learning: Applies to **/*.test.ts : Write unit tests using Vitest alongside source files with `.test.ts` naming convention
Applied to files:
packages/typescript/ai-deepseek/vite.config.tspackages/typescript/ai-deepseek/tsconfig.json
π Learning: 2025-12-13T17:09:09.794Z
Learnt from: CR
Repo: TanStack/ai PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-13T17:09:09.794Z
Learning: Applies to .eslintrc* : Use ESLint with custom TanStack config for linting all TypeScript and JavaScript files
Applied to files:
packages/typescript/ai-deepseek/vite.config.tspackages/typescript/ai-deepseek/tsconfig.jsonpackages/typescript/ai-deepseek/package.json
π Learning: 2025-12-13T17:09:09.794Z
Learnt from: CR
Repo: TanStack/ai PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-13T17:09:09.794Z
Learning: Applies to **/*.{ts,tsx} : Use Zod for runtime schema validation and type inference, particularly for tool input/output definitions with `toolDefinition()` and Zod schema inference
Applied to files:
packages/typescript/ai-deepseek/src/utils/schema-converter.tspackages/typescript/ai-deepseek/src/tools/function-tool.ts
π Learning: 2025-12-13T17:09:09.794Z
Learnt from: CR
Repo: TanStack/ai PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-13T17:09:09.794Z
Learning: Implement framework integrations using the headless `tanstack/ai-client` for state management with framework-specific hooks (useChat) on top
Applied to files:
packages/typescript/ai-deepseek/README.mdpackages/typescript/ai-deepseek/CHANGELOG.md
π Learning: 2025-12-13T17:09:09.794Z
Learnt from: CR
Repo: TanStack/ai PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-13T17:09:09.794Z
Learning: Applies to **/*.{ts,tsx} : Implement stream processing with StreamProcessor for handling chunked responses and support partial JSON parsing for streaming AI responses
Applied to files:
packages/typescript/ai-deepseek/src/adapters/text.ts
π Learning: 2025-12-13T17:09:09.794Z
Learnt from: CR
Repo: TanStack/ai PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-13T17:09:09.794Z
Learning: Applies to packages/*/package.json : Use `workspace:*` protocol for internal package dependencies in package.json (e.g., `"tanstack/ai": "workspace:*"`)
Applied to files:
packages/typescript/ai-deepseek/package.json
𧬠Code graph analysis (3)
packages/typescript/ai-deepseek/src/text/text-provider-options.ts (4)
packages/typescript/ai-deepseek/src/index.ts (1)
DeepSeekTextProviderOptions(11-11)packages/typescript/ai-deepseek/src/tools/function-tool.ts (1)
FunctionTool(6-6)packages/typescript/ai-deepseek/src/tools/index.ts (1)
FunctionTool(1-1)packages/typescript/ai-deepseek/src/adapters/text.ts (1)
ExternalTextProviderOptions(40-40)
packages/typescript/ai-deepseek/tests/deepseek-adapter.test.ts (4)
packages/typescript/ai-deepseek/src/adapters/text.ts (2)
createDeepSeekText(482-490)deepseekText(516-524)packages/typescript/ai-deepseek/src/index.ts (5)
createDeepSeekText(8-8)deepseekText(9-9)createDeepSeekSummarize(17-17)deepseekSummarize(18-18)DEEPSEEK_CHAT_MODELS(34-34)packages/typescript/ai-deepseek/src/adapters/summarize.ts (2)
createDeepSeekSummarize(136-142)deepseekSummarize(168-174)packages/typescript/ai-deepseek/src/model-meta.ts (1)
DEEPSEEK_CHAT_MODELS(87-91)
packages/typescript/ai-deepseek/src/model-meta.ts (1)
packages/typescript/ai-deepseek/src/index.ts (5)
DEEPSEEK_CHAT_MODELS(34-34)DeepSeekModelInputModalitiesByName(30-30)DeepSeekChatModelProviderOptionsByName(29-29)ResolveProviderOptions(31-31)ResolveInputModalities(32-32)
πͺ Biome (2.1.2)
packages/typescript/ai-deepseek/src/message-types.ts
[error] 46-46: An empty interface is equivalent to {}.
Safe fix: Use a type alias instead.
(lint/suspicious/noEmptyInterface)
[error] 52-52: An empty interface is equivalent to {}.
Safe fix: Use a type alias instead.
(lint/suspicious/noEmptyInterface)
[error] 58-58: An empty interface is equivalent to {}.
Safe fix: Use a type alias instead.
(lint/suspicious/noEmptyInterface)
π Additional comments (24)
packages/typescript/ai-deepseek/tsconfig.json (1)
1-9: LGTM!The TypeScript configuration correctly extends the base config and sets up appropriate paths for the new package.
packages/typescript/ai-deepseek/CHANGELOG.md (1)
1-23: LGTM!The changelog comprehensively documents the initial release with accurate feature descriptions and appropriate caveats about limited multimodal support.
packages/typescript/ai-deepseek/src/message-types.ts (1)
64-70: LGTM!The metadata mapping interface provides clean type inference for multimodal message construction.
packages/typescript/ai-deepseek/src/utils/schema-converter.ts (2)
12-35: LGTM!The null-to-undefined transformation handles primitives, arrays, and objects correctly with clear documentation of the behavior.
119-135: LGTM!The utility provides reasonable handling for schema formats with appropriate error messaging for unsupported Zod schemas.
.changeset/add-deepseek-adapter.md (1)
1-5: LGTM!The changeset is properly formatted with an appropriate minor version bump for the new adapter package.
packages/typescript/ai-deepseek/src/tools/tool-converter.ts (1)
9-17: LGTM!Clean implementation with appropriate documentation explaining the function-tool-only conversion for DeepSeek's OpenAI-compatible API.
packages/typescript/ai-deepseek/src/tools/index.ts (1)
1-2: LGTM!Clean barrel exports following the tree-shakeable adapter architecture pattern. Individual exports enable consumers to import only what they need. Based on learnings about subpath exports.
packages/typescript/ai-deepseek/vite.config.ts (1)
1-36: LGTM!Well-structured Vitest configuration with appropriate coverage settings, exclusions, and integration with TanStack's shared Vite config. The ESM-only output (
cjs: false) aligns with modern package distribution.packages/typescript/ai-deepseek/tests/deepseek-adapter.test.ts (2)
97-124: LGTM!Good coverage for type safety assertions and configuration acceptance. The runtime checks for expected method types provide useful compile-time and runtime guarantees.
71-78: No issues found. The test correctly verifies thatDEEPSEEK_CHAT_MODELSmatches the actual model names defined inmodel-meta.ts:DEEPSEEK_V3.name('deepseek-chat'),DEEPSEEK_REASONER.name('deepseek-reasoner'), andDEEPSEEK_CODER_V2_INSTRUCT.name('deepseek-coder').packages/typescript/ai-deepseek/src/tools/function-tool.ts (2)
19-45: LGTM!The conversion logic correctly handles schema defaults, applies DeepSeek-specific strict mode transformations, and returns a properly typed
FunctionTool. Thesatisfieskeyword ensures type safety without widening.
1-3: No issue foundβthe import path is correct. The functionmakeDeepSeekStructuredOutputCompatibleis properly exported fromschema-converter.ts(line 48), so the import on line 1 offunction-tool.tswill resolve successfully without errors.packages/typescript/ai-deepseek/src/utils/index.ts (1)
1-9: LGTM!Clean barrel exports consolidating utility functions with clear module separation. This enables tree-shaking and provides a clean public API surface for DeepSeek utilities. Based on learnings about tree-shakeable exports.
packages/typescript/ai-deepseek/README.md (1)
1-311: Documentation is comprehensive and well-structured.The README provides excellent coverage of installation, usage patterns, streaming, tool calling, structured output, configuration, and error handling. The tree-shakeable adapter documentation aligns well with the coding guidelines.
packages/typescript/ai-deepseek/src/index.ts (1)
1-42: Well-organized tree-shakeable exports.The index file properly separates adapter exports from type exports, enabling tree-shaking and minimizing bundle size. This aligns with the coding guidelines for the package structure. Based on learnings, the tree-shakeable adapter architecture is correctly implemented.
packages/typescript/ai-deepseek/src/model-meta.ts (1)
1-44: Model metadata structure is well-designed.The
ModelMetainterface and type-safe mappings (ResolveProviderOptions,ResolveInputModalities) provide excellent compile-time safety for per-model configuration. This aligns with the coding guidelines for maintaining model metadata files. Based on learnings, per-model type safety is correctly implemented.Also applies to: 64-152
packages/typescript/ai-deepseek/src/utils/client.ts (1)
1-38: Client creation and environment detection look good.The
createDeepSeekClientproperly wraps the OpenAI SDK with DeepSeek's base URL, andgetDeepSeekApiKeyFromEnvhandles both Node.js and browser environments with clear error messaging.packages/typescript/ai-deepseek/src/text/text-provider-options.ts (1)
1-77: Well-structured provider options with clear documentation.The type hierarchy (base β text β internal) provides clean separation of concerns. JSDoc comments document valid ranges for parameters. The no-op validator is an acceptable placeholder that maintains the validation contract for future enhancement.
packages/typescript/ai-deepseek/src/adapters/summarize.ts (2)
93-119: Prompt building logic is well-implemented.The
buildSummarizationPromptmethod handles different summarization styles cleanly with appropriate prompts for bullet-points, paragraph, and concise formats. Focus and maxLength constraints are properly incorporated.
122-174: Factory functions follow established patterns.Both
createDeepSeekSummarizeanddeepseekSummarizefactory functions mirror the text adapter's patterns, providing consistent API for explicit and environment-based API key usage. Documentation is thorough with examples.packages/typescript/ai-deepseek/src/adapters/text.ts (3)
100-171: Structured output implementation handles DeepSeek's limitations well.The implementation correctly notes that DeepSeek doesn't support OpenAI's
json_schemaformat and instead embeds the schema in the prompt withjson_objectmode. The error handling for JSON parse failures provides useful context.
173-305: Stream processing is robust with proper tool call accumulation.The
processDeepSeekStreamChunksmethod correctly handles incremental tool call arguments, accumulates content, and properly emits all event types. ThetoolCallsInProgressmap pattern handles the streaming nature of tool calls well.
430-524: Factory functions and helper methods are well-implemented.The
createDeepSeekTextanddeepseekTextfactories follow established patterns with proper type inference. Content normalization helpers (normalizeContent,extractTextContent) handle edge cases correctly.
π― Changes
Adding support for deepseek api
β Checklist
pnpm run test:pr.π Release Impact
Summary by CodeRabbit
New Features
Documentation
Tests
βοΈ Tip: You can customize this high-level summary in your review settings.