Skip to content

Commit dc587af

Browse files
committed
Add baseUrl https validation
1 parent 18a5557 commit dc587af

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

internal/api/chat/create_conversation_message_stream_v2.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"paperdebugger/internal/models"
99
"paperdebugger/internal/services"
1010
chatv2 "paperdebugger/pkg/gen/api/chat/v2"
11+
"strings"
1112

1213
"github.com/google/uuid"
1314
"github.com/openai/openai-go/v3"
@@ -296,6 +297,16 @@ func (s *ChatServerV2) CreateConversationMessageStream(
296297
IsCustomModel: false,
297298
}
298299
} else {
300+
customModel.BaseUrl = strings.ToLower(customModel.BaseUrl)
301+
302+
if strings.Contains(customModel.BaseUrl, "paperdebugger.com") {
303+
customModel.BaseUrl = ""
304+
}
305+
if !strings.HasPrefix(customModel.BaseUrl, "https://") {
306+
customModel.BaseUrl = strings.Replace(customModel.BaseUrl, "http://", "", 1)
307+
customModel.BaseUrl = "https://" + customModel.BaseUrl
308+
}
309+
299310
llmProvider = &models.LLMProviderConfig{
300311
APIKey: customModel.APIKey,
301312
Endpoint: customModel.BaseUrl,

0 commit comments

Comments
 (0)