fix: #3698 - o1 preview models do not work with max_tokens #3728
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Describe Your Changes
This PR addresses the issue where OpenAI preview models don't work with the
max_tokens
parameter. We'll likely deprecatemodel.json
for remote models at least, so we're not introducing new model parameter support. Instead, we're using the standard payload transform that's been applied to other providers.The changes are mostly about adding tests.
Fixes Issues
Additions and Changes:
Addition of Jest Configuration:
jest.config.js
has been added underextensions/inference-openai-extension
. This setting includes configurations such aspreset
,testEnvironment
, and custom transformations for testing@janhq/core
modules.Addition of Jest Test File:
OpenAIExtension.test.ts
has been added undersrc
. This test suite mocks the@janhq/core
module and includes tests for theJanInferenceOpenAIExtension
class, including initialization, payload transformation, and other functionalities specific to different model types.Modifications to
index.ts
:index.ts
file has been modified to incorporate new exports and enums, and introduce atransformPayload
method within theJanInferenceOpenAIExtension
class. The payload transformation accounts for differences between preview models (o1-mini
,o1-preview
) and non-preview models.max_completion_tokens
for preview models, while other models retain their original payload structure.Changes to
tsconfig.json
:tsconfig.json
adds an"exclude"
field to exclude test files (those ending in.test.ts
) from compilation. This likely ensures that unit test files are not included in the final production build.