Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion core/tests/e2e_tool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ func TestToolCallingEndToEnd(t *testing.T) {
// Only assert on Function.Name if it's not nil to prevent panic
require.NotNil(t, toolCall.Function.Name, "toolCall.Function.Name should not be nil")
assert.Equal(t, "get_weather", *toolCall.Function.Name)
require.NotNil(t, toolCall.ID)

// Verify tool arguments contain location
var params map[string]interface{}
Expand Down
2 changes: 1 addition & 1 deletion plugins/maxim/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/maximhq/bifrost/plugins/maxim
go 1.24.1

require (
github.com/maximhq/bifrost/core v1.0.7
github.com/maximhq/bifrost/core v1.0.9
github.com/maximhq/maxim-go v0.1.3
)

Expand Down
4 changes: 2 additions & 2 deletions plugins/maxim/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo=
github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ=
github.com/maximhq/bifrost/core v1.0.7 h1:+89Vq+FuD7FFZNbF161/FLBSFjAYLr4/UuWR8Do0Hyc=
github.com/maximhq/bifrost/core v1.0.7/go.mod h1:8aUSLGVdOhwxDzMcdQnSyMfSBA3lT05ICgX0b/VKc8g=
github.com/maximhq/bifrost/core v1.0.9 h1:OWUHCWCQsBH43YPIy2AsqNMZhoFXYe/qhJSCLbw5su8=
github.com/maximhq/bifrost/core v1.0.9/go.mod h1:8ycaWQ9bjQezoUT/x6a82VmPjoqLzyGglQ0RnnlZjqo=
github.com/maximhq/maxim-go v0.1.3 h1:nVzdz3hEjZVxmWHARWIM+Yrn1Jp50qrsK4BA/sz2jj8=
github.com/maximhq/maxim-go v0.1.3/go.mod h1:0+UTWM7UZwNNE5VnljLtr/vpRGtYP8r/2q9WDwlLWFw=
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
Expand Down
9 changes: 7 additions & 2 deletions plugins/maxim/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,16 +142,21 @@ func (plugin *Plugin) PreHook(ctx *context.Context, req *schemas.BifrostRequest)
Role: string(message.Role),
Content: message.Content,
})
} else if message.ImageContent != nil {
} else if message.UserMessage != nil && message.UserMessage.ImageContent != nil {
messages = append(messages, logging.CompletionRequest{
Role: string(message.Role),
Content: message.ImageContent,
Content: message.UserMessage.ImageContent,
})
} else if message.ToolCalls != nil {
messages = append(messages, logging.CompletionRequest{
Role: string(message.Role),
Content: message.ToolCalls,
})
} else if message.ToolMessage != nil && message.ToolMessage.ToolCallID != nil {
messages = append(messages, logging.CompletionRequest{
Role: string(message.Role),
Content: message.ToolMessage,
})
}
}
if len(*req.Input.ChatCompletionInput) > 0 {
Expand Down
2 changes: 1 addition & 1 deletion plugins/maxim/plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func TestMaximLoggerPlugin(t *testing.T) {
Provider: schemas.OpenAI,
Model: "gpt-4o-mini",
Input: schemas.RequestInput{
ChatCompletionInput: &[]schemas.Message{
ChatCompletionInput: &[]schemas.BifrostMessage{
{
Role: "user",
Content: bifrost.Ptr("Hello, how are you?"),
Expand Down
18 changes: 12 additions & 6 deletions transports/bifrost-http/integrations/genai/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ package genai

import (
"encoding/json"
"fmt"

bifrost "github.com/maximhq/bifrost/core"
"github.com/maximhq/bifrost/core/schemas"
genai_sdk "google.golang.org/genai"
)

var fnTypePtr = bifrost.Ptr(string(schemas.ToolChoiceTypeFunction))

type GeminiChatRequest struct {
Contents []genai_sdk.Content `json:"contents"`
GenerationConfig genai_sdk.GenerationConfig `json:"generationConfig,omitempty"`
Expand Down Expand Up @@ -40,15 +43,18 @@ func (r *GeminiChatRequest) ConvertToBifrostRequest(modelStr string) *schemas.Bi
case part.FunctionCall != nil:
jsonArgs, err := json.Marshal(part.FunctionCall.Args)
if err != nil {
jsonArgs = []byte("{}")
jsonArgs = []byte(fmt.Sprintf("%v", part.FunctionCall.Args))
}
toolCalls := []schemas.ToolCall{
{
Type: bifrost.Ptr(string(schemas.ToolChoiceTypeFunction)),
Function: schemas.FunctionCall{
Name: &part.FunctionCall.Name,
Arguments: string(jsonArgs),
},
Type: fnTypePtr,
Function: func() schemas.FunctionCall {
nameCopy := part.FunctionCall.Name
return schemas.FunctionCall{
Name: &nameCopy,
Arguments: string(jsonArgs),
}
}(),
},
}
bifrostMsg.ToolCalls = &toolCalls
Expand Down
2 changes: 1 addition & 1 deletion transports/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.24.1

require (
github.com/fasthttp/router v1.5.4
github.com/maximhq/bifrost/core v1.1.0
github.com/maximhq/bifrost/core v1.0.9
github.com/maximhq/bifrost/plugins/maxim v1.0.2
github.com/prometheus/client_golang v1.22.0
github.com/valyala/fasthttp v1.62.0
Expand Down
4 changes: 2 additions & 2 deletions transports/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zt
github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ=
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
github.com/maximhq/bifrost/core v1.0.7 h1:+89Vq+FuD7FFZNbF161/FLBSFjAYLr4/UuWR8Do0Hyc=
github.com/maximhq/bifrost/core v1.0.7/go.mod h1:8aUSLGVdOhwxDzMcdQnSyMfSBA3lT05ICgX0b/VKc8g=
github.com/maximhq/bifrost/core v1.0.9 h1:OWUHCWCQsBH43YPIy2AsqNMZhoFXYe/qhJSCLbw5su8=
github.com/maximhq/bifrost/core v1.0.9/go.mod h1:8ycaWQ9bjQezoUT/x6a82VmPjoqLzyGglQ0RnnlZjqo=
github.com/maximhq/bifrost/plugins/maxim v1.0.2 h1:l+J+HL9Kag6I7at/YKwwnDHOGoyUcySHXanJXALtXg0=
github.com/maximhq/bifrost/plugins/maxim v1.0.2/go.mod h1:9jC7ZaI7+N+3XZxJ9rmjwn+pfXHMwBcZk/omvzhgbP0=
github.com/maximhq/maxim-go v0.1.3 h1:nVzdz3hEjZVxmWHARWIM+Yrn1Jp50qrsK4BA/sz2jj8=
Expand Down