Skip to content

Commit 595f34e

Browse files
committed
fix: integration test cases fixes
1 parent c3f5100 commit 595f34e

File tree

37 files changed

+333
-287
lines changed

37 files changed

+333
-287
lines changed

core/changelog.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
feat: send back raw request in extra fields
22
feat: added support for reasoning in chat completions
33
feat: enhanced reasoning support in responses api
4-
enhancement: improved internal inter provider conversions for integrations
4+
enhancement: improved internal inter provider conversions for integrations
5+
feat: switched to gemini native api
6+
feat: fallback to supported request type for custom models used in integration

core/providers/cohere/chat.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -690,5 +690,11 @@ func (cm *CohereMessage) ToBifrostChatMessage() *schemas.ChatMessage {
690690
Content: messageContent,
691691
ChatAssistantMessage: assistantMessage,
692692
}
693+
694+
if cm.Role == "tool" {
695+
bifrostMessage.ChatToolMessage = &schemas.ChatToolMessage{
696+
ToolCallID: cm.ToolCallID,
697+
}
698+
}
693699
return bifrostMessage
694700
}

core/providers/gemini/chat.go

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,8 @@ func (response *GenerateContentResponse) ToBifrostChatCompletionStream() (*schem
187187

188188
candidate := response.Candidates[0]
189189

190-
// Determine if this is the last chunk based on finish reason or usage metadata
191-
isLastChunk := candidate.FinishReason != "" && candidate.FinishReason != FinishReasonUnspecified
190+
// Determine if this is the last chunk based on finish reason and usage metadata
191+
isLastChunk := candidate.FinishReason != "" && response.UsageMetadata != nil
192192

193193
// Create the streaming response
194194
streamResponse := &schemas.BifrostChatResponse{
@@ -256,15 +256,6 @@ func (response *GenerateContentResponse) ToBifrostChatCompletionStream() (*schem
256256
},
257257
}
258258

259-
// Preserve thought signature if present (required for Gemini 3 Pro)
260-
if len(part.ThoughtSignature) > 0 {
261-
toolCall.ExtraContent = map[string]interface{}{
262-
"google": map[string]interface{}{
263-
"thought_signature": string(part.ThoughtSignature),
264-
},
265-
}
266-
}
267-
268259
toolCalls = append(toolCalls, toolCall)
269260

270261
case part.FunctionResponse != nil:

core/providers/gemini/gemini.go

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ func (provider *GeminiProvider) ChatCompletion(ctx context.Context, key schemas.
245245

246246
// Set raw request if enabled
247247
if providerUtils.ShouldSendBackRawRequest(ctx, provider.sendBackRawRequest) {
248-
bifrostResponse.ExtraFields.RawRequest = jsonData
248+
providerUtils.ParseAndSetRawRequest(&bifrostResponse.ExtraFields, jsonData)
249249
}
250250

251251
// Set raw response if enabled
@@ -386,6 +386,11 @@ func HandleGeminiChatCompletionStream(
386386
var modelName string
387387

388388
for scanner.Scan() {
389+
select {
390+
case <-ctx.Done():
391+
return
392+
default:
393+
}
389394
line := scanner.Text()
390395

391396
// Skip empty lines and comments
@@ -688,6 +693,11 @@ func HandleGeminiResponsesStream(
688693
var lastUsageMetadata *GenerateContentResponseUsageMetadata
689694

690695
for scanner.Scan() {
696+
select {
697+
case <-ctx.Done():
698+
return
699+
default:
700+
}
691701
line := scanner.Text()
692702

693703
// Skip empty lines and comments
@@ -1001,6 +1011,11 @@ func (provider *GeminiProvider) SpeechStream(ctx context.Context, postHookRunner
10011011
lastChunkTime := startTime
10021012

10031013
for scanner.Scan() {
1014+
select {
1015+
case <-ctx.Done():
1016+
return
1017+
default:
1018+
}
10041019
line := scanner.Text()
10051020

10061021
// Skip empty lines
@@ -1259,6 +1274,11 @@ func (provider *GeminiProvider) TranscriptionStream(ctx context.Context, postHoo
12591274
var fullTranscriptionText string
12601275

12611276
for scanner.Scan() {
1277+
select {
1278+
case <-ctx.Done():
1279+
return
1280+
default:
1281+
}
12621282
line := scanner.Text()
12631283

12641284
// Skip empty lines

0 commit comments

Comments
 (0)