🤯 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.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
🐛 fix: fix some features for Github Copilot (ResponseAPI / Vision, etc) (#13279)
Zhijie Hedc9adf8f10b0
diff --git a/packages/model-bank/src/aiModels/githubCopilot.ts b/packages/model-bank/src/aiModels/githubCopilot.tsindex f0846af6f9a..2f6fbda8eee 100644--- a/packages/model-bank/src/aiModels/githubCopilot.ts+++ b/packages/model-bank/src/aiModels/githubCopilot.ts@@ -5,121 +5,128 @@ const githubCopilotChatModels: AIChatModelCard[] = [{abilities: {functionCall: true,+ reasoning: true,+ structuredOutput: true,vision: true,},- contextWindowTokens: 128_000,- description: 'GPT-5 mini is a compact and efficient model for various tasks.',- displayName: 'GPT-5 mini',+ contextWindowTokens: 400_000,+ description:+ 'GPT-5.4 is the frontier model for complex professional work with highest reasoning capability.',+ displayName: 'GPT-5.4',enabled: true,- id: 'gpt-5-mini',- maxOutput: 16_384,+ id: 'gpt-5.4',+ releasedAt: '2026-03-05',+ settings: {+ extendParams: ['gpt5_2ReasoningEffort', 'textVerbosity'],+ },type: 'chat',},{abilities: {functionCall: true,+ reasoning: true,+ structuredOutput: true,vision: true,},- contextWindowTokens: 128_000,+ contextWindowTokens: 400_000,description:- 'GPT-4o mini is a cost-effective solution for a wide range of text and image tasks.',- displayName: 'GPT-4o mini',+ "GPT-5.4 mini is OpenAI's strongest mini model for coding, computer use, and subagents.",+ displayName: 'GPT-5.4 mini',enabled: true,- id: 'gpt-4o-mini-2024-07-18',- maxOutput: 4096,- type: 'chat',- },- {- abilities: {- functionCall: true,- vision: true,+ id: 'gpt-5.4-mini',+ releasedAt: '2026-03-18',+ settings: {+ extendParams: ['gpt5_2ReasoningEffort', 'textVerbosity'],},- contextWindowTokens: 128_000,- description: 'GPT-4o is the most advanced multimodal model, handling text and image inputs.',- displayName: 'GPT-4o',- enabled: true,- id: 'gpt-4o-2024-11-20',- maxOutput: 16_384,type: 'chat',},{abilities: {functionCall: true,+ reasoning: true,+ structuredOutput: true,vision: true,},- contextWindowTokens: 128_000,- description: 'GPT-4o is the most advanced multimodal model, handling text and image inputs.',- displayName: 'GPT-4o',- enabled: true,- id: 'gpt-4o-2024-08-06',- maxOutput: 16_384,- type: 'chat',- },- {- abilities: {- functionCall: true,- vision: true,+ contextWindowTokens: 400_000,+ description:+ 'GPT-5.3-Codex is the most capable agentic coding model to date, optimized for agentic coding tasks in Codex or similar environments.',+ displayName: 'GPT-5.3 Codex',+ id: 'gpt-5.3-codex',+ releasedAt: '2026-02-05',+ settings: {+ extendParams: ['codexMaxReasoningEffort'],},- contextWindowTokens: 128_000,- description: 'GPT-4o is the most advanced multimodal model, handling text and image inputs.',- displayName: 'GPT-4o',- enabled: true,- id: 'gpt-4o-2024-05-13',- maxOutput: 16_384,type: 'chat',},{abilities: {functionCall: true,+ reasoning: true,+ structuredOutput: true,vision: true,},- contextWindowTokens: 128_000,- description: 'GPT-4o is the most advanced multimodal model, handling text and image inputs.',- displayName: 'GPT-4o',- enabled: true,- id: 'gpt-4-o-preview',- maxOutput: 16_384,+ contextWindowTokens: 192_000,+ description:+ 'GPT-5.2 is a flagship model for coding and agentic workflows with stronger reasoning and long-context performance.',+ displayName: 'GPT-5.2',+ id: 'gpt-5.2',+ releasedAt: '2025-12-11',+ settings: {+ extendParams: ['gpt5_2ReasoningEffort', 'textVerbosity'],+ },type: 'chat',},{abilities: {functionCall: true,+ reasoning: true,+ structuredOutput: true,vision: true,},- contextWindowTokens: 128_000,- description: 'GPT-4o is the most advanced multimodal model, handling text and image inputs.',- displayName: 'GPT-4o',- enabled: true,- id: 'gpt-4o',- maxOutput: 16_384,+ contextWindowTokens: 400_000,+ description:+ 'GPT-5.2-Codex is an upgraded GPT-5.2 variant optimized for long-horizon, agentic coding tasks.',+ displayName: 'GPT-5.2 Codex',+ id: 'gpt-5.2-codex',+ releasedAt: '2025-12-18',+ settings: {+ extendParams: ['codexMaxReasoningEffort'],+ },type: 'chat',},{abilities: {functionCall: true,+ reasoning: true,vision: true,},- contextWindowTokens: 128_000,+ contextWindowTokens: 192_000,description:- 'GPT-4o mini is a cost-effective solution for a wide range of text and image tasks.',- displayName: 'GPT-4o mini',- enabled: true,- id: 'gpt-4o-mini',- maxOutput: 4096,+ 'GPT-5.1 — a flagship model optimized for coding and agent tasks with configurable reasoning effort and longer context.',+ displayName: 'GPT-5.1',+ id: 'gpt-5.1',+ releasedAt: '2025-11-13',+ settings: {+ extendParams: ['gpt5_1ReasoningEffort', 'textVerbosity'],+ },type: 'chat',},{abilities: {functionCall: true,+ reasoning: true,+ structuredOutput: true,vision: true,},- contextWindowTokens: 1_047_576,+ contextWindowTokens: 192_000,description:- 'GPT-4.1 is the flagship model for complex tasks, ideal for cross-domain problem solving.',- displayName: 'GPT-4.1',- enabled: true,- id: 'gpt-4.1-2025-04-14',- maxOutput: 32_768,+ 'A faster, more cost-efficient GPT-5 variant for well-defined tasks, delivering quicker responses while maintaining quality.',+ displayName: 'GPT-5 mini',+ id: 'gpt-5-mini',+ releasedAt: '2025-08-07',+ settings: {+ extendParams: ['gpt5ReasoningEffort', 'textVerbosity'],+ },type: 'chat',},{@@ -127,195 +134,158 @@ const githubCopilotChatModels: AIChatModelCard[] = [functionCall: true,vision: true,},- contextWindowTokens: 1_047_576,+ contextWindowTokens: 128_000,description:- 'GPT-4.1 is the flagship model for complex tasks, ideal for cross-domain problem solving.',+ 'GPT-4.1 is our flagship model for complex tasks and cross-domain problem solving.',displayName: 'GPT-4.1',- enabled: true,id: 'gpt-4.1',- maxOutput: 32_768,+ releasedAt: '2025-04-14',type: 'chat',},++ // Anthropic Models{abilities: {functionCall: true,+ reasoning: true,+ structuredOutput: true,vision: true,},- contextWindowTokens: 16_385,- description: 'GPT 4 Turbo is an enhanced version with improved performance.',- displayName: 'GPT 4 Turbo',+ contextWindowTokens: 139_000,+ description:+ 'Claude Opus 4.6 is Anthropic’s most intelligent model for building agents and coding.',+ displayName: 'Claude Opus 4.6',enabled: true,- id: 'gpt-4-0125-preview',- maxOutput: 4096,- type: 'chat',- },- {- abilities: {- functionCall: true,- vision: true,+ id: 'claude-opus-4.6',+ releasedAt: '2026-02-05',+ settings: {+ extendParams: ['enableAdaptiveThinking', 'effort'],},- contextWindowTokens: 8192,- description: 'GPT 4 is a powerful model for complex reasoning tasks.',- displayName: 'GPT 4',- enabled: true,- id: 'gpt-4-0613',- maxOutput: 4096,type: 'chat',},{abilities: {functionCall: true,+ reasoning: true,+ structuredOutput: true,vision: true,},- contextWindowTokens: 8192,- description: 'GPT 4 is a powerful model for complex reasoning tasks.',- displayName: 'GPT 4',- enabled: true,- id: 'gpt-4',- maxOutput: 4096,- type: 'chat',- },- {- abilities: {- functionCall: true,+ contextWindowTokens: 139_000,+ description:+ 'Claude Opus 4.6 is Anthropic’s most intelligent model for building agents and coding.',+ displayName: 'Claude Opus 4.6 (Fast Mode)',+ id: 'claude-opus-4.6-fast',+ releasedAt: '2026-02-05',+ settings: {+ extendParams: ['enableAdaptiveThinking', 'effort'],},- contextWindowTokens: 4096,- description: 'GPT 3.5 Turbo is a fast and efficient model for various tasks.',- displayName: 'GPT 3.5 Turbo',- enabled: true,- id: 'gpt-3.5-turbo-0613',- maxOutput: 4096,type: 'chat',},{abilities: {functionCall: true,- },- contextWindowTokens: 4096,- description: 'GPT 3.5 Turbo is a fast and efficient model for various tasks.',- displayName: 'GPT 3.5 Turbo',- enabled: true,- id: 'gpt-3.5-turbo',- maxOutput: 4096,- type: 'chat',- },- {- abilities: {reasoning: true,+ structuredOutput: true,vision: true,},- contextWindowTokens: 200_000,- description: 'o1 is OpenAI reasoning model for complex tasks requiring broad knowledge.',- displayName: 'o1',- id: 'o1',- maxOutput: 100_000,+ contextWindowTokens: 139_000,+ description: 'Claude Sonnet 4.6 is Anthropic’s best combination of speed and intelligence.',+ displayName: 'Claude Sonnet 4.6',+ enabled: true,+ id: 'claude-sonnet-4.6',+ releasedAt: '2026-02-17',+ settings: {+ extendParams: ['enableAdaptiveThinking', 'enableReasoning', 'reasoningBudgetToken', 'effort'],+ },type: 'chat',},{abilities: {functionCall: true,reasoning: true,+ structuredOutput: true,+ vision: true,},- contextWindowTokens: 200_000,+ contextWindowTokens: 139_000,description:- 'o3-mini is the newest small reasoning model, delivering high intelligence at low cost.',- displayName: 'o3-mini',- id: 'o3-mini',- maxOutput: 100_000,+ 'Claude Opus 4.5 is Anthropic’s flagship model, combining top-tier intelligence with scalable performance for complex, high-quality reasoning tasks.',+ displayName: 'Claude Opus 4.5',+ id: 'claude-opus-4.5',+ releasedAt: '2025-11-24',+ settings: {+ extendParams: ['enableReasoning', 'reasoningBudgetToken'],+ },type: 'chat',},{abilities: {functionCall: true,reasoning: true,+ structuredOutput: true,vision: true,},- contextWindowTokens: 128_000,- description:- 'o4-mini is the latest small o-series model, optimized for fast, efficient reasoning.',- displayName: 'o4-mini',- enabled: true,- id: 'o4-mini',- maxOutput: 16_384,- type: 'chat',- },-- // Grok Models- {- abilities: {- functionCall: true,+ contextWindowTokens: 139_000,+ description: 'Claude Sonnet 4.5 is Anthropic’s most intelligent model to date.',+ displayName: 'Claude Sonnet 4.5',+ id: 'claude-sonnet-4.5',+ releasedAt: '2025-09-29',+ settings: {+ extendParams: ['enableReasoning', 'reasoningBudgetToken'],},- contextWindowTokens: 128_000,- description: 'Grok Code Fast 1 is optimized for fast code generation and understanding.',- displayName: 'Grok Code Fast 1',- enabled: true,- id: 'grok-code-fast-1',- maxOutput: 8192,- type: 'chat',- },-- // Embedding Models (marked as chat in API)- {- contextWindowTokens: 8192,- description: 'Embedding V3 small model for text embeddings.',- displayName: 'Embedding V3 small',- enabled: true,- id: 'text-embedding-3-small',- type: 'chat',- },- {- contextWindowTokens: 8192,- description: 'Embedding V3 small (Inference) model for text embeddings.',- displayName: 'Embedding V3 small (Inference)',- enabled: true,- id: 'text-embedding-3-small-inference',- type: 'chat',- },- {- contextWindowTokens: 8192,- description: 'Embedding V2 Ada model for text embeddings.',- displayName: 'Embedding V2 Ada',- enabled: true,- id: 'text-embedding-ada-002',type: 'chat',},-- // Anthropic Models{abilities: {functionCall: true,+ reasoning: true,+ structuredOutput: true,vision: true,},- contextWindowTokens: 200_000,- description: 'Claude Haiku 4.5 is a fast and efficient model for various tasks.',+ contextWindowTokens: 139_000,+ description:+ 'Claude Haiku 4.5 is Anthropic’s fastest and smartest Haiku model, with lightning speed and extended reasoning.',displayName: 'Claude Haiku 4.5',enabled: true,id: 'claude-haiku-4.5',- maxOutput: 8192,+ releasedAt: '2025-10-16',+ settings: {+ extendParams: ['enableReasoning', 'reasoningBudgetToken'],+ },type: 'chat',},{abilities: {functionCall: true,+ reasoning: true,vision: true,},- contextWindowTokens: 90_000,- description: 'Claude 3.5 Sonnet excels at coding, writing, and complex reasoning.',- displayName: 'Claude 3.5 Sonnet',- id: 'claude-3.5-sonnet',- maxOutput: 8192,+ contextWindowTokens: 139_000,+ description:+ 'Claude Sonnet 4 can produce near-instant responses or extended step-by-step reasoning that users can see. API users can finely control how long the model thinks.',+ displayName: 'Claude Sonnet 4',+ id: 'claude-sonnet-4',+ releasedAt: '2025-05-23',+ settings: {+ extendParams: ['enableReasoning', 'reasoningBudgetToken'],+ },type: 'chat',},++ // Google Models{abilities: {functionCall: true,+ reasoning: true,+ structuredOutput: true,vision: true,},- contextWindowTokens: 200_000,- description: 'Claude 3.7 Sonnet is an upgraded version with extended context and capabilities.',- displayName: 'Claude 3.7 Sonnet',- id: 'claude-3.7-sonnet',- maxOutput: 16_384,+ contextWindowTokens: 173_000,+ description:+ 'Gemini 3.1 Pro Preview improves on Gemini 3 Pro with enhanced reasoning capabilities and adds medium thinking level support.',+ displayName: 'Gemini 3.1 Pro Preview',+ enabled: true,+ id: 'gemini-3.1-pro-preview',+ releasedAt: '2026-02-19',type: 'chat',},{@@ -324,79 +294,78 @@ const githubCopilotChatModels: AIChatModelCard[] = [reasoning: true,vision: true,},- contextWindowTokens: 200_000,- description: 'Claude 3.7 Sonnet with extended thinking for complex reasoning tasks.',- displayName: 'Claude 3.7 Sonnet (Thinking)',- id: 'claude-3.7-sonnet-thought',- maxOutput: 16_384,+ contextWindowTokens: 173_000,+ description:+ 'Gemini 3 Flash is the smartest model built for speed, combining cutting-edge intelligence with excellent search grounding.',+ displayName: 'Gemini 3 Flash Preview',+ id: 'gemini-3-flash-preview',+ releasedAt: '2025-12-17',type: 'chat',},{abilities: {functionCall: true,+ reasoning: true,vision: true,},- contextWindowTokens: 200_000,+ contextWindowTokens: 173_000,description:- 'Claude Sonnet 4 is the latest generation with improved performance across all tasks.',- displayName: 'Claude Sonnet 4',- enabled: true,- id: 'claude-sonnet-4',- maxOutput: 16_000,+ 'Gemini 2.5 Pro is Google’s most advanced reasoning model, able to reason over code, math, and STEM problems and analyze large datasets, codebases, and documents with long context.',+ displayName: 'Gemini 2.5 Pro',+ id: 'gemini-2.5-pro',+ releasedAt: '2025-06-17',type: 'chat',},- // Raptor Models- {- abilities: {- functionCall: true,- },- contextWindowTokens: 128_000,- description: 'Raptor mini is a preview model optimized for code-related tasks.',- displayName: 'Raptor mini (Preview)',- enabled: true,- id: 'oswe-vscode-prime',- maxOutput: 8192,- type: 'chat',- },+ // Grok Models{abilities: {functionCall: true,+ reasoning: true,+ structuredOutput: true,},- contextWindowTokens: 128_000,- description: 'Raptor mini is a preview model optimized for code-related tasks.',- displayName: 'Raptor mini (Preview)',+ contextWindowTokens: 173_000,+ description:+ 'We’re excited to launch grok-code-fast-1, a fast and cost-effective reasoning model that excels at agentic coding.',+ displayName: 'Grok Code Fast 1',enabled: true,- id: 'oswe-vscode-secondary',- maxOutput: 8192,+ id: 'grok-code-fast-1',+ releasedAt: '2025-08-27',type: 'chat',},- // Google Models+ // Raptor Models{abilities: {functionCall: true,+ reasoning: true,+ structuredOutput: true,vision: true,},- contextWindowTokens: 1_000_000,- description: 'Gemini 2.0 Flash delivers fast, efficient multimodal understanding.',- displayName: 'Gemini 2.0 Flash',+ contextWindowTokens: 264_000,+ description: 'Raptor mini is a preview model optimized for code-related tasks.',+ displayName: 'Raptor mini',enabled: true,- id: 'gemini-2.0-flash-001',- maxOutput: 8192,+ id: 'oswe-vscode-prime',+ settings: {+ extendParams: ['gpt5ReasoningEffort', 'textVerbosity'],+ },type: 'chat',},{abilities: {functionCall: true,reasoning: true,+ structuredOutput: true,vision: true,},- contextWindowTokens: 1_000_000,- description: 'Gemini 2.5 Pro is the most capable Gemini model with advanced reasoning.',- displayName: 'Gemini 2.5 Pro',- id: 'gemini-2.5-pro',- maxOutput: 64_000,+ contextWindowTokens: 264_000,+ description: 'Raptor mini is a preview model optimized for code-related tasks.',+ displayName: 'Raptor mini (Secondary)',+ id: 'oswe-vscode-secondary',+ settings: {+ extendParams: ['gpt5ReasoningEffort', 'textVerbosity'],+ },type: 'chat',},];diff --git a/packages/model-bank/src/modelProviders/githubCopilot.ts b/packages/model-bank/src/modelProviders/githubCopilot.tsindex 05f6ade2567..a8fd06d34c7 100644--- a/packages/model-bank/src/modelProviders/githubCopilot.ts+++ b/packages/model-bank/src/modelProviders/githubCopilot.ts@@ -2,7 +2,7 @@ import type { ModelProviderCard } from '@/types/llm';const GithubCopilot: ModelProviderCard = {chatModels: [],- checkModel: 'gpt-4o',+ checkModel: 'gpt-5-mini',description: 'Access Claude, GPT, and Gemini models through your GitHub Copilot subscription.',id: 'githubcopilot',name: 'GitHub Copilot',@@ -19,6 +19,7 @@ const GithubCopilot: ModelProviderCard = {sdkType: 'openai',showApiKey: false,showChecker: true,+ supportResponsesApi: true,},url: 'https://github.com/features/copilot',};diff --git a/packages/model-runtime/src/core/streams/openai/openai.test.ts b/packages/model-runtime/src/core/streams/openai/openai.test.tsindex b64e72bd90f..b1bb2085264 100644--- a/packages/model-runtime/src/core/streams/openai/openai.test.ts+++ b/packages/model-runtime/src/core/streams/openai/openai.test.ts@@ -1373,6 +1373,68 @@ describe('OpenAIStream', () => {});describe('Reasoning', () => {+ it('should handle GitHub Copilot reasoning_text in delta chunks', async () => {+ const data = [+ {+ id: 'reasoning-text-1',+ object: 'chat.completion.chunk',+ created: 1774512975,+ model: 'gemini-3.1-pro-preview',+ choices: [+ {+ index: 0,+ delta: {+ content: null,+ role: 'assistant',+ reasoning_text: '这是 reasoning_text 内容',+ },+ finish_reason: null,+ },+ ],+ },+ {+ id: 'reasoning-text-1',+ object: 'chat.completion.chunk',+ created: 1774512976,+ model: 'gemini-3.1-pro-preview',+ choices: [+ {+ index: 0,+ delta: {},+ finish_reason: 'stop',+ },+ ],+ },+ ];++ const mockOpenAIStream = new ReadableStream({+ start(controller) {+ data.forEach((chunk) => controller.enqueue(chunk));+ controller.close();+ },+ });++ const protocolStream = OpenAIStream(mockOpenAIStream);+ const decoder = new TextDecoder();+ const chunks: string[] = [];++ // @ts-ignore+ for await (const chunk of protocolStream) {+ chunks.push(decoder.decode(chunk, { stream: true }));+ }++ expect(chunks).toEqual(+ [+ 'id: reasoning-text-1',+ 'event: reasoning',+ `data: "这是 reasoning_text 内容"\n`,+ 'id: reasoning-text-1',+ 'event: stop',+ `data: "stop"\n`,+ ].map((i) => `${i}\n`),+ );+ });+it('should handle <think></think> tags in streaming content', async () => {const data = [{diff --git a/packages/model-runtime/src/core/streams/openai/openai.ts b/packages/model-runtime/src/core/streams/openai/openai.tsindex 0d77a9e3524..b4477e4871c 100644--- a/packages/model-runtime/src/core/streams/openai/openai.ts+++ b/packages/model-runtime/src/core/streams/openai/openai.ts@@ -397,6 +397,8 @@ const transformOpenAIStream = (if (item.delta) {let reasoning_content = (() => {if ('reasoning_content' in item.delta) return item.delta.reasoning_content;+ // Handle Github Copilot's reasoning format+ if ('reasoning_text' in item.delta) return (item.delta as any).reasoning_text;if ('reasoning' in item.delta) return item.delta.reasoning;// Handle MiniMax M2 reasoning_details format (array of objects with text field)if ('reasoning_details' in item.delta) {diff --git a/packages/model-runtime/src/providers/githubCopilot/index.test.ts b/packages/model-runtime/src/providers/githubCopilot/index.test.tsindex 701404d4ee8..b47890a977a 100644--- a/packages/model-runtime/src/providers/githubCopilot/index.test.ts+++ b/packages/model-runtime/src/providers/githubCopilot/index.test.ts@@ -1,6 +1,8 @@// @vitest-environment nodeimport { afterEach, describe, expect, it, vi } from 'vitest';+import { responsesAPIModels } from '../../const/models';+import * as openAIContextBuilders from '../../core/contextBuilders/openai';import { LobeGithubCopilotAI } from './index';// Mock console.error to avoid polluting test output@@ -13,9 +15,61 @@ global.fetch = mockFetch;describe('LobeGithubCopilotAI', () => {afterEach(() => {vi.clearAllMocks();+ vi.restoreAllMocks();mockFetch.mockReset();});+ describe('image payload conversion', () => {+ it('should force image base64 conversion in responses mode', async () => {+ const convertResponseInputsSpy = vi+ .spyOn(openAIContextBuilders, 'convertOpenAIResponseInputs')+ .mockRejectedValue({ status: 400 });++ const futureTime = Date.now() + 600_000;+ const instance = new LobeGithubCopilotAI({+ bearerToken: 'cached-bearer-token',+ bearerTokenExpiresAt: futureTime,+ oauthAccessToken: 'ghu_oauth',+ });++ await expect(+ instance.chat({+ messages: [{ content: 'hello', role: 'user' }],+ model: 'gpt-5.1-codex-mini',+ } as any),+ ).rejects.toBeDefined();++ expect(convertResponseInputsSpy).toHaveBeenCalledWith(expect.any(Array), {+ forceImageBase64: true,+ strictToolPairing: true,+ });+ });++ it('should force image base64 conversion in chat completions mode', async () => {+ const convertMessagesSpy = vi+ .spyOn(openAIContextBuilders, 'convertOpenAIMessages')+ .mockRejectedValue({ status: 400 });++ const futureTime = Date.now() + 600_000;+ const instance = new LobeGithubCopilotAI({+ bearerToken: 'cached-bearer-token',+ bearerTokenExpiresAt: futureTime,+ oauthAccessToken: 'ghu_oauth',+ });++ await expect(+ instance.chat({+ messages: [{ content: 'hello', role: 'user' }],+ model: 'gpt-4o',+ } as any),+ ).rejects.toBeDefined();++ expect(convertMessagesSpy).toHaveBeenCalledWith(expect.any(Array), {+ forceImageBase64: true,+ });+ });+ });+describe('constructor', () => {it('should throw error if no token is provided', () => {expect(() => new LobeGithubCopilotAI({})).toThrow();@@ -185,4 +239,303 @@ describe('LobeGithubCopilotAI', () => {expect(instance.baseURL).toBe('https://api.githubcopilot.com');});});++ describe('responses api routing helpers', () => {+ it('should contain codex mini model in responses api model list', () => {+ expect(responsesAPIModels.has('gpt-5.1-codex-mini')).toBe(true);+ });++ it('should not treat gpt-4o as responses-only model', () => {+ expect(responsesAPIModels.has('gpt-4o')).toBe(false);+ });++ it('should convert chat completion tool to responses tool', () => {+ const instance = new LobeGithubCopilotAI({ apiKey: 'ghp_test' });+ const chatTool = {+ function: {+ description: 'Get weather',+ name: 'get_weather',+ parameters: {+ properties: {+ city: { type: 'string' },+ },+ type: 'object',+ },+ },+ type: 'function',+ };++ const responseTool = (instance as any).convertChatCompletionToolToResponseTool(chatTool);++ expect(responseTool).toEqual({+ description: 'Get weather',+ name: 'get_weather',+ parameters: {+ properties: {+ city: { type: 'string' },+ },+ type: 'object',+ },+ type: 'function',+ });+ });++ it('should map verbosity to responses text.verbosity', async () => {+ vi.resetModules();++ const responsesCreateMock = vi.fn().mockRejectedValue({ status: 500 });++ vi.doMock('openai', () => {+ return {+ default: class MockOpenAI {+ responses = {+ create: responsesCreateMock,+ };+ },+ };+ });++ const { LobeGithubCopilotAI: ReloadedLobeGithubCopilotAI } = await import('./index');++ const futureTime = Date.now() + 600_000;+ const instance = new ReloadedLobeGithubCopilotAI({+ bearerToken: 'cached-bearer-token',+ bearerTokenExpiresAt: futureTime,+ oauthAccessToken: 'ghu_oauth',+ });++ await expect(+ instance.chat({+ messages: [{ content: 'hello', role: 'user' }],+ model: 'gpt-5.1-codex-mini',+ verbosity: 'high',+ } as any),+ ).rejects.toBeDefined();++ expect(responsesCreateMock).toHaveBeenCalledTimes(1);++ const payload = responsesCreateMock.mock.calls[0][0];+ expect(payload.text).toEqual({ verbosity: 'high' });+ expect(payload.verbosity).toBeUndefined();++ vi.doUnmock('openai');+ });+ });++ describe('debug env flags', () => {+ it('should enable chat completion request debug with DEBUG_GITHUBCOPILOT_CHAT_COMPLETION', async () => {+ vi.resetModules();++ const chatCompletionCreateMock = vi.fn().mockRejectedValue({ status: 500 });++ vi.doMock('openai', () => {+ return {+ default: class MockOpenAI {+ chat = {+ completions: {+ create: chatCompletionCreateMock,+ },+ };++ responses = {+ create: vi.fn(),+ };+ },+ };+ });++ process.env.DEBUG_GITHUBCOPILOT_CHAT_COMPLETION = '1';+ const logSpy = vi.spyOn(console, 'log').mockImplementation(() => {});++ const { LobeGithubCopilotAI: ReloadedLobeGithubCopilotAI } = await import('./index');++ const futureTime = Date.now() + 600_000;+ const instance = new ReloadedLobeGithubCopilotAI({+ bearerToken: 'cached-bearer-token',+ bearerTokenExpiresAt: futureTime,+ oauthAccessToken: 'ghu_oauth',+ });++ await expect(+ instance.chat({+ messages: [{ content: 'hello', role: 'user' }],+ model: 'gpt-4o',+ } as any),+ ).rejects.toBeDefined();++ expect(chatCompletionCreateMock).toHaveBeenCalledTimes(1);+ expect(logSpy).toHaveBeenCalledWith('[requestPayload]');++ delete process.env.DEBUG_GITHUBCOPILOT_CHAT_COMPLETION;+ vi.doUnmock('openai');+ });++ it('should enable responses request debug with DEBUG_GITHUBCOPILOT_RESPONSES', async () => {+ vi.resetModules();++ const responsesCreateMock = vi.fn().mockRejectedValue({ status: 500 });++ vi.doMock('openai', () => {+ return {+ default: class MockOpenAI {+ chat = {+ completions: {+ create: vi.fn(),+ },+ };++ responses = {+ create: responsesCreateMock,+ };+ },+ };+ });++ process.env.DEBUG_GITHUBCOPILOT_RESPONSES = '1';+ const logSpy = vi.spyOn(console, 'log').mockImplementation(() => {});++ const { LobeGithubCopilotAI: ReloadedLobeGithubCopilotAI } = await import('./index');++ const futureTime = Date.now() + 600_000;+ const instance = new ReloadedLobeGithubCopilotAI({+ bearerToken: 'cached-bearer-token',+ bearerTokenExpiresAt: futureTime,+ oauthAccessToken: 'ghu_oauth',+ });++ await expect(+ instance.chat({+ messages: [{ content: 'hello', role: 'user' }],+ model: 'gpt-5.1-codex-mini',+ } as any),+ ).rejects.toBeDefined();++ expect(responsesCreateMock).toHaveBeenCalledTimes(1);+ expect(logSpy).toHaveBeenCalledWith('[requestPayload]');++ delete process.env.DEBUG_GITHUBCOPILOT_RESPONSES;+ vi.doUnmock('openai');+ });+ });++ describe('anthropic mode for claude models', () => {+ it('should route claude models to anthropic messages API', async () => {+ vi.resetModules();++ const openAIChatCreateMock = vi.fn().mockRejectedValue({ status: 500 });+ const openAIResponsesCreateMock = vi.fn().mockRejectedValue({ status: 500 });+ const anthropicMessagesCreateMock = vi.fn().mockRejectedValue({ status: 500 });+ const anthropicCtorSpy = vi.fn();++ vi.doMock('openai', () => {+ return {+ default: class MockOpenAI {+ chat = {+ completions: {+ create: openAIChatCreateMock,+ },+ };++ responses = {+ create: openAIResponsesCreateMock,+ };+ },+ };+ });++ vi.doMock('@anthropic-ai/sdk', () => {+ return {+ default: class MockAnthropic {+ messages = {+ create: anthropicMessagesCreateMock,+ };++ constructor(options: any) {+ anthropicCtorSpy(options);+ }+ },+ };+ });++ const { LobeGithubCopilotAI: ReloadedLobeGithubCopilotAI } = await import('./index');++ const futureTime = Date.now() + 600_000;+ const instance = new ReloadedLobeGithubCopilotAI({+ bearerToken: 'cached-bearer-token',+ bearerTokenExpiresAt: futureTime,+ oauthAccessToken: 'ghu_oauth',+ });++ await expect(+ instance.chat({+ messages: [{ content: 'hello', role: 'user' }],+ model: 'claude-3.7-sonnet',+ } as any),+ ).rejects.toBeDefined();++ expect(anthropicMessagesCreateMock).toHaveBeenCalledTimes(1);+ expect(openAIChatCreateMock).not.toHaveBeenCalled();+ expect(openAIResponsesCreateMock).not.toHaveBeenCalled();++ expect(anthropicCtorSpy).toHaveBeenCalledWith(+ expect.objectContaining({+ baseURL: 'https://api.githubcopilot.com',+ defaultHeaders: expect.objectContaining({+ 'Authorization': 'Bearer cached-bearer-token',+ 'Copilot-Integration-Id': 'vscode-chat',+ 'anthropic-version': '2023-06-01',+ }),+ }),+ );++ vi.doUnmock('openai');+ vi.doUnmock('@anthropic-ai/sdk');+ });++ it('should preserve explicit thinking and effort for claude models', async () => {+ vi.resetModules();++ const anthropicMessagesCreateMock = vi.fn().mockRejectedValue({ status: 500 });++ vi.doMock('@anthropic-ai/sdk', () => {+ return {+ default: class MockAnthropic {+ messages = {+ create: anthropicMessagesCreateMock,+ };+ },+ };+ });++ const { LobeGithubCopilotAI: ReloadedLobeGithubCopilotAI } = await import('./index');++ const futureTime = Date.now() + 600_000;+ const instance = new ReloadedLobeGithubCopilotAI({+ bearerToken: 'cached-bearer-token',+ bearerTokenExpiresAt: futureTime,+ oauthAccessToken: 'ghu_oauth',+ });++ await expect(+ instance.chat({+ effort: 'high',+ messages: [{ content: 'hello', role: 'user' }],+ model: 'claude-3.7-sonnet',+ thinking: { budget_tokens: 2048, type: 'enabled' },+ } as any),+ ).rejects.toBeDefined();++ const payload = anthropicMessagesCreateMock.mock.calls[0][0];++ expect(payload.output_config).toEqual({ effort: 'high' });+ expect(payload.thinking).toEqual(+ expect.objectContaining({+ budget_tokens: 2048,+ type: 'enabled',+ }),+ );++ vi.doUnmock('@anthropic-ai/sdk');+ });+ });});diff --git a/packages/model-runtime/src/providers/githubCopilot/index.ts b/packages/model-runtime/src/providers/githubCopilot/index.tsindex 6c344597276..d215eb55e03 100644--- a/packages/model-runtime/src/providers/githubCopilot/index.ts+++ b/packages/model-runtime/src/providers/githubCopilot/index.ts@@ -1,13 +1,23 @@+import Anthropic from '@anthropic-ai/sdk';import { type ChatModelCard } from '@lobechat/types';import { ModelProvider } from 'model-bank';import OpenAI from 'openai';+import { responsesAPIModels } from '../../const/models';+import { buildDefaultAnthropicPayload } from '../../core/anthropicCompatibleFactory';import { type LobeRuntimeAI } from '../../core/BaseAI';-import { pruneReasoningPayload } from '../../core/contextBuilders/openai';-import { OpenAIStream } from '../../core/streams';+import {+ convertOpenAIMessages,+ convertOpenAIResponseInputs,+ pruneReasoningPayload,+} from '../../core/contextBuilders/openai';+import { transformResponseAPIToStream } from '../../core/openaiCompatibleFactory';+import { AnthropicStream, OpenAIResponsesStream, OpenAIStream } from '../../core/streams';import { type ChatMethodOptions, type ChatStreamPayload } from '../../types';import { AgentRuntimeErrorType } from '../../types/error';import { AgentRuntimeError } from '../../utils/createError';+import { debugResponse, debugStream } from '../../utils/debugStream';+import { getModelPricing } from '../../utils/getModelPricing';import { StreamingResponse } from '../../utils/response';const COPILOT_BASE_URL = 'https://api.githubcopilot.com';@@ -16,6 +26,11 @@ const TOKEN_EXCHANGE_URL = 'https://api.github.com/copilot_internal/v2/token';const MAX_TOTAL_ATTEMPTS = 5;const MAX_RATE_LIMIT_RETRIES = 3;+const debugParams = {+ chatCompletion: () => process.env.DEBUG_GITHUBCOPILOT_CHAT_COMPLETION === '1',+ responses: () => process.env.DEBUG_GITHUBCOPILOT_RESPONSES === '1',+};+interface CachedToken {expiresAt: number;token: string;@@ -151,9 +166,78 @@ export class LobeGithubCopilotAI implements LobeRuntimeAI {async chat(payload: ChatStreamPayload, options?: ChatMethodOptions) {return this.executeWithRetry(async () => {+ const inputStartAt = Date.now();+// Use cached bearer token if available, otherwise exchangeconst bearerToken = this.cachedBearerToken || (await tokenManager.getToken(this.githubToken));+ const { model, ...rest } = this.handlePayload(payload);+ const shouldStream = rest.stream !== false;++ if (model.toLowerCase().includes('claude')) {+ const anthropicClient = new Anthropic({+ apiKey: bearerToken,+ baseURL: this.baseURL,+ defaultHeaders: {+ 'Authorization': `Bearer ${bearerToken}`,+ 'Copilot-Integration-Id': 'vscode-chat',+ 'Editor-Plugin-Version': 'LobeChat/1.0',+ 'Editor-Version': 'LobeChat/1.0',+ 'anthropic-version': '2023-06-01',+ },+ });++ const anthropicPayload = await buildDefaultAnthropicPayload({+ ...(rest as ChatStreamPayload),+ model,+ });++ const finalPayload = { ...anthropicPayload, stream: shouldStream };++ if (debugParams.chatCompletion()) {+ // eslint-disable-next-line no-console+ console.log('[requestPayload]');+ // eslint-disable-next-line no-console+ console.log(JSON.stringify(finalPayload), '\n');+ }++ const response = await anthropicClient.messages.create(+ {+ ...finalPayload,+ metadata: options?.user ? { user_id: options.user } : undefined,+ },+ {+ headers: options?.requestHeaders,+ signal: options?.signal,+ },+ );++ const pricing = await getModelPricing(model, ModelProvider.GithubCopilot);++ const streamResponse = response as any;+ const [prod, useForDebug] = streamResponse.tee();++ if (debugParams.chatCompletion()) {+ const useForDebugStream =+ useForDebug instanceof ReadableStream ? useForDebug : useForDebug.toReadableStream();++ debugStream(useForDebugStream).catch(console.error);+ }++ return StreamingResponse(+ AnthropicStream(prod, {+ callbacks: options?.callback,+ inputStartAt,+ payload: {+ model,+ pricing,+ provider: ModelProvider.GithubCopilot,+ },+ }),+ { headers: options?.headers },+ );+ }+const client = new OpenAI({apiKey: bearerToken,baseURL: COPILOT_BASE_URL,@@ -164,13 +248,132 @@ export class LobeGithubCopilotAI implements LobeRuntimeAI {},});- const { model, ...rest } = this.handlePayload(payload);- const shouldStream = rest.stream !== false;+ if (+ responsesAPIModels.has(model) ||+ model.toLowerCase().includes('oswe') ||+ (payload as any).apiMode === 'responses'+ ) {+ const {+ messages,+ reasoning_effort,+ tools,+ reasoning,+ max_tokens,+ verbosity,+ ...responseRest+ } = rest as any;++ delete responseRest.apiMode;+ delete responseRest.frequency_penalty;+ delete responseRest.presence_penalty;++ const input = await convertOpenAIResponseInputs(messages as any, {+ forceImageBase64: true,+ strictToolPairing: true,+ });- const response = await client.chat.completions.create(- { ...rest, model, stream: shouldStream } as OpenAI.ChatCompletionCreateParamsStreaming,- { signal: options?.signal },- );+ const responseTools = tools?.map(this.convertChatCompletionToolToResponseTool);+ const responsePayload = {+ ...responseRest,+ ...(reasoning || reasoning_effort+ ? {+ reasoning: {+ ...reasoning,+ ...(reasoning_effort && { effort: reasoning_effort }),+ summary: 'detailed',+ },+ }+ : {}),+ ...(max_tokens && { max_output_tokens: max_tokens }),+ text: verbosity ? { verbosity } : undefined,+ input,+ model,+ stream: shouldStream,+ ...(responseTools ? { tools: responseTools } : {}),+ };++ if (debugParams.responses()) {+ // eslint-disable-next-line no-console+ console.log('[requestPayload]');+ // eslint-disable-next-line no-console+ console.log(JSON.stringify(responsePayload), '\n');+ }++ const response = await client.responses.create(responsePayload, {+ signal: options?.signal,+ });++ if (shouldStream) {+ const stream = response as any;+ const [prod, useForDebug] = stream.tee();++ if (debugParams.responses()) {+ const useForDebugStream =+ useForDebug instanceof ReadableStream ? useForDebug : useForDebug.toReadableStream();++ debugStream(useForDebugStream).catch(console.error);+ }++ return StreamingResponse(+ OpenAIResponsesStream(prod, {+ callbacks: options?.callback,+ payload: { model, provider: ModelProvider.GithubCopilot },+ }),+ { headers: options?.headers },+ );+ }++ const responseStream = transformResponseAPIToStream(response as OpenAI.Responses.Response);++ if (debugParams.responses()) {+ debugResponse(response);+ }++ return StreamingResponse(+ OpenAIResponsesStream(responseStream, {+ callbacks: options?.callback,+ enableStreaming: false,+ payload: { model, provider: ModelProvider.GithubCopilot },+ }),+ { headers: options?.headers },+ );+ }++ const { apiMode: _, ...cleanedRest } = rest as any;+ const messages = await convertOpenAIMessages(cleanedRest.messages as any, {+ forceImageBase64: true,+ });++ const chatCompletionPayload = {+ ...cleanedRest,+ messages,+ model,+ stream: shouldStream,+ } as OpenAI.ChatCompletionCreateParamsStreaming;++ if (debugParams.chatCompletion()) {+ // eslint-disable-next-line no-console+ console.log('[requestPayload]');+ // eslint-disable-next-line no-console+ console.log(JSON.stringify(chatCompletionPayload), '\n');+ }++ let response = await client.chat.completions.create(chatCompletionPayload, {+ signal: options?.signal,+ });++ if (shouldStream && debugParams.chatCompletion()) {+ const [prod, useForDebug] = (response as any).tee();+ const useForDebugStream =+ useForDebug instanceof ReadableStream ? useForDebug : useForDebug.toReadableStream();++ debugStream(useForDebugStream).catch(console.error);+ response = prod;+ }++ if (!shouldStream && debugParams.chatCompletion()) {+ debugResponse(response);+ }return StreamingResponse(OpenAIStream(response, {@@ -224,6 +427,10 @@ export class LobeGithubCopilotAI implements LobeRuntimeAI {return { ...payload, stream: true };}+ private convertChatCompletionToolToResponseTool = (tool: any): OpenAI.Responses.Tool => {+ return { type: tool.type, ...tool.function } as any;+ };+private async executeWithRetry<T>(fn: () => Promise<T>): Promise<T> {let totalAttempts = 0;let hasRefreshedAuth = false;diff --git a/packages/model-runtime/src/providers/openai/__snapshots__/index.test.ts.snap b/packages/model-runtime/src/providers/openai/__snapshots__/index.test.ts.snapdeleted file mode 100644index 418d9aabfea..00000000000--- a/packages/model-runtime/src/providers/openai/__snapshots__/index.test.ts.snap+++ /dev/null@@ -1,518 +0,0 @@-// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html--exports[`LobeOpenAI > models > should get models 1`] = `-[- {- "contextWindowTokens": undefined,- "description": "A general speech recognition model supporting multilingual ASR, speech translation, and language identification.",- "displayName": "Whisper",- "enabled": false,- "functionCall": false,- "id": "whisper-1",- "imageOutput": false,- "maxOutput": undefined,- "pricing": undefined,- "reasoning": false,- "releasedAt": "2023-02-27",- "search": false,- "type": "stt",- "video": false,- "vision": false,- },- {- "contextWindowTokens": undefined,- "description": "",- "displayName": "davinci-002",- "enabled": false,- "functionCall": false,- "id": "davinci-002",- "imageOutput": false,- "maxOutput": undefined,- "pricing": undefined,- "reasoning": false,- "releasedAt": "2023-08-21",- "search": false,- "type": "chat",- "video": false,- "vision": false,- },- {- "contextWindowTokens": 16384,- "description": "GPT 3.5 Turbo for text generation and understanding; currently points to gpt-3.5-turbo-0125.",- "displayName": "GPT-3.5 Turbo",- "enabled": false,- "functionCall": true,- "id": "gpt-3.5-turbo",- "imageOutput": false,- "maxOutput": undefined,- "pricing": undefined,- "reasoning": false,- "releasedAt": "2023-02-28",- "search": false,- "type": "chat",- "video": false,- "vision": false,- },- {- "contextWindowTokens": undefined,- "description": "Second-generation DALL·E model with more realistic, accurate image generation and 4× the resolution of the first generation.",- "displayName": "DALL·E 2",- "enabled": false,- "functionCall": false,- "id": "dall-e-2",- "imageOutput": false,- "maxOutput": undefined,- "parameters": {- "imageUrl": {- "default": null,- },- "prompt": {- "default": "",- },- "size": {- "default": "1024x1024",- "enum": [- "256x256",- "512x512",- "1024x1024",- ],- },- },- "pricing": undefined,- "reasoning": false,- "releasedAt": "2023-11-01",- "search": false,- "type": "image",- "video": false,- "vision": false,- },- {- "contextWindowTokens": undefined,- "description": "",- "displayName": "gpt-3.5-turbo-16k",- "enabled": false,- "functionCall": false,- "id": "gpt-3.5-turbo-16k",- "imageOutput": false,- "maxOutput": undefined,- "pricing": undefined,- "reasoning": false,- "releasedAt": "2023-05-10",- "search": false,- "type": "chat",- "video": false,- "vision": false,- },- {- "contextWindowTokens": undefined,- "description": "",- "displayName": "tts-1-hd-1106",- "enabled": false,- "functionCall": false,- "id": "tts-1-hd-1106",- "imageOutput": false,- "maxOutput": undefined,- "pricing": undefined,- "reasoning": false,- "releasedAt": "2023-11-03",- "search": false,- "type": "chat",- "video": false,- "vision": false,- },- {- "contextWindowTokens": undefined,- "description": "The latest text-to-speech model optimized for quality.",- "displayName": "TTS-1 HD",- "enabled": false,- "functionCall": false,- "id": "tts-1-hd",- "imageOutput": false,- "maxOutput": undefined,- "pricing": undefined,- "reasoning": false,- "releasedAt": "2023-11-03",- "search": false,- "type": "tts",- "video": false,- "vision": false,- },- {- "contextWindowTokens": undefined,- "description": "",- "displayName": "gpt-3.5-turbo-16k-0613",- "enabled": false,- "functionCall": false,- "id": "gpt-3.5-turbo-16k-0613",- "imageOutput": false,- "maxOutput": undefined,- "pricing": undefined,- "reasoning": false,- "releasedAt": "2023-05-30",- "search": false,- "type": "chat",- "video": false,- "vision": false,- },- {- "contextWindowTokens": 8192,- "description": "The most capable embedding model for English and non-English tasks.",- "displayName": "Text Embedding 3 Large",- "enabled": false,- "functionCall": false,- "id": "text-embedding-3-large",- "imageOutput": false,- "maxOutput": undefined,- "pricing": undefined,- "reasoning": false,- "releasedAt": "2024-01-22",- "search": false,- "type": "embedding",- "video": false,- "vision": false,- },- {- "contextWindowTokens": undefined,- "description": "",- "displayName": "gpt-4-1106-vision-preview",- "enabled": false,- "functionCall": false,- "id": "gpt-4-1106-vision-preview",- "imageOutput": false,- "maxOutput": undefined,- "pricing": undefined,- "reasoning": false,- "releasedAt": "2024-03-26",- "search": false,- "type": "chat",- "video": false,- "vision": false,- },- {- "contextWindowTokens": undefined,- "description": "",- "displayName": "gpt-3.5-turbo-instruct-0914",- "enabled": false,- "functionCall": false,- "id": "gpt-3.5-turbo-instruct-0914",- "imageOutput": false,- "maxOutput": undefined,- "pricing": undefined,- "reasoning": false,- "releasedAt": "2023-09-07",- "search": false,- "type": "chat",- "video": false,- "vision": false,- },- {- "contextWindowTokens": 128000,- "description": "The latest GPT-4 Turbo adds vision. Visual requests support JSON mode and function calling. It is a cost-effective multimodal model that balances accuracy and efficiency for real-time applications.",- "displayName": "GPT-4 Turbo Preview 0125",- "enabled": false,- "functionCall": true,- "id": "gpt-4-0125-preview",- "imageOutput": false,- "maxOutput": undefined,- "pricing": undefined,- "reasoning": false,- "releasedAt": "2024-01-23",- "search": false,- "type": "chat",- "video": false,- "vision": false,- },- {- "contextWindowTokens": 128000,- "description": "The latest GPT-4 Turbo adds vision. Visual requests support JSON mode and function calling. It is a cost-effective multimodal model that balances accuracy and efficiency for real-time applications.",- "displayName": "GPT-4 Turbo Preview",- "enabled": false,- "functionCall": true,- "id": "gpt-4-turbo-preview",- "imageOutput": false,- "maxOutput": undefined,- "pricing": undefined,- "reasoning": false,- "releasedAt": "2024-01-23",- "search": false,- "type": "chat",- "video": false,- "vision": false,- },- {- "contextWindowTokens": 4096,- "description": "GPT 3.5 Turbo for text generation and understanding tasks, optimized for instruction following.",- "displayName": "GPT-3.5 Turbo Instruct",- "enabled": false,- "functionCall": false,- "id": "gpt-3.5-turbo-instruct",- "imageOutput": false,- "maxOutput": undefined,- "pricing": undefined,- "reasoning": false,- "releasedAt": "2023-08-24",- "search": false,- "type": "chat",- "video": false,- "vision": false,- },- {- "contextWindowTokens": undefined,- "description": "",- "displayName": "gpt-3.5-turbo-0301",- "enabled": false,- "functionCall": false,- "id": "gpt-3.5-turbo-0301",- "imageOutput": false,- "maxOutput": undefined,- "pricing": undefined,- "reasoning": false,- "releasedAt": "2023-03-01",- "search": false,- "type": "chat",- "video": false,- "vision": false,- },- {- "contextWindowTokens": 4096,- "description": "GPT 3.5 Turbo is a fast and efficient model for various tasks.",- "displayName": "GPT 3.5 Turbo",- "enabled": false,- "functionCall": true,- "id": "gpt-3.5-turbo-0613",- "imageOutput": false,- "maxOutput": 4096,- "pricing": undefined,- "reasoning": false,- "releasedAt": "2023-06-12",- "search": false,- "type": "chat",- "video": false,- "vision": false,- },- {- "contextWindowTokens": undefined,- "description": "The latest text-to-speech model optimized for real-time speed.",- "displayName": "TTS-1",- "enabled": false,- "functionCall": false,- "id": "tts-1",- "imageOutput": false,- "maxOutput": undefined,- "pricing": undefined,- "reasoning": false,- "releasedAt": "2023-04-19",- "search": false,- "type": "tts",- "video": false,- "vision": false,- },- {- "contextWindowTokens": undefined,- "description": "The latest DALL·E model, released in November 2023, supports more realistic, accurate image generation with stronger detail.",- "displayName": "DALL·E 3",- "enabled": true,- "functionCall": false,- "id": "dall-e-3",- "imageOutput": false,- "maxOutput": undefined,- "parameters": {- "prompt": {- "default": "",- },- "quality": {- "default": "standard",- "enum": [- "standard",- "hd",- ],- },- "size": {- "default": "1024x1024",- "enum": [- "1024x1024",- "1792x1024",- "1024x1792",- ],- },- },- "pricing": undefined,- "reasoning": false,- "releasedAt": "2023-10-31",- "search": false,- "type": "image",- "video": false,- "vision": false,- },- {- "contextWindowTokens": 16384,- "description": "GPT 3.5 Turbo for text generation and understanding; currently points to gpt-3.5-turbo-0125.",- "displayName": "GPT-3.5 Turbo 1106",- "enabled": false,- "functionCall": true,- "id": "gpt-3.5-turbo-1106",- "imageOutput": false,- "maxOutput": undefined,- "pricing": undefined,- "reasoning": false,- "releasedAt": "2023-11-02",- "search": false,- "type": "chat",- "video": false,- "vision": false,- },- {- "contextWindowTokens": 128000,- "description": "The latest GPT-4 Turbo adds vision. Visual requests support JSON mode and function calling. It is a cost-effective multimodal model that balances accuracy and efficiency for real-time applications.",- "displayName": "GPT-4 Turbo Preview 1106",- "enabled": false,- "functionCall": true,- "id": "gpt-4-1106-preview",- "imageOutput": false,- "maxOutput": undefined,- "pricing": undefined,- "reasoning": false,- "releasedAt": "2023-11-02",- "search": false,- "type": "chat",- "video": false,- "vision": false,- },- {- "contextWindowTokens": undefined,- "description": "",- "displayName": "babbage-002",- "enabled": false,- "functionCall": false,- "id": "babbage-002",- "imageOutput": false,- "maxOutput": undefined,- "pricing": undefined,- "reasoning": false,- "releasedAt": "2023-08-21",- "search": false,- "type": "chat",- "video": false,- "vision": false,- },- {- "contextWindowTokens": undefined,- "description": "",- "displayName": "tts-1-1106",- "enabled": false,- "functionCall": false,- "id": "tts-1-1106",- "imageOutput": false,- "maxOutput": undefined,- "pricing": undefined,- "reasoning": false,- "releasedAt": "2023-11-03",- "search": false,- "type": "chat",- "video": false,- "vision": false,- },- {- "contextWindowTokens": 128000,- "description": "GPT-4 Vision preview, designed for image analysis and processing tasks.",- "displayName": "GPT 4 Turbo with Vision Preview",- "enabled": false,- "functionCall": false,- "id": "gpt-4-vision-preview",- "imageOutput": false,- "maxOutput": undefined,- "pricing": undefined,- "reasoning": false,- "releasedAt": "2023-11-02",- "search": false,- "type": "chat",- "video": false,- "vision": true,- },- {- "contextWindowTokens": 8192,- "description": "An efficient, cost-effective next-generation embedding model for retrieval and RAG scenarios.",- "displayName": "Text Embedding 3 Small",- "enabled": false,- "functionCall": false,- "id": "text-embedding-3-small",- "imageOutput": false,- "maxOutput": undefined,- "pricing": undefined,- "reasoning": false,- "releasedAt": "2024-01-22",- "search": false,- "type": "embedding",- "video": false,- "vision": false,- },- {- "contextWindowTokens": 8192,- "description": "GPT-4 provides a larger context window to handle longer inputs, suitable for broad information synthesis and data analysis.",- "displayName": "GPT-4",- "enabled": false,- "functionCall": true,- "id": "gpt-4",- "imageOutput": false,- "maxOutput": undefined,- "pricing": undefined,- "reasoning": false,- "releasedAt": "2023-06-27",- "search": false,- "type": "chat",- "video": false,- "vision": false,- },- {- "contextWindowTokens": 8192,- "description": "Embedding V2 Ada model for text embeddings.",- "displayName": "Embedding V2 Ada",- "enabled": false,- "functionCall": false,- "id": "text-embedding-ada-002",- "imageOutput": false,- "maxOutput": undefined,- "pricing": undefined,- "reasoning": false,- "releasedAt": "2022-12-16",- "search": false,- "type": "chat",- "video": false,- "vision": false,- },- {- "contextWindowTokens": 16384,- "description": "GPT 3.5 Turbo for text generation and understanding; currently points to gpt-3.5-turbo-0125.",- "displayName": "GPT-3.5 Turbo 0125",- "enabled": false,- "functionCall": true,- "id": "gpt-3.5-turbo-0125",- "imageOutput": false,- "maxOutput": undefined,- "pricing": undefined,- "reasoning": false,- "releasedAt": "2024-01-23",- "search": false,- "type": "chat",- "video": false,- "vision": false,- },- {- "contextWindowTokens": 8192,- "description": "GPT-4 provides a larger context window to handle longer inputs, suitable for broad information synthesis and data analysis.",- "displayName": "GPT-4 0613",- "enabled": false,- "functionCall": true,- "id": "gpt-4-0613",- "imageOutput": false,- "maxOutput": undefined,- "pricing": undefined,- "reasoning": false,- "releasedAt": "2023-06-12",- "search": false,- "type": "chat",- "video": false,- "vision": false,- },-]-`;diff --git a/packages/model-runtime/src/providers/openai/index.test.ts b/packages/model-runtime/src/providers/openai/index.test.tsindex b5a0e914763..be28b6ac489 100644--- a/packages/model-runtime/src/providers/openai/index.test.ts+++ b/packages/model-runtime/src/providers/openai/index.test.ts@@ -240,7 +240,16 @@ describe('LobeOpenAI', () => {const list = await instance.models();- expect(list).toMatchSnapshot();+ expect(Array.isArray(list)).toBe(true);+ expect(list.length).toBeGreaterThan(0);++ const gpt35Turbo = list.find((model) => model.id === 'gpt-3.5-turbo-0613');+ expect(gpt35Turbo).toBeDefined();+ expect(gpt35Turbo?.id).toBe('gpt-3.5-turbo-0613');++ const textEmbeddingAda = list.find((model) => model.id === 'text-embedding-ada-002');+ expect(textEmbeddingAda).toBeDefined();+ expect(textEmbeddingAda?.type).toBe('embedding');});});