Skip to content

Commit 3dd9bd9

Browse files
committed
Merge branch 'staging' into feat/proj-cost-track
2 parents 4c14874 + 56cbe48 commit 3dd9bd9

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

internal/api/chat/create_conversation_message_stream_v2.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,32 @@ func (s *ChatServerV2) CreateConversationMessageStream(
313313
}
314314
}
315315

316+
// Usage is the same as ChatCompletion, just passing the stream parameter
317+
318+
if customModel == nil {
319+
// User did not specify API key for this model
320+
llmProvider = &models.LLMProviderConfig{
321+
APIKey: "",
322+
IsCustomModel: false,
323+
}
324+
} else {
325+
customModel.BaseUrl = strings.ToLower(customModel.BaseUrl)
326+
327+
if strings.Contains(customModel.BaseUrl, "paperdebugger.com") {
328+
customModel.BaseUrl = ""
329+
}
330+
if !strings.HasPrefix(customModel.BaseUrl, "https://") {
331+
customModel.BaseUrl = strings.Replace(customModel.BaseUrl, "http://", "", 1)
332+
customModel.BaseUrl = "https://" + customModel.BaseUrl
333+
}
334+
335+
llmProvider = &models.LLMProviderConfig{
336+
APIKey: customModel.APIKey,
337+
Endpoint: customModel.BaseUrl,
338+
IsCustomModel: true,
339+
}
340+
}
341+
316342
openaiChatHistory, inappChatHistory, _, err := s.aiClientV2.ChatCompletionStreamV2(ctx, stream, conversation.UserID, conversation.ProjectID, conversation.ID.Hex(), modelSlug, conversation.OpenaiChatHistoryCompletion, llmProvider)
317343
if err != nil {
318344
return s.sendStreamError(stream, err)

0 commit comments

Comments
 (0)