fix: test

This commit is contained in:
suyao 2025-12-03 12:15:53 +08:00
parent fd0be32ab4
commit 08a537bfe4
No known key found for this signature in database
4 changed files with 56 additions and 3 deletions

View File

@ -322,9 +322,10 @@ function convertAnthropicToAiMessages(params: MessageCreateParams): ModelMessage
}
}
if (openRouterReasoningCache.get(`openrouter-${block.id}`)) {
options.openrouter = {
reasoning_details: (sanitizeJson(openRouterReasoningCache.get(`openrouter-${block.id}`)) as JSONValue[]) || []
}
options.openrouter = {
reasoning_details:
(sanitizeJson(openRouterReasoningCache.get(`openrouter-${block.id}`)) as JSONValue[]) || []
}
}
toolCallParts.push({
type: 'tool-call',

View File

@ -6,6 +6,29 @@ import { isDeepSeekHybridInferenceModel } from '../reasoning'
import { isFunctionCallingModel } from '../tooluse'
import { isPureGenerateImageModel, isTextToImageModel } from '../vision'
vi.mock('@renderer/i18n', () => ({
__esModule: true,
default: {
t: vi.fn((key: string) => key)
}
}))
vi.mock('@renderer/services/AssistantService', () => ({
getProviderByModel: vi.fn().mockReturnValue({
id: 'openai',
type: 'openai',
name: 'OpenAI',
models: []
}),
getAssistantSettings: vi.fn(),
getDefaultAssistant: vi.fn().mockReturnValue({
id: 'default',
name: 'Default Assistant',
prompt: '',
settings: {}
})
}))
vi.mock('@renderer/hooks/useStore', () => ({
getStoreProviders: vi.fn(() => [])
}))

View File

@ -68,6 +68,29 @@ vi.mock('@renderer/store/settings', () => {
)
})
vi.mock('@renderer/i18n', () => ({
__esModule: true,
default: {
t: vi.fn((key: string) => key)
}
}))
vi.mock('@renderer/services/AssistantService', () => ({
getProviderByModel: vi.fn().mockReturnValue({
id: 'openai',
type: 'openai',
name: 'OpenAI',
models: []
}),
getAssistantSettings: vi.fn(),
getDefaultAssistant: vi.fn().mockReturnValue({
id: 'default',
name: 'Default Assistant',
prompt: '',
settings: {}
})
}))
vi.mock('@renderer/hooks/useSettings', () => ({
useSettings: vi.fn(() => ({})),
useNavbarPosition: vi.fn(() => ({ navbarPosition: 'left' })),
@ -98,6 +121,10 @@ vi.mock('../websearch', () => ({
isOpenAIWebSearchChatCompletionOnlyModel: vi.fn()
}))
vi.mock('../tooluse', () => ({
isFunctionCallingModel: vi.fn()
}))
const createModel = (overrides: Partial<Model> = {}): Model => ({
id: 'gpt-4o',
name: 'gpt-4o',
@ -125,6 +152,7 @@ describe('model utils', () => {
generateImageMock.mockReturnValue(false)
reasoningMock.mockReturnValue(false)
openAIWebSearchOnlyMock.mockReturnValue(false)
isFunctionCallingModelMock.mockReturnValue(true)
})
describe('OpenAI model detection', () => {

View File

@ -10,6 +10,7 @@ export {
SUPPORTED_IMAGE_ENDPOINT_LIST,
validateApiHost,
withoutTrailingApiVersion,
withoutTrailingSharp,
withoutTrailingSlash
} from '@shared/api'