Skip to content

Commit a5bb02e

Browse files
committed
fix: handle openrouter special case
1 parent 90fb2b0 commit a5bb02e

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

providers/openrouter/language_model_hooks.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,26 @@ func languageModelStreamExtra(chunk openaisdk.ChatCompletionChunk, yield func(fa
264264
}
265265

266266
if strings.HasPrefix(detail.Format, "google-gemini") {
267+
// this means there is only encrypted data available start and finish right away
268+
if detail.Type == "reasoning.encrypted" {
269+
ctx[reasoningStartedCtx] = nil
270+
if !yield(fantasy.StreamPart{
271+
Type: fantasy.StreamPartTypeReasoningStart,
272+
ID: fmt.Sprintf("%d", inx),
273+
}) {
274+
return ctx, false
275+
}
276+
return ctx, yield(fantasy.StreamPart{
277+
Type: fantasy.StreamPartTypeReasoningEnd,
278+
ID: fmt.Sprintf("%d", inx),
279+
ProviderMetadata: fantasy.ProviderMetadata{
280+
google.Name: &google.ReasoningMetadata{
281+
Signature: detail.Data,
282+
ToolID: detail.ID,
283+
},
284+
},
285+
})
286+
}
267287
currentState.googleMetadata = &google.ReasoningMetadata{}
268288
currentState.googleText = detail.Text
269289
metadata = fantasy.ProviderMetadata{

0 commit comments

Comments
 (0)