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

Possible fix for issue #2218, allowing to disable setting the Authorization header #2219

Closed
wants to merge 1 commit into from

Conversation

paulbakker
Copy link
Contributor

Allow disabling setting the Authorization header in OpenAi models.

Possible fix for #2218

…ing the Authorization header.

Signed-off-by: pbakker <[email protected]>
@ilayaperumalg ilayaperumalg self-assigned this Feb 12, 2025
@ilayaperumalg ilayaperumalg added this to the 1.0.0-M6 milestone Feb 12, 2025
Copy link
Member

@ilayaperumalg ilayaperumalg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, merging. will follow up with a PR to use ApiKey for the other OpenAi APIs.

import org.springframework.ai.model.ChatModelDescription;
import org.springframework.ai.model.ModelOptionsUtils;
import org.springframework.ai.model.SimpleApiKey;
import org.springframework.ai.model.*;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wildcard import isn't allowed and will fix when merging.

@ilayaperumalg
Copy link
Member

@paulbakker Thanks for the PR!
Rebased, cleaned up java imports, license header and merged as b936a9c. Will have a follow up PR for using ApiKey for image, audio and moderation APIs.

@ilayaperumalg
Copy link
Member

PR to use ApiKey for other OpenAI APIs: #2226

@paulbakker
Copy link
Contributor Author

Thanks for the super quick follow up @ilayaperumalg 🙏

@@ -200,7 +192,10 @@ public OpenAiApi(String baseUrl, ApiKey apiKey, MultiValueMap<String, String> he
this.embeddingsPath = embeddingsPath;
// @formatter:off
Consumer<HttpHeaders> finalHeaders = h -> {
h.setBearerAuth(apiKey.getValue());
if(!(apiKey instanceof NoopApiKey)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of checking for a specific impl, we should check for the return value, if it is empty then don't set header.

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

Successfully merging this pull request may close these issues.

3 participants