Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] OpenAi O1 doesn't support temperature, waiting for LangChain4J upgrade #442

Open
stephanj opened this issue Jan 25, 2025 · 3 comments
Labels
enhancement New feature or request

Comments

@stephanj
Copy link
Contributor

We need to remove the temperature param when OpenAI o1 is selected.

An unexpected error occurred: CompletionException - com.devoxx.genie.service.exception.ProviderUnavailableException: dev.ai4j.openai4j.OpenAiHttpException: { "error": { "message": "Unsupported parameter: 'temperature' is not supported with this model.", "type": "invalid_request_error", "param": "temperature", "code": "unsupported_parameter" } } Caused by: ProviderUnavailableException - dev.ai4j.openai4j.OpenAiHttpException: { "error": { "message": "Unsupported parameter: 'temperature' is not supported with this model.", "type": "invalid_request_error", "param": "temperature", "code": "unsupported_parameter" } } Please check the IDE log for more details.
@stephanj stephanj added the enhancement New feature or request label Jan 25, 2025
@stephanj
Copy link
Contributor Author

stephanj commented Jan 25, 2025

Langchain4J sets the default temperature to 0.7 when it has a null value. So there's no way to override this.
A fix will be included in a very near future release of LC4J 🤩

this.defaultRequestParameters = OpenAiChatRequestParameters.builder()
                // common parameters
                .modelName(getOrDefault(getOrDefault(modelName, commonParameters.modelName()), GPT_3_5_TURBO))
                .temperature(getOrDefault(getOrDefault(temperature, commonParameters.temperature()), 0.7))
                .topP(getOrDefault(topP, commonParameters.topP()))
       ...

@stephanj
Copy link
Contributor Author

Wip 👇 👀
langchain4j/langchain4j@0a75a33

@stephanj stephanj changed the title OpenAi O1 doesn't support temperature [FEATURE] OpenAi O1 doesn't support temperature, waiting for LangChain4J upgrade Jan 28, 2025
@stephanj
Copy link
Contributor Author

stephanj commented Feb 2, 2025

"Try out @openai's latest o3-mini model using #LangChain4j 1.0.0-alpha2-SNAPSHOT version (the official release version will be available early next week)"

<dependency>
    <groupId>dev.langchain4j</groupId>
    <artifactId>langchain4j-open-ai</artifactId>
    <version>1.0.0-alpha2-SNAPSHOT</version>
</dependency>
OpenAiChatModel model = OpenAiChatModel.builder()
        .apiKey(System.getenv("OPENAI_API_KEY"))
        .defaultRequestParameters(OpenAiChatRequestParameters.builder()
                .modelName("o3-mini")
                .reasoningEffort("medium")
                .build())
        .build();

String answer = model.chat("Explain the difference between O3 and O2");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant