Skip to content

Commit

Permalink
lint check
Browse files Browse the repository at this point in the history
  • Loading branch information
devinyf committed Feb 23, 2024
1 parent 08c8259 commit bed616c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 28 deletions.
1 change: 0 additions & 1 deletion qwen/uploader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ func TestGetUploadCertificate(t *testing.T) {

require.NoError(t, err)
require.NotNil(t, resp)

}
}

Expand Down
52 changes: 25 additions & 27 deletions tongyiclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand All @@ -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)
}
}

Expand Down

0 comments on commit bed616c

Please sign in to comment.