MCPcopy Create free account
hub / github.com/aiprodcoder/MIXAPI / FetchTask

Method FetchTask

relay/channel/task/kling/adaptor.go:193–220  ·  view source on GitHub ↗

FetchTask fetch task status

(baseUrl, key string, body map[string]any)

Source from the content-addressed store, hash-verified

191
192// FetchTask fetch task status
193func (a *TaskAdaptor) FetchTask(baseUrl, key string, body map[string]any) (*http.Response, error) {
194 taskID, ok := body["task_id"].(string)
195 if !ok {
196 return nil, fmt.Errorf("invalid task_id")
197 }
198 action, ok := body["action"].(string)
199 if !ok {
200 return nil, fmt.Errorf("invalid action")
201 }
202 path := lo.Ternary(action == constant.TaskActionGenerate, "/v1/videos/image2video", "/v1/videos/text2video")
203 url := fmt.Sprintf("%s%s/%s", baseUrl, path, taskID)
204
205 req, err := http.NewRequest(http.MethodGet, url, nil)
206 if err != nil {
207 return nil, err
208 }
209
210 token, err := a.createJWTTokenWithKey(key)
211 if err != nil {
212 token = key
213 }
214
215 req.Header.Set("Accept", "application/json")
216 req.Header.Set("Authorization", "Bearer "+token)
217 req.Header.Set("User-Agent", "kling-sdk/1.0")
218
219 return service.GetHttpClient().Do(req)
220}
221
222func (a *TaskAdaptor) GetModelList() []string {
223 return []string{"kling-v1", "kling-v1-6", "kling-v2-master"}

Callers

nothing calls this directly

Implementers 3

TaskAdaptorrelay/channel/task/jimeng/adaptor.go
TaskAdaptorrelay/channel/task/suno/adaptor.go
TaskAdaptorrelay/channel/task/kling/adaptor.go

Calls 2

createJWTTokenWithKeyMethod · 0.95
GetHttpClientFunction · 0.92

Tested by

no test coverage detected