Skip to content

Commit f68d124

Browse files
committed
fix(llm): add trailing slash to customOpenAiHost && fixed #77
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.
1 parent 71ca091 commit f68d124

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/main/kotlin/cc/unitmesh/devti/llms/azure/AzureOpenAIProvider.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,14 @@ class AzureOpenAIProvider(val project: Project) : LLMProvider {
5151
private val logger = logger<AzureOpenAIProvider>()
5252

5353
private val autoDevSettingsState = AutoDevSettingsState.getInstance()
54-
private val url get() = autoDevSettingsState.customOpenAiHost
54+
private val url: String
55+
get() {
56+
val customOpenAiHost = autoDevSettingsState.customOpenAiHost
57+
if (!customOpenAiHost.endsWith("/")) {
58+
return "$customOpenAiHost/"
59+
}
60+
return customOpenAiHost
61+
}
5562
private var customPromptConfig: CustomPromptConfig? = null
5663
private val timeout = Duration.ofSeconds(600)
5764
private var client = OkHttpClient().newBuilder().readTimeout(timeout).build()

src/main/kotlin/cc/unitmesh/devti/llms/openai/OpenAIProvider.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ class OpenAIProvider(val project: Project) : LLMProvider {
3838
throw IllegalStateException("openAiKey is empty")
3939
}
4040

41-
val openAiProxy = AutoDevSettingsState.getInstance().customOpenAiHost
41+
var openAiProxy = AutoDevSettingsState.getInstance().customOpenAiHost
42+
if (!openAiProxy.endsWith("/")) {
43+
openAiProxy += "/"
44+
}
45+
4246
return if (openAiProxy.isEmpty()) {
4347
OpenAiService(openAiKey, timeout)
4448
} else {

0 commit comments

Comments
 (0)