Skip to content

Construct non-Azure OpenAI clients for default and EU endpoints #43228

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

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Code generated by Microsoft (R) TypeSpec Code Generator.
package com.azure.ai.openai;

import static com.azure.ai.openai.implementation.NonAzureOpenAIClientImpl.OPEN_AI_ENDPOINT;
import static com.azure.ai.openai.implementation.NonAzureOpenAIClientImpl.OPEN_AI_ENDPOINT_PATTERN;

import com.azure.ai.openai.implementation.NonAzureOpenAIClientImpl;
import com.azure.ai.openai.implementation.OpenAIClientImpl;
Expand Down Expand Up @@ -333,7 +333,7 @@ private HttpPipeline createHttpPipeline() {
private NonAzureOpenAIClientImpl buildInnerNonAzureOpenAIClient() {
HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline();
NonAzureOpenAIClientImpl client
= new NonAzureOpenAIClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter());
= new NonAzureOpenAIClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint);
return client;
}

Expand Down Expand Up @@ -362,11 +362,11 @@ public OpenAIClient buildClient() {
private static final ClientLogger LOGGER = new ClientLogger(OpenAIClientBuilder.class);

/**
* OpenAI service can be used by either not setting the endpoint or by setting the endpoint to start with
* "https://api.openai.com/"
* OpenAI service can be used by either not setting the endpoint or by setting the endpoint to a
* URL like "https://api.openai.com/v1" or "https://eu.api.openai.com/v1".
*/
private boolean useNonAzureOpenAIService() {
return endpoint == null || endpoint.startsWith(OPEN_AI_ENDPOINT);
return endpoint == null || OPEN_AI_ENDPOINT_PATTERN.matcher(endpoint).matches();
}

private void validateClient() {
Expand Down
Loading
Loading