Skip to content

Commit 025f8a9

Browse files
fix: minor type fixes
1 parent 5f6b769 commit 025f8a9

File tree

18 files changed

+342
-1490
lines changed

18 files changed

+342
-1490
lines changed

core/schemas/chatcompletions.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ type ChatParameters struct {
1414
LogProbs *bool `json:"logprobs,omitempty"` // Number of logprobs to return
1515
MaxCompletionTokens *int `json:"max_completion_tokens,omitempty"` // Maximum number of tokens to generate
1616
Metadata *map[string]any `json:"metadata,omitempty"` // Metadata to be returned with the response
17-
Modalities []string `json:"modalities,omitempty"` // Modalities to be returned with the response
17+
Modalities []string `json:"modalities,omitempty"` // Modalities to be returned with the response
1818
ParallelToolCalls *bool `json:"parallel_tool_calls,omitempty"`
1919
PresencePenalty *float64 `json:"presence_penalty,omitempty"` // Penalizes repeated tokens
2020
PromptCacheKey *string `json:"prompt_cache_key,omitempty"` // Prompt cache key
@@ -24,7 +24,7 @@ type ChatParameters struct {
2424
Seed *int `json:"seed,omitempty"`
2525
ServiceTier *string `json:"service_tier,omitempty"`
2626
StreamOptions *ChatStreamOptions `json:"stream_options,omitempty"`
27-
Stop []string `json:"stop,omitempty"`
27+
Stop []string `json:"stop,omitempty"`
2828
Store *bool `json:"store,omitempty"`
2929
Temperature *float64 `json:"temperature,omitempty"`
3030
TopLogProbs *int `json:"top_logprobs,omitempty"`
@@ -71,7 +71,7 @@ type ToolFunctionParameters struct {
7171
Description *string `json:"description,omitempty"` // Description of the parameters
7272
Required []string `json:"required,omitempty"` // Required parameter names
7373
Properties map[string]interface{} `json:"properties,omitempty"` // Parameter properties
74-
Enum []string `json:"enum,omitempty"` // Enum values for the parameters
74+
Enum []string `json:"enum,omitempty"` // Enum values for the parameters
7575
}
7676

7777
type ChatToolCustom struct {
@@ -89,7 +89,7 @@ type ChatToolCustomGrammarFormat struct {
8989
Syntax string `json:"syntax"` // "lark" | "regex"
9090
}
9191

92-
// Combined tool choices for all providers, make sure to check the provider's
92+
// ChatToolChoiceType for all providers, make sure to check the provider's
9393
// documentation to see which tool choices are supported.
9494
type ChatToolChoiceType string
9595

@@ -178,7 +178,7 @@ type ChatToolChoiceAllowedToolsTool struct {
178178

179179
// MESSAGES
180180

181-
// ModelChatMessageRole represents the role of a chat message
181+
// ChatMessageRole represents the role of a chat message
182182
type ChatMessageRole string
183183

184184
const (
@@ -296,7 +296,7 @@ type ChatToolMessage struct {
296296
type ChatAssistantMessage struct {
297297
Refusal *string `json:"refusal,omitempty"`
298298
Annotations []ChatAssistantMessageAnnotation `json:"annotations,omitempty"`
299-
ToolCalls []ChatAssistantMessageToolCall `json:"tool_calls,omitempty"`
299+
ToolCalls []ChatAssistantMessageToolCall `json:"tool_calls,omitempty"`
300300
}
301301

302302
// ChatAssistantMessageAnnotation represents an annotation in a response.

core/schemas/providers/anthropic/chat.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -780,16 +780,12 @@ func ToAnthropicChatCompletionError(bifrostErr *schemas.BifrostError) *Anthropic
780780

781781
// Handle nested error fields with nil checks
782782
errorStruct := AnthropicMessageErrorStruct{
783-
Type: "",
783+
Type: errorType,
784784
Message: bifrostErr.Error.Message,
785785
}
786786

787-
if bifrostErr.Error.Type != nil {
788-
errorStruct.Type = *bifrostErr.Error.Type
789-
}
790-
791787
return &AnthropicMessageError{
792-
Type: errorType,
788+
Type: "error", // always "error" for Anthropic
793789
Error: errorStruct,
794790
}
795791
}

core/schemas/providers/anthropic/responses.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ func ToAnthropicResponsesRequest(bifrostReq *schemas.BifrostResponsesRequest) *A
129129
if ok {
130130
anthropicReq.TopK = topK
131131
}
132-
if stop, ok := schemas.SafeExtractStringSlicePointer(bifrostReq.Params.ExtraParams["stop"]); ok {
132+
if stop, ok := schemas.SafeExtractStringSlice(bifrostReq.Params.ExtraParams["stop"]); ok {
133133
anthropicReq.StopSequences = stop
134134
}
135135
}
@@ -891,7 +891,7 @@ func convertBifrostMessagesToAnthropicContent(messages []schemas.ResponsesMessag
891891
})
892892
} else if msg.Content.ContentBlocks != nil {
893893
// Convert content blocks
894-
for _, block := range msg.Content.ContentBlocks {
894+
for _, block := range msg.Content.ContentBlocks {
895895
anthropicBlock := convertContentBlockToAnthropic(block)
896896
if anthropicBlock != nil {
897897
contentBlocks = append(contentBlocks, *anthropicBlock)

core/schemas/providers/bedrock/responses.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func ToBedrockResponsesRequest(bifrostReq *schemas.BifrostResponsesRequest) (*Be
4444
inferenceConfig.TopP = bifrostReq.Params.TopP
4545
}
4646
if bifrostReq.Params.ExtraParams != nil {
47-
if stop, ok := schemas.SafeExtractStringSlicePointer(bifrostReq.Params.ExtraParams["stop"]); ok {
47+
if stop, ok := schemas.SafeExtractStringSlice(bifrostReq.Params.ExtraParams["stop"]); ok {
4848
inferenceConfig.StopSequences = stop
4949
}
5050
}

core/schemas/providers/cohere/responses.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func ToCohereResponsesRequest(bifrostReq *schemas.BifrostResponsesRequest) *Cohe
3232
if topK, ok := schemas.SafeExtractIntPointer(bifrostReq.Params.ExtraParams["top_k"]); ok {
3333
cohereReq.K = topK
3434
}
35-
if stop, ok := schemas.SafeExtractStringSlicePointer(bifrostReq.Params.ExtraParams["stop"]); ok {
35+
if stop, ok := schemas.SafeExtractStringSlice(bifrostReq.Params.ExtraParams["stop"]); ok {
3636
cohereReq.StopSequences = stop
3737
}
3838
if frequencyPenalty, ok := schemas.SafeExtractFloat64Pointer(bifrostReq.Params.ExtraParams["frequency_penalty"]); ok {

core/schemas/utils.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -510,17 +510,6 @@ func SafeExtractBoolPointer(value interface{}) (*bool, bool) {
510510
return nil, false
511511
}
512512

513-
// SafeExtractStringSlicePointer safely extracts a []string value from an interface{} with type checking
514-
func SafeExtractStringSlicePointer(value interface{}) ([]string, bool) {
515-
if value == nil {
516-
return nil, false
517-
}
518-
if sliceVal, ok := SafeExtractStringSlice(value); ok {
519-
return sliceVal, true
520-
}
521-
return nil, false
522-
}
523-
524513
// SafeExtractFromMap safely extracts a value from a map[string]interface{} with type checking
525514
func SafeExtractFromMap(m map[string]interface{}, key string) (interface{}, bool) {
526515
if m == nil {

plugins/logging/go.mod

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ go 1.24
55
toolchain go1.24.3
66

77
require (
8-
github.com/bytedance/sonic v1.14.0
98
github.com/maximhq/bifrost/core v1.1.37
109
github.com/maximhq/bifrost/framework v1.0.23
1110
)
1211

1312
require (
13+
cloud.google.com/go/compute/metadata v0.8.0 // indirect
14+
github.com/andybalholm/brotli v1.2.0 // indirect
1415
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
1516
github.com/aws/aws-sdk-go-v2 v1.38.0 // indirect
1617
github.com/aws/aws-sdk-go-v2/config v1.31.0 // indirect
@@ -27,6 +28,7 @@ require (
2728
github.com/aws/smithy-go v1.22.5 // indirect
2829
github.com/bahlo/generic-list-go v0.2.0 // indirect
2930
github.com/buger/jsonparser v1.1.1 // indirect
31+
github.com/bytedance/sonic v1.14.0 // indirect
3032
github.com/bytedance/sonic/loader v0.3.0 // indirect
3133
github.com/cespare/xxhash/v2 v2.3.0 // indirect
3234
github.com/cloudwego/base64x v0.1.6 // indirect
@@ -42,20 +44,31 @@ require (
4244
github.com/go-openapi/swag v0.23.0 // indirect
4345
github.com/go-openapi/validate v0.24.0 // indirect
4446
github.com/google/uuid v1.6.0 // indirect
47+
github.com/invopop/jsonschema v0.13.0 // indirect
4548
github.com/jinzhu/inflection v1.0.0 // indirect
4649
github.com/jinzhu/now v1.1.5 // indirect
4750
github.com/josharian/intern v1.0.0 // indirect
51+
github.com/klauspost/compress v1.18.0 // indirect
4852
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
4953
github.com/mailru/easyjson v0.9.0 // indirect
54+
github.com/mark3labs/mcp-go v0.37.0 // indirect
55+
github.com/mattn/go-colorable v0.1.14 // indirect
56+
github.com/mattn/go-isatty v0.0.20 // indirect
5057
github.com/mattn/go-sqlite3 v1.14.32 // indirect
5158
github.com/mitchellh/mapstructure v1.5.0 // indirect
5259
github.com/oklog/ulid v1.3.1 // indirect
5360
github.com/opentracing/opentracing-go v1.2.0 // indirect
5461
github.com/pkg/errors v0.9.1 // indirect
5562
github.com/redis/go-redis/v9 v9.12.1 // indirect
63+
github.com/rs/zerolog v1.34.0 // indirect
64+
github.com/spf13/cast v1.9.2 // indirect
5665
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
66+
github.com/valyala/bytebufferpool v1.0.0 // indirect
67+
github.com/valyala/fasthttp v1.65.0 // indirect
5768
github.com/weaviate/weaviate v1.31.5 // indirect
5869
github.com/weaviate/weaviate-go-client/v5 v5.2.0 // indirect
70+
github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect
71+
github.com/yosida95/uritemplate/v3 v3.0.2 // indirect
5972
go.mongodb.org/mongo-driver v1.14.0 // indirect
6073
golang.org/x/arch v0.20.0 // indirect
6174
golang.org/x/net v0.43.0 // indirect

plugins/logging/go.sum

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
cloud.google.com/go v0.121.0 h1:pgfwva8nGw7vivjZiRfrmglGWiCJBP+0OmDpenG/Fwg=
21
cloud.google.com/go/compute/metadata v0.8.0 h1:HxMRIbao8w17ZX6wBnjhcDkW6lTFpgcaobyVfZWqRLA=
32
cloud.google.com/go/compute/metadata v0.8.0/go.mod h1:sYOGTp851OV9bOFJ9CH7elVvyzopvWQFNNghtDQ/Biw=
43
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
@@ -60,6 +59,7 @@ github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8Yc
6059
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
6160
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
6261
github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
62+
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
6363
github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
6464
github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
6565
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
@@ -247,6 +247,7 @@ github.com/wk8/go-ordered-map/v2 v2.1.8/go.mod h1:5nJHM5DyteebpVlHnWMV0rPz6Zp7+x
247247
github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI=
248248
github.com/xdg-go/scram v1.0.2/go.mod h1:1WAq6h33pAW+iRreB34OORO2Nf7qel3VV3fjBj+hCSs=
249249
github.com/xdg-go/stringprep v1.0.2/go.mod h1:8F9zXuvzgwmyT5DUm4GUfZGDdT3W+LCvS6+da4O5kxM=
250+
github.com/xyproto/randomstring v1.0.5 h1:YtlWPoRdgMu3NZtP45drfy1GKoojuR7hmRcnhZqKjWU=
250251
github.com/yosida95/uritemplate/v3 v3.0.2 h1:Ed3Oyj9yrmi9087+NczuL5BwkIc4wvTb5zIM+UJPGz4=
251252
github.com/yosida95/uritemplate/v3 v3.0.2/go.mod h1:ILOh0sOhIJR3+L/8afwt/kE++YT040gmv5BQTMR2HP4=
252253
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA=

0 commit comments

Comments
 (0)