Skip to content

Commit

Permalink
fix(llm): add trailing slash to customOpenAiHost && fixed #77
Browse files Browse the repository at this point in the history
Add a trailing slash to the `customOpenAiHost` if it doesn't already have one. This ensures that the URL is properly formatted.

Also update the corresponding message in the AutoDevBundle.properties file to indicate that the `customOpenAIHost` parameter must end with a slash.
  • Loading branch information
phodal committed Jan 21, 2024
1 parent 71ca091 commit f68d124
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Expand Up @@ -51,7 +51,14 @@ class AzureOpenAIProvider(val project: Project) : LLMProvider {
private val logger = logger<AzureOpenAIProvider>()

private val autoDevSettingsState = AutoDevSettingsState.getInstance()
private val url get() = autoDevSettingsState.customOpenAiHost
private val url: String
get() {
val customOpenAiHost = autoDevSettingsState.customOpenAiHost
if (!customOpenAiHost.endsWith("/")) {
return "$customOpenAiHost/"
}
return customOpenAiHost
}
private var customPromptConfig: CustomPromptConfig? = null
private val timeout = Duration.ofSeconds(600)
private var client = OkHttpClient().newBuilder().readTimeout(timeout).build()
Expand Down
Expand Up @@ -38,7 +38,11 @@ class OpenAIProvider(val project: Project) : LLMProvider {
throw IllegalStateException("openAiKey is empty")
}

val openAiProxy = AutoDevSettingsState.getInstance().customOpenAiHost
var openAiProxy = AutoDevSettingsState.getInstance().customOpenAiHost
if (!openAiProxy.endsWith("/")) {
openAiProxy += "/"
}

return if (openAiProxy.isEmpty()) {
OpenAiService(openAiKey, timeout)
} else {
Expand Down

0 comments on commit f68d124

Please sign in to comment.