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
2 changes: 2 additions & 0 deletions core/providers/anthropic.go
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,8 @@ func prepareAnthropicChatRequest(messages []schemas.BifrostMessage, params *sche
if params != nil && params.ToolChoice != nil {
switch toolChoice := params.ToolChoice.Type; toolChoice {
case schemas.ToolChoiceTypeFunction:
fallthrough
case "tool":
preparedParams["tool_choice"] = map[string]interface{}{
"type": "tool",
"name": params.ToolChoice.Function.Name,
Expand Down
39 changes: 39 additions & 0 deletions transports/bifrost-http/integrations/anthropic/router.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package anthropic

import (
bifrost "github.com/maximhq/bifrost/core"
"github.com/maximhq/bifrost/core/schemas"
"github.com/maximhq/bifrost/transports/bifrost-http/integrations"
)

// AnthropicRouter holds route registrations for Anthropic endpoints.
// It supports standard chat completions and image-enabled vision capabilities.
type AnthropicRouter struct {
*integrations.GenericRouter
}

// NewAnthropicRouter creates a new AnthropicRouter with the given bifrost client.
func NewAnthropicRouter(client *bifrost.Bifrost) *AnthropicRouter {
routes := []integrations.RouteConfig{
{
Path: "/anthropic/v1/messages",
Method: "POST",
GetRequestTypeInstance: func() interface{} {
return &AnthropicMessageRequest{}
},
RequestConverter: func(req interface{}) *schemas.BifrostRequest {
Comment thread
Pratham-Mishra04 marked this conversation as resolved.
if anthropicReq, ok := req.(*AnthropicMessageRequest); ok {
return anthropicReq.ConvertToBifrostRequest()
}
return nil
},
ResponseFunc: func(resp *schemas.BifrostResponse) interface{} {
return DeriveAnthropicFromBifrostResponse(resp)
},
},
Comment thread
Pratham-Mishra04 marked this conversation as resolved.
Comment thread
Pratham-Mishra04 marked this conversation as resolved.
}

return &AnthropicRouter{
GenericRouter: integrations.NewGenericRouter(client, routes),
}
}
Loading