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
7 changes: 5 additions & 2 deletions core/providers/anthropic.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,11 @@ func buildAnthropicImageSourceMap(imgContent *schemas.ImageURLStruct) map[string
urlTypeInfo := ExtractURLTypeInfo(sanitizedURL)

formattedImgContent := AnthropicImageContent{
Type: urlTypeInfo.Type,
MediaType: *urlTypeInfo.MediaType,
Type: urlTypeInfo.Type,
}

if urlTypeInfo.MediaType != nil {
formattedImgContent.MediaType = *urlTypeInfo.MediaType
}

if urlTypeInfo.DataURLWithoutPrefix != nil {
Expand Down
7 changes: 5 additions & 2 deletions core/providers/bedrock.go
Original file line number Diff line number Diff line change
Expand Up @@ -522,8 +522,11 @@ func (provider *BedrockProvider) prepareChatCompletionMessages(messages []schema
urlTypeInfo := ExtractURLTypeInfo(sanitizedURL)

formattedImgContent := AnthropicImageContent{
Type: urlTypeInfo.Type,
MediaType: *urlTypeInfo.MediaType,
Type: urlTypeInfo.Type,
}

if urlTypeInfo.MediaType != nil {
formattedImgContent.MediaType = *urlTypeInfo.MediaType
}

if urlTypeInfo.DataURLWithoutPrefix != nil {
Expand Down
9 changes: 6 additions & 3 deletions core/providers/cohere.go
Original file line number Diff line number Diff line change
Expand Up @@ -459,9 +459,12 @@ func processImageContent(imageContent *schemas.ImageURLStruct) map[string]interf
urlTypeInfo := ExtractURLTypeInfo(sanitizedURL)

formattedImgContent := AnthropicImageContent{
Type: urlTypeInfo.Type,
URL: sanitizedURL,
MediaType: *urlTypeInfo.MediaType,
Type: urlTypeInfo.Type,
URL: sanitizedURL,
}

if urlTypeInfo.MediaType != nil {
formattedImgContent.MediaType = *urlTypeInfo.MediaType
}
Comment thread
Pratham-Mishra04 marked this conversation as resolved.

return map[string]interface{}{
Expand Down
2 changes: 1 addition & 1 deletion core/providers/openai.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ func prepareOpenAIChatRequest(messages []schemas.BifrostMessage, params *schemas
if msg.Role == schemas.ModelChatMessageRoleAssistant {
assistantMessage := map[string]interface{}{
"role": msg.Role,
"content": coalesceString(msg.Content.ContentStr),
"content": msg.Content,
}
Comment thread
Pratham-Mishra04 marked this conversation as resolved.
if msg.AssistantMessage != nil && msg.AssistantMessage.ToolCalls != nil {
assistantMessage["tool_calls"] = *msg.AssistantMessage.ToolCalls
Expand Down
9 changes: 0 additions & 9 deletions core/providers/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,15 +338,6 @@ func StrPtr(s string) *string {
return &s
}

// coalesceString returns the string value of a pointer to a string, or an empty string if the pointer is nil.
// This is a helper function for safely handling pointer-to-string values.
func coalesceString(s *string) string {
if s == nil {
return ""
}
return *s
}

//* IMAGE UTILS *//

// SanitizeImageURL sanitizes and validates an image URL.
Expand Down