feat: add checks for non-empty URLs in file metadata processing
This commit is contained in:
@@ -115,12 +115,14 @@ func (r *GeneralOpenAIRequest) GetTokenCountMeta() *types.TokenCountMeta {
|
|||||||
if m.Type == ContentTypeImageURL {
|
if m.Type == ContentTypeImageURL {
|
||||||
imageUrl := m.GetImageMedia()
|
imageUrl := m.GetImageMedia()
|
||||||
if imageUrl != nil {
|
if imageUrl != nil {
|
||||||
meta := &types.FileMeta{
|
if imageUrl.Url != "" {
|
||||||
FileType: types.FileTypeImage,
|
meta := &types.FileMeta{
|
||||||
|
FileType: types.FileTypeImage,
|
||||||
|
}
|
||||||
|
meta.OriginData = imageUrl.Url
|
||||||
|
meta.Detail = imageUrl.Detail
|
||||||
|
fileMeta = append(fileMeta, meta)
|
||||||
}
|
}
|
||||||
meta.OriginData = imageUrl.Url
|
|
||||||
meta.Detail = imageUrl.Detail
|
|
||||||
fileMeta = append(fileMeta, meta)
|
|
||||||
}
|
}
|
||||||
} else if m.Type == ContentTypeInputAudio {
|
} else if m.Type == ContentTypeInputAudio {
|
||||||
inputAudio := m.GetInputAudio()
|
inputAudio := m.GetInputAudio()
|
||||||
@@ -142,7 +144,7 @@ func (r *GeneralOpenAIRequest) GetTokenCountMeta() *types.TokenCountMeta {
|
|||||||
}
|
}
|
||||||
} else if m.Type == ContentTypeVideoUrl {
|
} else if m.Type == ContentTypeVideoUrl {
|
||||||
videoUrl := m.GetVideoUrl()
|
videoUrl := m.GetVideoUrl()
|
||||||
if videoUrl != nil {
|
if videoUrl != nil && videoUrl.Url != "" {
|
||||||
meta := &types.FileMeta{
|
meta := &types.FileMeta{
|
||||||
FileType: types.FileTypeVideo,
|
FileType: types.FileTypeVideo,
|
||||||
}
|
}
|
||||||
@@ -783,16 +785,20 @@ func (r *OpenAIResponsesRequest) GetTokenCountMeta() *types.TokenCountMeta {
|
|||||||
inputs := r.ParseInput()
|
inputs := r.ParseInput()
|
||||||
for _, input := range inputs {
|
for _, input := range inputs {
|
||||||
if input.Type == "input_image" {
|
if input.Type == "input_image" {
|
||||||
fileMeta = append(fileMeta, &types.FileMeta{
|
if input.ImageUrl != "" {
|
||||||
FileType: types.FileTypeImage,
|
fileMeta = append(fileMeta, &types.FileMeta{
|
||||||
OriginData: input.ImageUrl,
|
FileType: types.FileTypeImage,
|
||||||
Detail: input.Detail,
|
OriginData: input.ImageUrl,
|
||||||
})
|
Detail: input.Detail,
|
||||||
|
})
|
||||||
|
}
|
||||||
} else if input.Type == "input_file" {
|
} else if input.Type == "input_file" {
|
||||||
fileMeta = append(fileMeta, &types.FileMeta{
|
if input.FileUrl != "" {
|
||||||
FileType: types.FileTypeFile,
|
fileMeta = append(fileMeta, &types.FileMeta{
|
||||||
OriginData: input.FileUrl,
|
FileType: types.FileTypeFile,
|
||||||
})
|
OriginData: input.FileUrl,
|
||||||
|
})
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
texts = append(texts, input.Text)
|
texts = append(texts, input.Text)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user