diff --git a/packages/core/package.json b/packages/core/package.json index 12427bc1..32a8d6fd 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@smythos/sre", - "version": "1.5.45", + "version": "1.5.46", "description": "Smyth Runtime Environment", "author": "Alaa-eddine KADDOURI", "license": "MIT", diff --git a/packages/core/src/subsystems/LLMManager/LLM.service/connectors/openai/apiInterfaces/ChatCompletionsApiInterface.ts b/packages/core/src/subsystems/LLMManager/LLM.service/connectors/openai/apiInterfaces/ChatCompletionsApiInterface.ts index f63367d8..5eeec642 100644 --- a/packages/core/src/subsystems/LLMManager/LLM.service/connectors/openai/apiInterfaces/ChatCompletionsApiInterface.ts +++ b/packages/core/src/subsystems/LLMManager/LLM.service/connectors/openai/apiInterfaces/ChatCompletionsApiInterface.ts @@ -5,13 +5,8 @@ import { AccessCandidate } from '@sre/Security/AccessControl/AccessCandidate.cla import { TLLMParams, TLLMPreparedParams, ILLMRequestContext, ToolData, TLLMMessageRole, APIKeySource, TLLMEvent } from '@sre/types/LLM.types'; import { OpenAIApiInterface, ToolConfig } from './OpenAIApiInterface'; import { HandlerDependencies } from '../types'; -import { JSON_RESPONSE_INSTRUCTION, SUPPORTED_MIME_TYPES_MAP } from '@sre/constants'; -import { - MODELS_WITHOUT_PRESENCE_PENALTY_SUPPORT, - MODELS_WITHOUT_TEMPERATURE_SUPPORT, - MODELS_WITHOUT_SYSTEM_MESSAGE_SUPPORT, - MODELS_WITHOUT_JSON_RESPONSE_SUPPORT, -} from './constants'; +import { JSON_RESPONSE_INSTRUCTION, SUPPORTED_MIME_TYPES_MAP, BUILT_IN_MODEL_PREFIX } from '@sre/constants'; +import { MODELS_WITHOUT_SYSTEM_MESSAGE_SUPPORT, MODELS_WITHOUT_JSON_RESPONSE_SUPPORT, O3_AND_O4_MODELS } from './constants'; import { isValidOpenAIReasoningEffort } from './utils'; @@ -134,32 +129,33 @@ export class ChatCompletionsApiInterface extends OpenAIApiInterface { } // Handle temperature - if (params?.temperature !== undefined && !MODELS_WITHOUT_TEMPERATURE_SUPPORT.includes(params.modelEntryName)) { + const modelName = params.modelEntryName?.replace(BUILT_IN_MODEL_PREFIX, ''); + if (params?.temperature !== undefined && !O3_AND_O4_MODELS.includes(modelName)) { body.temperature = params.temperature; } // Handle topP - if (params?.topP !== undefined) { + if (params?.topP !== undefined && !O3_AND_O4_MODELS.includes(modelName)) { body.top_p = params.topP; } // Handle frequency penalty - if (params?.frequencyPenalty !== undefined) { + if (params?.frequencyPenalty !== undefined && !O3_AND_O4_MODELS.includes(modelName)) { body.frequency_penalty = params.frequencyPenalty; } // Handle presence penalty - if (params?.presencePenalty !== undefined && !MODELS_WITHOUT_PRESENCE_PENALTY_SUPPORT.includes(params.modelEntryName)) { + if (params?.presencePenalty !== undefined && !O3_AND_O4_MODELS.includes(modelName)) { body.presence_penalty = params.presencePenalty; } // Handle response format - if (params?.responseFormat?.type && !MODELS_WITHOUT_JSON_RESPONSE_SUPPORT.includes(params.modelEntryName)) { + if (params?.responseFormat?.type && !MODELS_WITHOUT_JSON_RESPONSE_SUPPORT.includes(modelName)) { body.response_format = params.responseFormat; } // Handle stop sequences - if (params?.stopSequences?.length) { + if (params?.stopSequences?.length && !O3_AND_O4_MODELS.includes(modelName)) { body.stop = params.stopSequences; } diff --git a/packages/core/src/subsystems/LLMManager/LLM.service/connectors/openai/apiInterfaces/ResponsesApiInterface.ts b/packages/core/src/subsystems/LLMManager/LLM.service/connectors/openai/apiInterfaces/ResponsesApiInterface.ts index 328055d7..7c4ced27 100644 --- a/packages/core/src/subsystems/LLMManager/LLM.service/connectors/openai/apiInterfaces/ResponsesApiInterface.ts +++ b/packages/core/src/subsystems/LLMManager/LLM.service/connectors/openai/apiInterfaces/ResponsesApiInterface.ts @@ -4,24 +4,11 @@ import type { Stream } from 'openai/streaming'; import { BinaryInput } from '@sre/helpers/BinaryInput.helper'; import { AccessCandidate } from '@sre/Security/AccessControl/AccessCandidate.class'; -import { - TLLMParams, - TLLMPreparedParams, - ILLMRequestContext, - TLLMMessageBlock, - ToolData, - TLLMToolResultMessageBlock, - TLLMMessageRole, - APIKeySource, - TLLMEvent, - OpenAIToolDefinition, - LegacyToolDefinition, - LLMModelInfo, -} from '@sre/types/LLM.types'; +import { TLLMParams, TLLMPreparedParams, ILLMRequestContext, ToolData, APIKeySource, TLLMEvent, LLMModelInfo } from '@sre/types/LLM.types'; import { OpenAIApiInterface, ToolConfig } from './OpenAIApiInterface'; import { HandlerDependencies, TToolType } from '../types'; import { SUPPORTED_MIME_TYPES_MAP } from '@sre/constants'; -import { MODELS_WITHOUT_TEMPERATURE_SUPPORT, SEARCH_TOOL_COSTS } from './constants'; +import { SEARCH_TOOL_COSTS } from './constants'; import { isValidOpenAIReasoningEffort } from './utils'; // File size limits in bytes @@ -564,16 +551,6 @@ export class ResponsesApiInterface extends OpenAIApiInterface { if (params?.maxTokens !== undefined) { body.max_output_tokens = params.maxTokens; } - - // o3-pro does not support temperature - if (params?.temperature !== undefined && !MODELS_WITHOUT_TEMPERATURE_SUPPORT.includes(params.modelEntryName)) { - body.temperature = params.temperature; - } - - if (params?.topP !== undefined) { - body.top_p = params.topP; - } - // #region GPT 5 specific fields const isGPT5ReasoningModels = params.modelEntryName?.includes('gpt-5') && params?.capabilities?.reasoning; diff --git a/packages/core/src/subsystems/LLMManager/LLM.service/connectors/openai/apiInterfaces/constants.ts b/packages/core/src/subsystems/LLMManager/LLM.service/connectors/openai/apiInterfaces/constants.ts index 18c7646f..1e6bd3e7 100644 --- a/packages/core/src/subsystems/LLMManager/LLM.service/connectors/openai/apiInterfaces/constants.ts +++ b/packages/core/src/subsystems/LLMManager/LLM.service/connectors/openai/apiInterfaces/constants.ts @@ -1,5 +1,5 @@ -export const MODELS_WITHOUT_TEMPERATURE_SUPPORT = ['o3-pro', 'o4-mini']; -export const MODELS_WITHOUT_PRESENCE_PENALTY_SUPPORT = ['o4-mini']; +export const O3_AND_O4_MODELS = ['o3', 'o3-pro', 'o4-mini']; +export const O3_AND_O4_MODELS_PATTERN = /o3|o4/i; export const MODELS_WITHOUT_JSON_RESPONSE_SUPPORT = ['o1-preview']; export const MODELS_WITHOUT_SYSTEM_MESSAGE_SUPPORT = ['o1-mini', 'o1-preview']; diff --git a/packages/sdk/package.json b/packages/sdk/package.json index 557145da..662fcb28 100644 --- a/packages/sdk/package.json +++ b/packages/sdk/package.json @@ -1,6 +1,6 @@ { "name": "@smythos/sdk", - "version": "1.0.43", + "version": "1.0.44", "description": "SRE SDK", "keywords": [ "smythos",