Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

💄 style: add `sensenova-6.7-flash-lite` & `sensenova-u1-fast`support (#15306)

Zhijie He3ccc23152ce5
diff --git a/packages/model-bank/src/aiModels/sensenova.ts b/packages/model-bank/src/aiModels/sensenova.ts
index cd4cd4052a6..7bf629899f0 100644
--- a/packages/model-bank/src/aiModels/sensenova.ts
+++ b/packages/model-bank/src/aiModels/sensenova.ts
@@ -1,73 +1,22 @@
-import type { AIChatModelCard } from '../types/aiModel';
+import type { AIChatModelCard, AIImageModelCard } from '../types/aiModel';
-// https://platform.sensenova.cn/pricing
-// https://www.sensecore.cn/help/docs/model-as-a-service/nova/release
+// https://platform.sensenova.cn/docs
const sensenovaChatModels: AIChatModelCard[] = [
{
abilities: {
+ functionCall: true,
reasoning: true,
- // video: true,
- vision: true,
- },
- contextWindowTokens: 131_072,
- description:
- 'With comprehensive updates to multimodal, language, and reasoning data plus training strategy optimization, the new model significantly improves multimodal reasoning and generalized instruction following, supports up to a 128k context window, and excels in OCR and cultural tourism IP recognition tasks.',
- displayName: 'SenseNova V6.5 Pro',
- enabled: true,
- family: 'sensenova',
- id: 'SenseNova-V6-5-Pro',
- pricing: {
- currency: 'CNY',
- units: [
- { name: 'textInput', rate: 3, strategy: 'fixed', unit: 'millionTokens' },
- { name: 'textOutput', rate: 9, strategy: 'fixed', unit: 'millionTokens' },
- ],
- },
- releasedAt: '2025-07-23',
- // settings: {
- // extendParams: ['enableReasoning'],
- // },
- type: 'chat',
- },
- {
- abilities: {
- reasoning: true,
- // video: true,
vision: true,
},
- contextWindowTokens: 131_072,
+ contextWindowTokens: 262_144,
description:
- 'With comprehensive updates to multimodal, language, and reasoning data plus training strategy optimization, the new model significantly improves multimodal reasoning and generalized instruction following, supports up to a 128k context window, and excels in OCR and cultural tourism IP recognition tasks.',
- displayName: 'SenseNova V6.5 Turbo',
+ 'A lightweight multimodal agent model designed for real-world workflows, supporting both text-based conversations and image understanding. Lightweight and efficient, balancing performance, cost, and deployability. Native multimodal architecture with support for image understanding, including OCR and chart interpretation. Enhanced for office and productivity scenarios, with stable support for complex long-chain tasks. Improved token efficiency, enabling better cost control for complex workloads. Context length of 256K tokens (maximum input: 252K, maximum output: 64K)',
+ displayName: 'SenseNova 6.7 Flash Lite',
enabled: true,
family: 'sensenova',
- id: 'SenseNova-V6-5-Turbo',
- pricing: {
- currency: 'CNY',
- units: [
- { name: 'textInput', rate: 1.5, strategy: 'fixed', unit: 'millionTokens' },
- { name: 'textOutput', rate: 4.5, strategy: 'fixed', unit: 'millionTokens' },
- ],
- },
- releasedAt: '2025-07-23',
- // settings: {
- // extendParams: ['enableReasoning'],
- // },
- type: 'chat',
- },
- {
- abilities: {
- reasoning: true,
- },
- contextWindowTokens: 32_768,
- description:
- 'Qwen3-235B-A22B is a MoE model that introduces a hybrid reasoning mode, letting users switch seamlessly between thinking and non-thinking. It supports understanding and reasoning across 119 languages and dialects and has strong tool-calling capabilities, competing with mainstream models like DeepSeek R1, OpenAI o1, o3-mini, Grok 3, and Google Gemini 2.5 Pro across benchmarks in general ability, code and math, multilingual capability, and knowledge reasoning.',
- displayName: 'Qwen3 235B A22B',
- family: 'qwen',
- generation: 'qwen3',
- id: 'Qwen3-235B',
- organization: 'Qwen',
+ id: 'sensenova-6.7-flash-lite',
+ maxOutput: 65_536,
pricing: {
currency: 'CNY',
units: [
@@ -75,362 +24,25 @@ const sensenovaChatModels: AIChatModelCard[] = [
{ name: 'textOutput', rate: 0, strategy: 'fixed', unit: 'millionTokens' },
],
},
- releasedAt: '2025-05-27',
+ releasedAt: '2026-05-08',
settings: {
- extendParams: ['enableReasoning'],
- },
- type: 'chat',
- },
- {
- abilities: {
- reasoning: true,
- },
- contextWindowTokens: 32_768,
- description:
- 'Qwen3-32B is a dense model that introduces a hybrid reasoning mode, letting users switch between thinking and non-thinking. With architecture improvements, more data, and better training, it performs on par with Qwen2.5-72B.',
- displayName: 'Qwen3 32B',
- family: 'qwen',
- generation: 'qwen3',
- id: 'Qwen3-32B',
- organization: 'Qwen',
- pricing: {
- currency: 'CNY',
- units: [
- { name: 'textInput', rate: 0, strategy: 'fixed', unit: 'millionTokens' },
- { name: 'textOutput', rate: 0, strategy: 'fixed', unit: 'millionTokens' },
- ],
- },
- releasedAt: '2025-05-27',
- settings: {
- extendParams: ['enableReasoning'],
- },
- type: 'chat',
- },
- {
- abilities: {
- reasoning: true,
- // video: true,
- vision: true,
- },
- contextWindowTokens: 32_768,
- description:
- 'Combines vision and language deep reasoning, supporting slow thinking and full chain-of-thought.',
- displayName: 'SenseNova V6 Reasoner',
- family: 'sensenova',
- id: 'SenseNova-V6-Reasoner',
- pricing: {
- currency: 'CNY',
- units: [
- { name: 'textInput', rate: 4, strategy: 'fixed', unit: 'millionTokens' },
- { name: 'textOutput', rate: 16, strategy: 'fixed', unit: 'millionTokens' },
- ],
- },
- releasedAt: '2025-04-14',
- type: 'chat',
- },
- {
- abilities: {
- // video: true,
- vision: true,
- },
- contextWindowTokens: 32_768,
- description:
- 'Natively unifies image, text, and video, breaking traditional multimodal silos. It leads across core multimodal and language capabilities and ranks top-tier in multiple evaluations.',
- displayName: 'SenseNova V6 Turbo',
- family: 'sensenova',
- id: 'SenseNova-V6-Turbo',
- pricing: {
- currency: 'CNY',
- units: [
- { name: 'textInput', rate: 1.5, strategy: 'fixed', unit: 'millionTokens' },
- { name: 'textOutput', rate: 4.5, strategy: 'fixed', unit: 'millionTokens' },
- ],
- },
- releasedAt: '2025-04-14',
- type: 'chat',
- },
- {
- abilities: {
- // video: true,
- vision: true,
- },
- contextWindowTokens: 32_768,
- description:
- 'Natively unifies image, text, and video, breaking traditional multimodal silos; wins top spots on OpenCompass and SuperCLUE.',
- displayName: 'SenseNova V6 Pro',
- family: 'sensenova',
- id: 'SenseNova-V6-Pro',
- pricing: {
- currency: 'CNY',
- units: [
- { name: 'textInput', rate: 3, strategy: 'fixed', unit: 'millionTokens' },
- { name: 'textOutput', rate: 9, strategy: 'fixed', unit: 'millionTokens' },
- ],
- },
- releasedAt: '2025-04-14',
- type: 'chat',
- },
- {
- contextWindowTokens: 32_768,
- description: 'Some performance exceeds SenseChat-5-1202.',
- displayName: 'SenseChat 5.5 Beta',
- family: 'sensenova',
- id: 'SenseChat-5-beta',
- pricing: {
- currency: 'CNY',
- units: [
- { name: 'textInput', rate: 8, strategy: 'fixed', unit: 'millionTokens' },
- { name: 'textOutput', rate: 20, strategy: 'fixed', unit: 'millionTokens' },
- ],
- },
- type: 'chat',
- },
- {
- abilities: {
- functionCall: true,
- },
- contextWindowTokens: 32_768,
- description:
- 'Latest version based on V5.5, with significant gains in Chinese/English fundamentals, chat, STEM knowledge, humanities knowledge, writing, math/logic, and length control.',
- displayName: 'SenseChat 5.5 1202',
- family: 'sensenova',
- id: 'SenseChat-5-1202',
- pricing: {
- currency: 'CNY',
- units: [
- { name: 'textInput', rate: 8, strategy: 'fixed', unit: 'millionTokens' },
- { name: 'textOutput', rate: 20, strategy: 'fixed', unit: 'millionTokens' },
- ],
- },
- releasedAt: '2024-12-30',
- type: 'chat',
- },
- {
- abilities: {
- functionCall: true,
- },
- contextWindowTokens: 32_768,
- description:
- 'Latest lightweight model reaching 90%+ of full-model capability with significantly lower inference cost.',
- displayName: 'SenseChat Turbo 1202',
- family: 'sensenova',
- id: 'SenseChat-Turbo-1202',
- pricing: {
- currency: 'CNY',
- units: [
- { name: 'textInput', rate: 0.3, strategy: 'fixed', unit: 'millionTokens' },
- { name: 'textOutput', rate: 0.6, strategy: 'fixed', unit: 'millionTokens' },
- ],
- },
- releasedAt: '2024-12-30',
- type: 'chat',
- },
- {
- abilities: {
- functionCall: true,
- },
- contextWindowTokens: 131_072,
- description:
- 'Latest V5.5 with 128K context; major gains in math reasoning, English chat, instruction following, and long-text understanding, comparable to GPT-4o.',
- displayName: 'SenseChat 5.5',
- family: 'sensenova',
- id: 'SenseChat-5',
- maxOutput: 131_072,
- pricing: {
- currency: 'CNY',
- units: [
- { name: 'textInput', rate: 8, strategy: 'fixed', unit: 'millionTokens' },
- { name: 'textOutput', rate: 20, strategy: 'fixed', unit: 'millionTokens' },
- ],
- },
- type: 'chat',
- },
- {
- abilities: {
- vision: true,
- },
- contextWindowTokens: 16_384,
- description:
- 'Latest V5.5 with multi-image input and broad core improvements in attribute recognition, spatial relations, action/event detection, scene understanding, emotion recognition, commonsense reasoning, and text understanding/generation.',
- displayName: 'SenseChat 5.5 Vision',
- family: 'sensenova',
- id: 'SenseChat-Vision',
- maxOutput: 16_384,
- pricing: {
- currency: 'CNY',
- units: [
- { name: 'textInput', rate: 10, strategy: 'fixed', unit: 'millionTokens' },
- { name: 'textOutput', rate: 60, strategy: 'fixed', unit: 'millionTokens' },
- ],
+ extendParams: ['gpt5_1ReasoningEffort'],
},
- releasedAt: '2024-09-12',
type: 'chat',
},
{
abilities: {
functionCall: true,
- },
- contextWindowTokens: 32_768,
- description: 'Suitable for fast Q&A and model fine-tuning scenarios.',
- displayName: 'SenseChat 5.0 Turbo',
- family: 'sensenova',
- id: 'SenseChat-Turbo',
- maxOutput: 32_768,
- pricing: {
- currency: 'CNY',
- units: [
- { name: 'textInput', rate: 0.3, strategy: 'fixed', unit: 'millionTokens' },
- { name: 'textOutput', rate: 0.6, strategy: 'fixed', unit: 'millionTokens' },
- ],
- },
- type: 'chat',
- },
- {
- contextWindowTokens: 131_072,
- description: 'Base V4 with 128K context, strong in long-text understanding and generation.',
- displayName: 'SenseChat 4.0 128K',
- family: 'sensenova',
- id: 'SenseChat-128K',
- maxOutput: 131_072,
- pricing: {
- currency: 'CNY',
- units: [
- { name: 'textInput', rate: 60, strategy: 'fixed', unit: 'millionTokens' },
- { name: 'textOutput', rate: 60, strategy: 'fixed', unit: 'millionTokens' },
- ],
- },
- type: 'chat',
- },
- {
- contextWindowTokens: 32_768,
- description: 'Base V4 with 32K context, flexible for many scenarios.',
- displayName: 'SenseChat 4.0 32K',
- family: 'sensenova',
- id: 'SenseChat-32K',
- maxOutput: 32_768,
- pricing: {
- currency: 'CNY',
- units: [
- { name: 'textInput', rate: 36, strategy: 'fixed', unit: 'millionTokens' },
- { name: 'textOutput', rate: 36, strategy: 'fixed', unit: 'millionTokens' },
- ],
- },
- type: 'chat',
- },
- {
- contextWindowTokens: 4096,
- description: 'Base V4 with 4K context and strong general capability.',
- displayName: 'SenseChat 4.0 4K',
- family: 'sensenova',
- id: 'SenseChat',
- maxOutput: 4096,
- pricing: {
- currency: 'CNY',
- units: [
- { name: 'textInput', rate: 12, strategy: 'fixed', unit: 'millionTokens' },
- { name: 'textOutput', rate: 12, strategy: 'fixed', unit: 'millionTokens' },
- ],
- },
- type: 'chat',
- },
- {
- contextWindowTokens: 32_768,
- description:
- 'Designed for Hong Kong dialogue habits, slang, and local knowledge; surpasses GPT-4 in Cantonese understanding and rivals GPT-4 Turbo in knowledge, reasoning, math, and coding.',
- displayName: 'SenseChat 5.0 Cantonese',
- family: 'sensenova',
- id: 'SenseChat-5-Cantonese',
- maxOutput: 32_768,
- pricing: {
- currency: 'CNY',
- units: [
- { name: 'textInput', rate: 27, strategy: 'fixed', unit: 'millionTokens' },
- { name: 'textOutput', rate: 27, strategy: 'fixed', unit: 'millionTokens' },
- ],
- },
- type: 'chat',
- },
- {
- contextWindowTokens: 8192,
- description: 'Standard character chat model with 8K context and high response speed.',
- displayName: 'SenseChat Character',
- family: 'sensenova',
- id: 'SenseChat-Character',
- maxOutput: 1024,
- pricing: {
- currency: 'CNY',
- units: [
- { name: 'textInput', rate: 12, strategy: 'fixed', unit: 'millionTokens' },
- { name: 'textOutput', rate: 12, strategy: 'fixed', unit: 'millionTokens' },
- ],
- },
- type: 'chat',
- },
- {
- contextWindowTokens: 32_768,
- description:
- 'Advanced character chat model with 32K context, improved capability, and Chinese/English support.',
- displayName: 'SenseChat Character Pro',
- family: 'sensenova',
- id: 'SenseChat-Character-Pro',
- maxOutput: 4096,
- pricing: {
- currency: 'CNY',
- units: [
- { name: 'textInput', rate: 15, strategy: 'fixed', unit: 'millionTokens' },
- { name: 'textOutput', rate: 15, strategy: 'fixed', unit: 'millionTokens' },
- ],
- },
- type: 'chat',
- },
- {
- contextWindowTokens: 32_768,
- description:
- 'DeepSeek-V3 is a MoE model developed by DeepSeek. It surpasses other open models like Qwen2.5-72B and Llama-3.1-405B on many benchmarks and is competitive with leading closed models such as GPT-4o and Claude 3.5 Sonnet.',
- displayName: 'DeepSeek V3',
- family: 'deepseek',
- generation: 'deepseek-v3',
- id: 'DeepSeek-V3',
- pricing: {
- currency: 'CNY',
- units: [
- { name: 'textInput', rate: 2, strategy: 'fixed', unit: 'millionTokens' },
- { name: 'textOutput', rate: 8, strategy: 'fixed', unit: 'millionTokens' },
- ],
- },
- type: 'chat',
- },
- {
- abilities: {
- reasoning: true,
- },
- contextWindowTokens: 32_768,
- description:
- 'DeepSeek-R1 applies large-scale reinforcement learning during post-training, greatly boosting reasoning with very little labeled data. It matches the OpenAI o1 production model on math, code, and natural language reasoning tasks.',
- displayName: 'DeepSeek R1',
- family: 'deepseek',
- generation: 'deepseek-r1',
- id: 'DeepSeek-R1',
- pricing: {
- currency: 'CNY',
- units: [
- { name: 'textInput', rate: 4, strategy: 'fixed', unit: 'millionTokens' },
- { name: 'textOutput', rate: 16, strategy: 'fixed', unit: 'millionTokens' },
- ],
- },
- type: 'chat',
- },
- {
- abilities: {
reasoning: true,
},
- contextWindowTokens: 32_768,
+ contextWindowTokens: 262_144,
description:
- 'DeepSeek-R1-Distill models are fine-tuned from open-source models using sample data generated by DeepSeek-R1.',
- displayName: 'DeepSeek R1 Distill Qwen 14B',
+ 'A high-performance conversational model from DeepSeek, supporting both reasoning and non-reasoning modes, with a 256K-token context window and up to 64K output tokens. Built-in capabilities include JSON Output and Tool Calls.',
+ displayName: 'DeepSeek V4 Flash',
family: 'deepseek',
- generation: 'deepseek-r1-distill',
- id: 'DeepSeek-R1-Distill-Qwen-14B',
+ generation: 'deepseek-v4',
+ id: 'deepseek-v4-flash',
+ maxOutput: 65_536,
pricing: {
currency: 'CNY',
units: [
@@ -438,30 +50,49 @@ const sensenovaChatModels: AIChatModelCard[] = [
{ name: 'textOutput', rate: 0, strategy: 'fixed', unit: 'millionTokens' },
],
},
+ settings: {
+ extendParams: ['gpt5_1ReasoningEffort'],
+ },
type: 'chat',
},
+];
+
+const sensenovaImageModels: AIImageModelCard[] = [
{
- abilities: {
- reasoning: true,
- },
- contextWindowTokens: 8192,
description:
- 'DeepSeek-R1-Distill models are fine-tuned from open-source models using sample data generated by DeepSeek-R1.',
- displayName: 'DeepSeek R1 Distill Qwen 32B',
- family: 'deepseek',
- generation: 'deepseek-r1-distill',
- id: 'DeepSeek-R1-Distill-Qwen-32B',
- pricing: {
- currency: 'CNY',
- units: [
- { name: 'textInput', rate: 0, strategy: 'fixed', unit: 'millionTokens' },
- { name: 'textOutput', rate: 0, strategy: 'fixed', unit: 'millionTokens' },
- ],
- },
- type: 'chat',
+ 'An accelerated version based on SenseNova U1, specifically optimized for infographic generation.',
+ displayName: 'SenseNova U1 Fast',
+ enabled: true,
+ id: 'sensenova-u1-fast',
+ parameters: {
+ prompt: {
+ default: '',
+ },
+ size: {
+ default: '2752x1536',
+ enum: [
+ '1664x2496',
+ '2496x1664',
+ '1760x2368',
+ '2368x1760',
+ '1824x2272',
+ '2272x1824',
+ '2048x2048',
+ '2752x1536',
+ '1536x2752',
+ '3072x1376',
+ '1344x3136',
+ ],
+ },
+ },
+ pricing: {
+ units: [{ name: 'imageGeneration', rate: 0, strategy: 'fixed', unit: 'image' }],
+ },
+ releasedAt: '2026-05-08',
+ type: 'image',
},
];
-export const allModels = [...sensenovaChatModels];
+export const allModels = [...sensenovaChatModels, ...sensenovaImageModels];
export default allModels;
diff --git a/packages/model-bank/src/modelProviders/sensenova.ts b/packages/model-bank/src/modelProviders/sensenova.ts
index 2b914a9d0c2..55f1b4ff949 100644
--- a/packages/model-bank/src/modelProviders/sensenova.ts
+++ b/packages/model-bank/src/modelProviders/sensenova.ts
@@ -1,26 +1,22 @@
import type { ModelProviderCard } from '@/types/llm';
-// ref https://platform.sensenova.cn/pricing
-// ref https://platform.sensenova.cn/release?path=/release-202409.md
const SenseNova: ModelProviderCard = {
chatModels: [],
- checkModel: 'SenseChat-Turbo',
+ checkModel: 'sensenova-6.7-flash-lite',
description:
'SenseNova delivers efficient, easy-to-use full-stack LLM services backed by SenseTime infrastructure.',
- disableBrowserRequest: true,
id: 'sensenova',
- modelList: { showModelFetcher: true },
- modelsUrl: 'https://platform.sensenova.cn/pricing',
+ modelsUrl: 'https://www.sensenova.cn/models',
name: 'SenseNova',
settings: {
- disableBrowserRequest: true,
+ //disableBrowserRequest: true,
proxyUrl: {
- placeholder: 'https://api.sensenova.cn/compatible-mode/v2',
+ placeholder: 'https://token.sensenova.cn/v1',
},
sdkType: 'openai',
showModelFetcher: true,
},
- url: 'https://platform.sensenova.cn/home',
+ url: 'https://platform.sensenova.cn',
};
export default SenseNova;
diff --git a/packages/model-runtime/src/providers/sensenova/index.test.ts b/packages/model-runtime/src/providers/sensenova/index.test.ts
deleted file mode 100644
index 5971b335243..00000000000
--- a/packages/model-runtime/src/providers/sensenova/index.test.ts
+++ /dev/null
@@ -1,758 +0,0 @@
-// @vitest-environment node
-import { ModelProvider } from 'model-bank';
-import { beforeEach, describe, expect, it, vi } from 'vitest';
-
-import { testProvider } from '../../providerTestUtils';
-import { LobeSenseNovaAI, params } from './index';
-
-const provider = ModelProvider.SenseNova;
-const defaultBaseURL = 'https://api.sensenova.cn/compatible-mode/v2';
-
-// Basic provider tests
-testProvider({
- Runtime: LobeSenseNovaAI,
- provider,
- defaultBaseURL,
- chatDebugEnv: 'DEBUG_SENSENOVA_CHAT_COMPLETION',
- chatModel: 'deepseek-r1',
- test: {
- skipAPICall: true,
- },
-});
-
-// Custom feature tests
-describe('LobeSenseNovaAI - custom features', () => {
- let _instance: InstanceType<typeof LobeSenseNovaAI>;
-
- beforeEach(() => {
- _instance = new LobeSenseNovaAI({ apiKey: 'test_api_key' });
- vi.clearAllMocks();
- });
-
- describe('params object', () => {
- it('should export params with correct structure', () => {
- expect(params).toBeDefined();
- expect(params.baseURL).toBe('https://api.sensenova.cn/compatible-mode/v2');
- expect(params.provider).toBe('sensenova');
- expect(params.chatCompletion).toBeDefined();
- expect(params.debug).toBeDefined();
- expect(params.models).toBeDefined();
- });
-
- it('should have handlePayload function in chatCompletion', () => {
- expect(typeof params.chatCompletion.handlePayload).toBe('function');
- });
-
- it('should have chatCompletion debug function', () => {
- expect(typeof params.debug.chatCompletion).toBe('function');
- });
-
- it('should have models function', () => {
- expect(typeof params.models).toBe('function');
- });
- });
-
- describe('Debug Configuration', () => {
- it('should disable debug by default', () => {
- delete process.env.DEBUG_SENSENOVA_CHAT_COMPLETION;
- const result = params.debug.chatCompletion();
- expect(result).toBe(false);
- });
-
- it('should enable debug when env is set to 1', () => {
- process.env.DEBUG_SENSENOVA_CHAT_COMPLETION = '1';
- const result = params.debug.chatCompletion();
- expect(result).toBe(true);
- delete process.env.DEBUG_SENSENOVA_CHAT_COMPLETION;
- });
-
- it('should disable debug when env is set to other values', () => {
- process.env.DEBUG_SENSENOVA_CHAT_COMPLETION = '0';
- const result = params.debug.chatCompletion();
- expect(result).toBe(false);
- delete process.env.DEBUG_SENSENOVA_CHAT_COMPLETION;
- });
- });
-
- describe('handlePayload', () => {
- const createMockPayload = (overrides = {}) => ({
- frequency_penalty: 1.5,
- max_tokens: 100,
- messages: [{ content: 'Hello', role: 'user' }],
- model: 'SenseChat-5',
- temperature: 0.7,
- top_p: 0.9,
- ...overrides,
- });
-
- it('should handle basic payload transformation', () => {
- const payload = createMockPayload();
- const result = params.chatCompletion.handlePayload(payload as any);
-
- expect(result).toMatchObject({
- frequency_penalty: 1.5,
- max_new_tokens: 100,
- messages: [{ content: 'Hello', role: 'user' }],
- model: 'SenseChat-5',
- stream: true,
- temperature: 0.7,
- top_p: 0.9,
- });
- });
-
- describe('frequency_penalty handling', () => {
- it('should keep valid frequency_penalty in range (0, 2]', () => {
- const payload = createMockPayload({ frequency_penalty: 1.5 });
- const result = params.chatCompletion.handlePayload(payload as any);
- expect(result.frequency_penalty).toBe(1.5);
- });
-
- it('should remove frequency_penalty when it is 0', () => {
- const payload = createMockPayload({ frequency_penalty: 0 });
- const result = params.chatCompletion.handlePayload(payload as any);
- expect(result.frequency_penalty).toBeUndefined();
- });
-
- it('should remove frequency_penalty when it is negative', () => {
- const payload = createMockPayload({ frequency_penalty: -0.5 });
- const result = params.chatCompletion.handlePayload(payload as any);
- expect(result.frequency_penalty).toBeUndefined();
- });
-
- it('should remove frequency_penalty when it exceeds 2', () => {
- const payload = createMockPayload({ frequency_penalty: 2.5 });
- const result = params.chatCompletion.handlePayload(payload as any);
- expect(result.frequency_penalty).toBeUndefined();
- });
-
- it('should keep frequency_penalty at boundary value 2', () => {
- const payload = createMockPayload({ frequency_penalty: 2 });
- const result = params.chatCompletion.handlePayload(payload as any);
- expect(result.frequency_penalty).toBe(2);
- });
-
- it('should keep frequency_penalty at minimal valid value', () => {
- const payload = createMockPayload({ frequency_penalty: 0.001 });
- const result = params.chatCompletion.handlePayload(payload as any);
- expect(result.frequency_penalty).toBe(0.001);
- });
-
- it('should remove frequency_penalty when undefined', () => {
- const payload = createMockPayload({ frequency_penalty: undefined });
- const result = params.chatCompletion.handlePayload(payload as any);
- expect(result.frequency_penalty).toBeUndefined();
- });
- });
-
- describe('max_tokens handling', () => {
- it('should convert max_tokens to max_new_tokens', () => {
- const payload = createMockPayload({ max_tokens: 100 });
- const result = params.chatCompletion.handlePayload(payload as any);
- expect(result.max_new_tokens).toBe(100);
- expect(result.max_tokens).toBeUndefined();
- });
-
- it('should remove max_new_tokens when max_tokens is 0', () => {
- const payload = createMockPayload({ max_tokens: 0 });
- const result = params.chatCompletion.handlePayload(payload as any);
- expect(result.max_new_tokens).toBeUndefined();
- });
-
- it('should remove max_new_tokens when max_tokens is negative', () => {
- const payload = createMockPayload({ max_tokens: -10 });
- const result = params.chatCompletion.handlePayload(payload as any);
- expect(result.max_new_tokens).toBeUndefined();
- });
-
- it('should remove max_new_tokens when max_tokens is undefined', () => {
- const payload = createMockPayload({ max_tokens: undefined });
- const result = params.chatCompletion.handlePayload(payload as any);
- expect(result.max_new_tokens).toBeUndefined();
- });
-
- it('should handle large max_tokens values', () => {
- const payload = createMockPayload({ max_tokens: 100000 });
- const result = params.chatCompletion.handlePayload(payload as any);
- expect(result.max_new_tokens).toBe(100000);
- });
- });
-
- describe('temperature handling', () => {
- it('should keep valid temperature in range (0, 2]', () => {
- const payload = createMockPayload({ temperature: 0.7 });
- const result = params.chatCompletion.handlePayload(payload as any);
- expect(result.temperature).toBe(0.7);
- });
-
- it('should remove temperature when it is 0', () => {
- const payload = createMockPayload({ temperature: 0 });
- const result = params.chatCompletion.handlePayload(payload as any);
- expect(result.temperature).toBeUndefined();
- });
-
- it('should remove temperature when it is negative', () => {
- const payload = createMockPayload({ temperature: -0.5 });
- const result = params.chatCompletion.handlePayload(payload as any);
- expect(result.temperature).toBeUndefined();
- });
-
- it('should remove temperature when it exceeds 2', () => {
- const payload = createMockPayload({ temperature: 2.5 });
- const result = params.chatCompletion.handlePayload(payload as any);
- expect(result.temperature).toBeUndefined();
- });
-
- it('should keep temperature at boundary value 2', () => {
- const payload = createMockPayload({ temperature: 2 });
- const result = params.chatCompletion.handlePayload(payload as any);
- expect(result.temperature).toBe(2);
- });
-
- it('should keep temperature at minimal valid value', () => {
- const payload = createMockPayload({ temperature: 0.001 });
- const result = params.chatCompletion.handlePayload(payload as any);
- expect(result.temperature).toBe(0.001);
- });
-
- it('should remove temperature when undefined', () => {
- const payload = createMockPayload({ temperature: undefined });
- const result = params.chatCompletion.handlePayload(payload as any);
- expect(result.temperature).toBeUndefined();
- });
- });
-
- describe('top_p handling', () => {
- it('should keep valid top_p in range (0, 1)', () => {
- const payload = createMockPayload({ top_p: 0.9 });
- const result = params.chatCompletion.handlePayload(payload as any);
- expect(result.top_p).toBe(0.9);
- });
-
- it('should remove top_p when it is 0', () => {
- const payload = createMockPayload({ top_p: 0 });
- const result = params.chatCompletion.handlePayload(payload as any);
- expect(result.top_p).toBeUndefined();
- });
-
- it('should remove top_p when it is 1', () => {
- const payload = createMockPayload({ top_p: 1 });
- const result = params.chatCompletion.handlePayload(payload as any);
- expect(result.top_p).toBeUndefined();
- });
-
- it('should remove top_p when it is negative', () => {
- const payload = createMockPayload({ top_p: -0.5 });
- const result = params.chatCompletion.handlePayload(payload as any);
- expect(result.top_p).toBeUndefined();
- });
-
- it('should remove top_p when it exceeds 1', () => {
- const payload = createMockPayload({ top_p: 1.5 });
- const result = params.chatCompletion.handlePayload(payload as any);
- expect(result.top_p).toBeUndefined();
- });
-
- it('should keep top_p at minimal valid value', () => {
- const payload = createMockPayload({ top_p: 0.001 });
- const result = params.chatCompletion.handlePayload(payload as any);
- expect(result.top_p).toBe(0.001);
- });
-
- it('should keep top_p at maximal valid value', () => {
- const payload = createMockPayload({ top_p: 0.999 });
- const result = params.chatCompletion.handlePayload(payload as any);
- expect(result.top_p).toBe(0.999);
- });
-
- it('should remove top_p when undefined', () => {
- const payload = createMockPayload({ top_p: undefined });
- const result = params.chatCompletion.handlePayload(payload as any);
- expect(result.top_p).toBeUndefined();
- });
- });
-
- describe('thinking parameter handling', () => {
- it('should enable thinking for V6-5 models when type is enabled', () => {
- const payload = createMockPayload({
- model: 'SenseNova-V6-5-Plus',
- thinking: { type: 'enabled' },
- });
- const result = params.chatCompletion.handlePayload(payload as any);
- expect(result.thinking).toEqual({ enabled: true });
- });
-
- it('should disable thinking for V6-5 models when type is not enabled', () => {
- const payload = createMockPayload({
- model: 'SenseNova-V6-5-Plus',
- thinking: { type: 'disabled' },
- });
- const result = params.chatCompletion.handlePayload(payload as any);
- expect(result.thinking).toEqual({ enabled: false });
- });
-
- it('should disable thinking for non-V6-5 models even when type is enabled', () => {
- const payload = createMockPayload({
- model: 'SenseChat-5',
- thinking: { type: 'enabled' },
- });
- const result = params.chatCompletion.handlePayload(payload as any);
- expect(result.thinking).toEqual({ enabled: false });
- });
-
- it('should handle thinking for V6-5 model with case sensitivity', () => {
- const payload = createMockPayload({
- model: 'sensenova-v6-5-plus',
- thinking: { type: 'enabled' },
- });
- const result = params.chatCompletion.handlePayload(payload as any);
- // The code uses includes('-V6-5-') which is case-sensitive, so lowercase v6-5 won't match
- expect(result.thinking).toEqual({ enabled: false });
- });
-
- it('should remove thinking when not provided', () => {
- const payload = createMockPayload({ thinking: undefined });
- const result = params.chatCompletion.handlePayload(payload as any);
- expect(result.thinking).toBeUndefined();
- });
-
- it('should handle thinking for model without -V6-5-', () => {
- const payload = createMockPayload({
- model: 'SenseNova-V6',
- thinking: { type: 'enabled' },
- });
- const result = params.chatCompletion.handlePayload(payload as any);
- expect(result.thinking).toEqual({ enabled: false });
- });
- });
-
- it('should always set stream to true', () => {
- const payload = createMockPayload({ stream: false });
- const result = params.chatCompletion.handlePayload(payload as any);
- expect(result.stream).toBe(true);
- });
-
- it('should preserve other payload properties', () => {
- const payload = createMockPayload({
- custom_property: 'custom_value',
- presence_penalty: 0.5,
- });
- const result = params.chatCompletion.handlePayload(payload as any);
- expect(result.custom_property).toBe('custom_value');
- expect(result.presence_penalty).toBe(0.5);
- });
- });
-
- describe('models function', () => {
- it('should fetch and process model list', async () => {
- const mockClient = {
- apiKey: 'test',
- baseURL: 'https://api.sensenova.cn/compatible-mode/v2',
- models: {
- list: vi.fn().mockResolvedValue({
- data: [
- { id: 'SenseChat-5' },
- { id: 'SenseNova-V6' },
- { id: 'deepseek-r1' },
- { id: 'model-1202' },
- ],
- }),
- },
- };
-
- const models = await params.models({ client: mockClient as any });
-
- expect(mockClient.baseURL).toBe('https://api.sensenova.cn/v1/llm');
- expect(mockClient.models.list).toHaveBeenCalled();
- expect(models).toHaveLength(4);
- });
-
- it('should detect function call capability by keyword 1202', async () => {
- const mockClient = {
- baseURL: 'https://api.sensenova.cn/compatible-mode/v2',
- models: {
- list: vi.fn().mockResolvedValue({
- data: [{ id: 'model-1202' }, { id: 'normal-model' }],
- }),
- },
- };
-
- const models = await params.models({ client: mockClient as any });
- const functionCallModel = models.find((m) => m.id === 'model-1202');
- const normalModel = models.find((m) => m.id === 'normal-model');
-
- expect(functionCallModel?.functionCall).toBe(true);
- expect(normalModel?.functionCall).toBe(false);
- });
-
- it('should detect vision capability by keyword vision', async () => {
- const mockClient = {
- baseURL: 'https://api.sensenova.cn/compatible-mode/v2',
- models: {
- list: vi.fn().mockResolvedValue({
- data: [{ id: 'model-vision' }, { id: 'normal-model' }],
- }),
- },
- };
-
- const models = await params.models({ client: mockClient as any });
- const visionModel = models.find((m) => m.id === 'model-vision');
- const normalModel = models.find((m) => m.id === 'normal-model');
-
- expect(visionModel?.vision).toBe(true);
- expect(normalModel?.vision).toBe(false);
- });
-
- it('should detect vision capability by keyword sensenova-v6', async () => {
- const mockClient = {
- baseURL: 'https://api.sensenova.cn/compatible-mode/v2',
- models: {
- list: vi.fn().mockResolvedValue({
- data: [{ id: 'sensenova-v6' }, { id: 'sensenova-v5' }],
- }),
- },
- };
-
- const models = await params.models({ client: mockClient as any });
- const v6Model = models.find((m) => m.id === 'sensenova-v6');
- const v5Model = models.find((m) => m.id === 'sensenova-v5');
-
- expect(v6Model?.vision).toBe(true);
- expect(v5Model?.vision).toBe(false);
- });
-
- it('should detect reasoning capability by keyword deepseek-r1', async () => {
- const mockClient = {
- baseURL: 'https://api.sensenova.cn/compatible-mode/v2',
- models: {
- list: vi.fn().mockResolvedValue({
- data: [{ id: 'deepseek-r1' }, { id: 'deepseek' }],
- }),
- },
- };
-
- const models = await params.models({ client: mockClient as any });
- const reasoningModel = models.find((m) => m.id === 'deepseek-r1');
- const normalModel = models.find((m) => m.id === 'deepseek');
-
- expect(reasoningModel?.reasoning).toBe(true);
- expect(normalModel?.reasoning).toBe(false);
- });
-
- it('should detect reasoning capability by keyword reasoner', async () => {
- const mockClient = {
- baseURL: 'https://api.sensenova.cn/compatible-mode/v2',
- models: {
- list: vi.fn().mockResolvedValue({
- data: [{ id: 'model-reasoner' }, { id: 'model' }],
- }),
- },
- };
-
- const models = await params.models({ client: mockClient as any });
- const reasonerModel = models.find((m) => m.id === 'model-reasoner');
- const normalModel = models.find((m) => m.id === 'model');
-
- expect(reasonerModel?.reasoning).toBe(true);
- expect(normalModel?.reasoning).toBe(false);
- });
-
- it('should merge with LOBE_DEFAULT_MODEL_LIST when model is known', async () => {
- const mockClient = {
- baseURL: 'https://api.sensenova.cn/compatible-mode/v2',
- models: {
- list: vi.fn().mockResolvedValue({
- data: [{ id: 'SenseChat-5' }],
- }),
- },
- };
-
- const models = await params.models({ client: mockClient as any });
- const model = models[0];
-
- // Should have properties from LOBE_DEFAULT_MODEL_LIST
- expect(model).toHaveProperty('id');
- expect(model).toHaveProperty('enabled');
- });
-
- it('should use default values for unknown models', async () => {
- const mockClient = {
- baseURL: 'https://api.sensenova.cn/compatible-mode/v2',
- models: {
- list: vi.fn().mockResolvedValue({
- data: [{ id: 'unknown-model-xyz' }],
- }),
- },
- };
-
- const models = await params.models({ client: mockClient as any });
- const model = models[0];
-
- expect(model.id).toBe('unknown-model-xyz');
- expect(model.enabled).toBe(false);
- expect(model.contextWindowTokens).toBeUndefined();
- expect(model.displayName).toBeUndefined();
- });
-
- it('should handle case-insensitive model matching', async () => {
- const mockClient = {
- baseURL: 'https://api.sensenova.cn/compatible-mode/v2',
- models: {
- list: vi.fn().mockResolvedValue({
- data: [{ id: 'SENSECHAT-5' }],
- }),
- },
- };
-
- const models = await params.models({ client: mockClient as any });
- expect(models).toHaveLength(1);
- expect(models[0].id).toBe('SENSECHAT-5');
- });
-
- it('should merge abilities from known model', async () => {
- const mockClient = {
- baseURL: 'https://api.sensenova.cn/compatible-mode/v2',
- models: {
- list: vi.fn().mockResolvedValue({
- data: [{ id: 'test-model' }],
- }),
- },
- };
-
- const models = await params.models({ client: mockClient as any });
- const model = models[0];
-
- // Should have all ability flags (even if false)
- expect(model).toHaveProperty('functionCall');
- expect(model).toHaveProperty('vision');
- expect(model).toHaveProperty('reasoning');
- });
-
- it('should handle API errors gracefully', async () => {
- const mockClient = {
- baseURL: 'https://api.sensenova.cn/compatible-mode/v2',
- models: {
- list: vi.fn().mockRejectedValue(new Error('API Error')),
- },
- };
-
- await expect(params.models({ client: mockClient as any })).rejects.toThrow('API Error');
- });
-
- it('should handle empty model list', async () => {
- const mockClient = {
- baseURL: 'https://api.sensenova.cn/compatible-mode/v2',
- models: {
- list: vi.fn().mockResolvedValue({
- data: [],
- }),
- },
- };
-
- const models = await params.models({ client: mockClient as any });
- expect(models).toEqual([]);
- });
-
- it('should change client baseURL to models endpoint', async () => {
- const mockClient = {
- baseURL: 'https://api.sensenova.cn/compatible-mode/v2',
- models: {
- list: vi.fn().mockResolvedValue({
- data: [{ id: 'test-model' }],
- }),
- },
- };
-
- await params.models({ client: mockClient as any });
- expect(mockClient.baseURL).toBe('https://api.sensenova.cn/v1/llm');
- });
-
- it('should detect multiple ability keywords in one model', async () => {
- const mockClient = {
- baseURL: 'https://api.sensenova.cn/compatible-mode/v2',
- models: {
- list: vi.fn().mockResolvedValue({
- data: [{ id: 'model-1202-vision-reasoner' }],
- }),
- },
- };
-
- const models = await params.models({ client: mockClient as any });
- const model = models[0];
-
- expect(model.functionCall).toBe(true); // has 1202
- expect(model.vision).toBe(true); // has vision
- expect(model.reasoning).toBe(true); // has reasoner
- });
-
- it('should prioritize keyword detection over known model abilities', async () => {
- const mockClient = {
- baseURL: 'https://api.sensenova.cn/compatible-mode/v2',
- models: {
- list: vi.fn().mockResolvedValue({
- data: [{ id: 'custom-1202-model' }],
- }),
- },
- };
-
- const models = await params.models({ client: mockClient as any });
- const model = models[0];
-
- // Should detect functionCall from keyword even if not in LOBE_DEFAULT_MODEL_LIST
- expect(model.functionCall).toBe(true);
- });
-
- it('should use OR logic for combining keyword and known model abilities', async () => {
- const mockClient = {
- baseURL: 'https://api.sensenova.cn/compatible-mode/v2',
- models: {
- list: vi.fn().mockResolvedValue({
- data: [
- { id: 'SenseChat-5' }, // Known model, no special keywords
- ],
- }),
- },
- };
-
- const models = await params.models({ client: mockClient as any });
- const model = models[0];
-
- // Should get abilities from LOBE_DEFAULT_MODEL_LIST for known models
- expect(model.id).toBe('SenseChat-5');
- expect(model).toHaveProperty('functionCall');
- expect(model).toHaveProperty('vision');
- expect(model).toHaveProperty('reasoning');
- });
- });
-});
-
-describe('LobeSenseNovaAI - chat integration', () => {
- let instance: InstanceType<typeof LobeSenseNovaAI>;
-
- beforeEach(() => {
- instance = new LobeSenseNovaAI({ apiKey: 'test_api_key' });
- vi.spyOn(instance['client'].chat.completions, 'create').mockResolvedValue(
- new ReadableStream() as any,
- );
- });
-
- describe('chat method payload handling', () => {
- it('should call handlePayload correctly for basic chat', async () => {
- await instance.chat({
- messages: [{ content: 'Hello', role: 'user' }],
- model: 'SenseChat-5',
- temperature: 0.7,
- });
-
- expect(instance['client'].chat.completions.create).toHaveBeenCalledWith(
- expect.objectContaining({
- messages: [{ content: 'Hello', role: 'user' }],
- model: 'SenseChat-5',
- stream: true,
- temperature: 0.7,
- }),
- expect.anything(),
- );
- });
-
- it('should convert vision model messages', async () => {
- await instance.chat({
- messages: [
- {
- content: JSON.stringify([
- { text: 'Describe', type: 'text' },
- {
- image_url: { url: 'https://example.com/image.jpg' },
- type: 'image_url',
- },
- ]),
- role: 'user',
- },
- ],
- model: 'SenseNova-V6',
- temperature: 0.7,
- });
-
- // The payload transformation happens inside handlePayload
- expect(instance['client'].chat.completions.create).toHaveBeenCalled();
- });
-
- it('should handle temperature normalization in chat', async () => {
- await instance.chat({
- messages: [{ content: 'Hello', role: 'user' }],
- model: 'SenseChat-5',
- temperature: 1.5,
- });
-
- expect(instance['client'].chat.completions.create).toHaveBeenCalledWith(
- expect.objectContaining({
- temperature: 1.5,
- }),
- expect.anything(),
- );
- });
-
- it('should handle max_tokens conversion to max_new_tokens', async () => {
- await instance.chat({
- max_tokens: 500,
- messages: [{ content: 'Hello', role: 'user' }],
- model: 'SenseChat-5',
- temperature: 0.7,
- });
-
- expect(instance['client'].chat.completions.create).toHaveBeenCalledWith(
- expect.objectContaining({
- max_new_tokens: 500,
- }),
- expect.anything(),
- );
- });
-
- it('should handle thinking parameter for V6-5 model', async () => {
- await instance.chat({
- messages: [{ content: 'Solve this', role: 'user' }],
- model: 'SenseNova-V6-5-Plus',
- temperature: 0.7,
- thinking: { type: 'enabled' },
- } as any);
-
- expect(instance['client'].chat.completions.create).toHaveBeenCalledWith(
- expect.objectContaining({
- thinking: { enabled: true },
- }),
- expect.anything(),
- );
- });
-
- it('should handle frequency_penalty parameter', async () => {
- await instance.chat({
- frequency_penalty: 1.2,
- messages: [{ content: 'Hello', role: 'user' }],
- model: 'SenseChat-5',
- temperature: 0.7,
- });
-
- expect(instance['client'].chat.completions.create).toHaveBeenCalledWith(
- expect.objectContaining({
- frequency_penalty: 1.2,
- }),
- expect.anything(),
- );
- });
-
- it('should handle top_p parameter', async () => {
- await instance.chat({
- messages: [{ content: 'Hello', role: 'user' }],
- model: 'SenseChat-5',
- temperature: 0.7,
- top_p: 0.95,
- });
-
- expect(instance['client'].chat.completions.create).toHaveBeenCalledWith(
- expect.objectContaining({
- top_p: 0.95,
- }),
- expect.anything(),
- );
- });
- });
-});
diff --git a/packages/model-runtime/src/providers/sensenova/index.ts b/packages/model-runtime/src/providers/sensenova/index.ts
index 2e76171d200..fd6440fd590 100644
--- a/packages/model-runtime/src/providers/sensenova/index.ts
+++ b/packages/model-runtime/src/providers/sensenova/index.ts
@@ -1,19 +1,32 @@
import type { ChatModelCard } from '@lobechat/types';
-import { ModelProvider } from 'model-bank';
+import { LOBE_DEFAULT_MODEL_LIST, ModelProvider } from 'model-bank';
import type { OpenAICompatibleFactoryOptions } from '../../core/openaiCompatibleFactory';
import { createOpenAICompatibleRuntime } from '../../core/openaiCompatibleFactory';
export interface SenseNovaModelCard {
+ context_length: number;
+ created: number;
+ description: string;
id: string;
+ input_modalities: string[];
+ max_output_length: number;
+ name: string;
+ pricing: {
+ prompt: string;
+ completion: string;
+ image: string;
+ request: string;
+ input_cache_read: string;
+ };
+ supported_features: string[];
}
export const params = {
- baseURL: 'https://api.sensenova.cn/compatible-mode/v2',
+ baseURL: 'https://token.sensenova.cn/v1',
chatCompletion: {
handlePayload: (payload) => {
- const { frequency_penalty, max_tokens, model, temperature, thinking, top_p, ...rest } =
- payload;
+ const { frequency_penalty, presence_penalty, temperature, top_p, ...rest } = payload;
return {
...rest,
@@ -21,18 +34,14 @@ export const params = {
frequency_penalty !== undefined && frequency_penalty > 0 && frequency_penalty <= 2
? frequency_penalty
: undefined,
- max_new_tokens: max_tokens !== undefined && max_tokens > 0 ? max_tokens : undefined,
- model,
- stream: true,
+ presence_penalty:
+ presence_penalty !== undefined && presence_penalty > 0 && presence_penalty <= 2
+ ? presence_penalty
+ : undefined,
temperature:
temperature !== undefined && temperature > 0 && temperature <= 2
? temperature
: undefined,
- thinking: thinking
- ? model && model.includes('-V6-5-') && thinking.type === 'enabled'
- ? { enabled: true }
- : { enabled: false }
- : undefined,
top_p: top_p !== undefined && top_p > 0 && top_p < 1 ? top_p : undefined,
} as any;
},
@@ -41,16 +50,6 @@ export const params = {
chatCompletion: () => process.env.DEBUG_SENSENOVA_CHAT_COMPLETION === '1',
},
models: async ({ client }) => {
- const { LOBE_DEFAULT_MODEL_LIST } = await import('model-bank');
-
- const functionCallKeywords = ['1202'];
-
- const visionKeywords = ['vision', 'sensenova-v6'];
-
- const reasoningKeywords = ['deepseek-r1', 'reasoner'];
-
- client.baseURL = 'https://api.sensenova.cn/v1/llm';
-
const modelsPage = (await client.models.list()) as any;
const modelList: SenseNovaModelCard[] = modelsPage.data;
@@ -61,22 +60,50 @@ export const params = {
);
return {
- contextWindowTokens: knownModel?.contextWindowTokens ?? undefined,
- displayName: knownModel?.displayName ?? undefined,
+ contextWindowTokens: model.context_length ?? knownModel?.contextWindowTokens ?? undefined,
+ displayName: model.name ?? knownModel?.displayName ?? undefined,
enabled: knownModel?.enabled || false,
functionCall:
- functionCallKeywords.some((keyword) => model.id.toLowerCase().includes(keyword)) ||
+ model.supported_features?.includes('tools') ||
knownModel?.abilities?.functionCall ||
false,
id: model.id,
+ maxOutput: model.max_output_length ?? knownModel?.maxOutput ?? undefined,
+ pricing: {
+ units: [
+ {
+ name: 'textInput',
+ rate: model.pricing.prompt ? parseFloat(model.pricing.prompt) : 0,
+ strategy: 'fixed',
+ unit: 'millionTokens',
+ },
+ {
+ name: 'textInput_cacheRead',
+ rate: model.pricing.input_cache_read
+ ? parseFloat(model.pricing.input_cache_read)
+ : 0,
+ strategy: 'fixed',
+ unit: 'millionTokens',
+ },
+ {
+ name: 'textOutput',
+ rate: model.pricing.completion ? parseFloat(model.pricing.completion) : 0,
+ strategy: 'fixed',
+ unit: 'millionTokens',
+ },
+ ],
+ },
+ releasedAt: model.created ? new Date(model.created * 1000).toISOString() : undefined,
reasoning:
- reasoningKeywords.some((keyword) => model.id.toLowerCase().includes(keyword)) ||
+ model.supported_features?.includes('reasoning') ||
knownModel?.abilities?.reasoning ||
false,
- vision:
- visionKeywords.some((keyword) => model.id.toLowerCase().includes(keyword)) ||
- knownModel?.abilities?.vision ||
+ structuredOutput:
+ model.supported_features?.includes('json_mode') ||
+ knownModel?.abilities?.structuredOutput ||
false,
+ vision:
+ model.input_modalities?.includes('image') || knownModel?.abilities?.vision || false,
};
})
.filter(Boolean) as ChatModelCard[];