diff --git a/qwen/uploader_test.go b/qwen/uploader_test.go index 6815fb1..0452d35 100644 --- a/qwen/uploader_test.go +++ b/qwen/uploader_test.go @@ -34,7 +34,6 @@ func TestGetUploadCertificate(t *testing.T) { require.NoError(t, err) require.NotNil(t, resp) - } } diff --git a/tongyiclient.go b/tongyiclient.go index b82a84d..1920981 100644 --- a/tongyiclient.go +++ b/tongyiclient.go @@ -44,22 +44,20 @@ func (q *TongyiClient) CreateCompletion(ctx context.Context, payload *qwen.Reque //nolint:lll func (q *TongyiClient) CreateVLCompletion(ctx context.Context, payload *qwen.Request[*qwen.VLContentList], url string) (*VLQwenResponse, error) { payload = paylosdPreCheck(q, payload) - // Uploading URL... - // fmt.Println("upload images...") + for _, vMsg := range payload.Input.Messages { - if vMsg.Role == "user" { - if tmpImageContent, hasImg := vMsg.Content.PopImageContent(); hasImg { - filepath := tmpImageContent.Image - - ossURL, hasUploadOss, err := checkIfNeedUploadFile(ctx, filepath, payload.Model, q.token) - if err != nil { - return nil, err - } - if hasUploadOss { - payload.HasUploadOss = true - } - vMsg.Content.SetImage(ossURL) + tmpImageContent, hasImg := vMsg.Content.PopImageContent() + if hasImg && vMsg.Role == "user" { + filepath := tmpImageContent.Image + + ossURL, hasUploadOss, err := checkIfNeedUploadFile(ctx, filepath, payload.Model, q.token) + if err != nil { + return nil, err } + if hasUploadOss { + payload.HasUploadOss = true + } + vMsg.Content.SetImage(ossURL) } } @@ -70,20 +68,20 @@ func (q *TongyiClient) CreateVLCompletion(ctx context.Context, payload *qwen.Req func (q *TongyiClient) CreateAudioCompletion(ctx context.Context, payload *qwen.Request[*qwen.AudioContentList], url string) (*AudioQwenResponse, error) { payload = paylosdPreCheck(q, payload) for _, acMsg := range payload.Input.Messages { - if acMsg.Role == "user" { - if tmpAudioContent, hasAudio := acMsg.Content.PopAudioContent(); hasAudio { - filepath := tmpAudioContent.Audio - - ossURL, hasUploadOss, err := checkIfNeedUploadFile(ctx, filepath, payload.Model, q.token) - if err != nil { - return nil, err - } - - if hasUploadOss { - payload.HasUploadOss = true - } - acMsg.Content.SetAudio(ossURL) + tmpAudioContent, hasAudio := acMsg.Content.PopAudioContent() + + if hasAudio && acMsg.Role == "user" { + filepath := tmpAudioContent.Audio + + ossURL, hasUploadOss, err := checkIfNeedUploadFile(ctx, filepath, payload.Model, q.token) + if err != nil { + return nil, err + } + + if hasUploadOss { + payload.HasUploadOss = true } + acMsg.Content.SetAudio(ossURL) } }