dashscope 1.15.0__py3-none-any.whl → 1.18.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of dashscope might be problematic. Click here for more details.

Files changed (56) hide show
  1. dashscope/__init__.py +57 -10
  2. dashscope/aigc/code_generation.py +12 -9
  3. dashscope/aigc/conversation.py +3 -0
  4. dashscope/aigc/generation.py +3 -0
  5. dashscope/aigc/image_synthesis.py +26 -6
  6. dashscope/aigc/multimodal_conversation.py +3 -0
  7. dashscope/api_entities/aiohttp_request.py +1 -0
  8. dashscope/api_entities/api_request_factory.py +28 -12
  9. dashscope/api_entities/dashscope_response.py +63 -0
  10. dashscope/api_entities/http_request.py +21 -31
  11. dashscope/api_entities/websocket_request.py +3 -0
  12. dashscope/app/application.py +16 -18
  13. dashscope/assistants/__init__.py +14 -0
  14. dashscope/assistants/assistant_types.py +164 -0
  15. dashscope/assistants/assistants.py +280 -0
  16. dashscope/assistants/files.py +189 -0
  17. dashscope/audio/asr/asr_phrase_manager.py +27 -5
  18. dashscope/audio/asr/recognition.py +10 -2
  19. dashscope/audio/asr/transcription.py +21 -3
  20. dashscope/audio/tts/speech_synthesizer.py +3 -0
  21. dashscope/cli.py +7 -7
  22. dashscope/client/base_api.py +317 -70
  23. dashscope/common/base_type.py +130 -0
  24. dashscope/common/constants.py +1 -0
  25. dashscope/common/error.py +4 -0
  26. dashscope/common/utils.py +159 -27
  27. dashscope/deployment.py +40 -6
  28. dashscope/embeddings/batch_text_embedding.py +24 -7
  29. dashscope/embeddings/multimodal_embedding.py +3 -0
  30. dashscope/embeddings/text_embedding.py +8 -1
  31. dashscope/files.py +107 -0
  32. dashscope/finetune.py +31 -7
  33. dashscope/model.py +9 -2
  34. dashscope/models.py +47 -0
  35. dashscope/nlp/understanding.py +2 -2
  36. dashscope/rerank/__init__.py +0 -0
  37. dashscope/rerank/text_rerank.py +67 -0
  38. dashscope/threads/__init__.py +24 -0
  39. dashscope/threads/messages/__init__.py +0 -0
  40. dashscope/threads/messages/files.py +111 -0
  41. dashscope/threads/messages/messages.py +218 -0
  42. dashscope/threads/runs/__init__.py +0 -0
  43. dashscope/threads/runs/runs.py +483 -0
  44. dashscope/threads/runs/steps.py +110 -0
  45. dashscope/threads/thread_types.py +651 -0
  46. dashscope/threads/threads.py +210 -0
  47. dashscope/tokenizers/tokenization.py +3 -0
  48. dashscope/utils/oss_utils.py +11 -0
  49. dashscope/version.py +1 -1
  50. {dashscope-1.15.0.dist-info → dashscope-1.18.0.dist-info}/METADATA +2 -3
  51. dashscope-1.18.0.dist-info/RECORD +84 -0
  52. dashscope-1.15.0.dist-info/RECORD +0 -66
  53. {dashscope-1.15.0.dist-info → dashscope-1.18.0.dist-info}/LICENSE +0 -0
  54. {dashscope-1.15.0.dist-info → dashscope-1.18.0.dist-info}/WHEEL +0 -0
  55. {dashscope-1.15.0.dist-info → dashscope-1.18.0.dist-info}/entry_points.txt +0 -0
  56. {dashscope-1.15.0.dist-info → dashscope-1.18.0.dist-info}/top_level.txt +0 -0
@@ -14,7 +14,11 @@ class TextEmbedding(BaseApi):
14
14
  text_embedding_v2 = 'text-embedding-v2'
15
15
 
16
16
  @classmethod
17
- def call(cls, model: str, input: Union[str, List[str]],
17
+ def call(cls,
18
+ model: str,
19
+ input: Union[str, List[str]],
20
+ workspace: str = None,
21
+ api_key: str = None,
18
22
  **kwargs) -> DashScopeAPIResponse:
19
23
  """Get embedding of text input.
20
24
 
@@ -24,6 +28,7 @@ class TextEmbedding(BaseApi):
24
28
  can be a text or list of text or opened file object,
25
29
  if opened file object, will read all lines,
26
30
  one embedding per line.
31
+ workspace (str): The dashscope workspace id.
27
32
  **kwargs:
28
33
  text_type(str, `optional`): query or document.
29
34
 
@@ -42,4 +47,6 @@ class TextEmbedding(BaseApi):
42
47
  task_group=task_group,
43
48
  task=TextEmbedding.task,
44
49
  function=function,
50
+ api_key=api_key,
51
+ workspace=workspace,
45
52
  **kwargs)
dashscope/files.py ADDED
@@ -0,0 +1,107 @@
1
+ import os
2
+
3
+ from dashscope.api_entities.dashscope_response import DashScopeAPIResponse
4
+ from dashscope.client.base_api import (DeleteMixin, FileUploadMixin, GetMixin,
5
+ ListMixin)
6
+ from dashscope.common.constants import FilePurpose
7
+ from dashscope.common.error import InvalidFileFormat
8
+ from dashscope.common.utils import is_validate_fine_tune_file
9
+
10
+
11
+ class Files(FileUploadMixin, ListMixin, DeleteMixin, GetMixin):
12
+ SUB_PATH = 'files'
13
+
14
+ @classmethod
15
+ def upload(cls,
16
+ file_path: str,
17
+ purpose: str = FilePurpose.fine_tune,
18
+ description: str = None,
19
+ api_key: str = None,
20
+ workspace: str = None,
21
+ **kwargs) -> DashScopeAPIResponse:
22
+ """Upload file for model fine-tune or other tasks.
23
+
24
+ Args:
25
+ file_path (str): The local file name to upload.
26
+ purpose (str): The purpose of the file[fine-tune|inference]
27
+ description (str, optional): The file description message.
28
+ api_key (str, optional): The api key. Defaults to None.
29
+ workspace (str): The dashscope workspace id.
30
+
31
+ Returns:
32
+ DashScopeAPIResponse: The upload information
33
+ """
34
+ if purpose == FilePurpose.fine_tune:
35
+ if not is_validate_fine_tune_file(file_path):
36
+ raise InvalidFileFormat(
37
+ 'The file %s is not in valid jsonl format' % file_path)
38
+ with open(file_path, 'rb') as f:
39
+ return super().upload(files=[('files', (os.path.basename(f.name),
40
+ f, None))],
41
+ descriptions=[description]
42
+ if description is not None else None,
43
+ api_key=api_key,
44
+ workspace=workspace,
45
+ **kwargs)
46
+
47
+ @classmethod
48
+ def list(cls,
49
+ page=1,
50
+ page_size=10,
51
+ api_key: str = None,
52
+ workspace: str = None,
53
+ **kwargs) -> DashScopeAPIResponse:
54
+ """List uploaded files.
55
+
56
+ Args:
57
+ api_key (str, optional):
58
+ The api api_key, can be None,
59
+ if None, will get by default rule(TODO: api key doc).
60
+ page (int, optional): Page number. Defaults to 1.
61
+ page_size (int, optional): Items per page. Defaults to 10.
62
+ workspace (str): The dashscope workspace id.
63
+
64
+ Returns:
65
+ DashScopeAPIResponse: The fine-tune jobs in the result.
66
+ """
67
+ return super().list(page,
68
+ page_size,
69
+ api_key,
70
+ workspace=workspace,
71
+ **kwargs)
72
+
73
+ @classmethod
74
+ def get(cls,
75
+ file_id: str,
76
+ api_key: str = None,
77
+ workspace: str = None,
78
+ **kwargs) -> DashScopeAPIResponse:
79
+ """Get the file info.
80
+
81
+ Args:
82
+ file_id (str): The file id.
83
+ api_key (str, optional): The api key. Defaults to None.
84
+ workspace (str): The dashscope workspace id.
85
+
86
+ Returns:
87
+ DashScopeAPIResponse: The job info
88
+ """
89
+ return super().get(file_id, api_key, workspace=workspace, **kwargs)
90
+
91
+ @classmethod
92
+ def delete(cls,
93
+ file_id: str,
94
+ api_key: str = None,
95
+ workspace: str = None,
96
+ **kwargs) -> DashScopeAPIResponse:
97
+ """Delete uploaded file.
98
+
99
+ Args:
100
+ file_id (str): The file id want to delete.
101
+ api_key (str, optional): The api key. Defaults to None.
102
+ workspace (str): The dashscope workspace id.
103
+
104
+ Returns:
105
+ DashScopeAPIResponse: Delete result.
106
+ """
107
+ return super().delete(file_id, api_key, workspace=workspace, **kwargs)
dashscope/finetune.py CHANGED
@@ -18,6 +18,7 @@ class FineTune(CreateMixin, CancelMixin, DeleteMixin, ListMixin,
18
18
  mode: str = None,
19
19
  hyper_parameters: dict = {},
20
20
  api_key: str = None,
21
+ workspace: str = None,
21
22
  **kwargs) -> DashScopeAPIResponse:
22
23
  """Create fine-tune job
23
24
 
@@ -31,6 +32,7 @@ class FineTune(CreateMixin, CancelMixin, DeleteMixin, ListMixin,
31
32
  hyper_parameters (dict, optional): The fine-tune hyper parameters.
32
33
  Defaults to empty.
33
34
  api_key (str, optional): The api key. Defaults to None.
35
+ workspace (str): The dashscope workspace id.
34
36
 
35
37
  Returns:
36
38
  DashScopeAPIResponse: The request result.
@@ -45,12 +47,16 @@ class FineTune(CreateMixin, CancelMixin, DeleteMixin, ListMixin,
45
47
  request['training_type'] = mode
46
48
  if 'finetuned_output' in kwargs:
47
49
  request['finetuned_output'] = kwargs['finetuned_output']
48
- return super().call(request, api_key, **kwargs)
50
+ return super().call(request,
51
+ api_key=api_key,
52
+ workspace=workspace,
53
+ **kwargs)
49
54
 
50
55
  @classmethod
51
56
  def cancel(cls,
52
57
  job_id: str,
53
58
  api_key: str = None,
59
+ workspace: str = None,
54
60
  **kwargs) -> DashScopeAPIResponse:
55
61
  """Cancel a running fine-tune job.
56
62
 
@@ -58,17 +64,19 @@ class FineTune(CreateMixin, CancelMixin, DeleteMixin, ListMixin,
58
64
  job_id (str): The fine-tune job id.
59
65
  api_key (str, optional): The api api_key, can be None,
60
66
  if None, will get by default rule(TODO: api key doc).
67
+ workspace (str): The dashscope workspace id.
61
68
 
62
69
  Returns:
63
70
  DashScopeAPIResponse: The request result.
64
71
  """
65
- return super().cancel(job_id, api_key, **kwargs)
72
+ return super().cancel(job_id, api_key, workspace=workspace, **kwargs)
66
73
 
67
74
  @classmethod
68
75
  def list(cls,
69
76
  page=1,
70
77
  page_size=10,
71
78
  api_key: str = None,
79
+ workspace: str = None,
72
80
  **kwargs) -> DashScopeAPIResponse:
73
81
  """List fine-tune job.
74
82
 
@@ -76,59 +84,73 @@ class FineTune(CreateMixin, CancelMixin, DeleteMixin, ListMixin,
76
84
  api_key (str, optional): The api key
77
85
  page (int, optional): Page number. Defaults to 1.
78
86
  page_size (int, optional): Items per page. Defaults to 10.
87
+ workspace (str): The dashscope workspace id.
79
88
 
80
89
  Returns:
81
90
  DashScopeAPIResponse: The fine-tune jobs in the result.
82
91
  """
83
- return super().list(page, page_size, api_key, **kwargs)
92
+ return super().list(page,
93
+ page_size,
94
+ api_key,
95
+ workspace=workspace,
96
+ **kwargs)
84
97
 
85
98
  @classmethod
86
99
  def get(cls,
87
100
  job_id: str,
88
101
  api_key: str = None,
102
+ workspace: str = None,
89
103
  **kwargs) -> DashScopeAPIResponse:
90
104
  """Get fine-tune job information.
91
105
 
92
106
  Args:
93
107
  job_id (str): The fine-tune job id
94
108
  api_key (str, optional): The api key. Defaults to None.
109
+ workspace (str): The dashscope workspace id.
95
110
 
96
111
  Returns:
97
112
  DashScopeAPIResponse: The job info
98
113
  """
99
- return super().get(job_id, api_key, **kwargs)
114
+ return super().get(job_id, api_key, workspace=workspace, **kwargs)
100
115
 
101
116
  @classmethod
102
117
  def delete(cls,
103
118
  job_id: str,
104
119
  api_key: str = None,
120
+ workspace: str = None,
105
121
  **kwargs) -> DashScopeAPIResponse:
106
122
  """Delete a fine-tune job.
107
123
 
108
124
  Args:
109
125
  job_id (str): The fine-tune job id.
110
126
  api_key (str, optional): The api key. Defaults to None.
127
+ workspace (str): The dashscope workspace id.
111
128
 
112
129
  Returns:
113
130
  DashScopeAPIResponse: The delete result.
114
131
  """
115
- return super().delete(job_id, api_key, **kwargs)
132
+ return super().delete(job_id, api_key, workspace=workspace, **kwargs)
116
133
 
117
134
  @classmethod
118
135
  def stream_events(cls,
119
136
  job_id: str,
120
137
  api_key: str = None,
138
+ workspace: str = None,
121
139
  **kwargs) -> DashScopeAPIResponse:
122
140
  """Get fine-tune job events.
123
141
 
124
142
  Args:
125
143
  job_id (str): The fine-tune job id
126
144
  api_key (str, optional): the api key. Defaults to None.
145
+ workspace (str): The dashscope workspace id.
127
146
 
128
147
  Returns:
129
148
  DashScopeAPIResponse: The job log events.
130
149
  """
131
- return super().stream_events(job_id, api_key, **kwargs)
150
+ return super().stream_events(job_id,
151
+ api_key,
152
+ workspace=workspace,
153
+ **kwargs)
132
154
 
133
155
  @classmethod
134
156
  def logs(cls,
@@ -136,6 +158,7 @@ class FineTune(CreateMixin, CancelMixin, DeleteMixin, ListMixin,
136
158
  offset=1,
137
159
  line=1000,
138
160
  api_key: str = None,
161
+ workspace: str = None,
139
162
  **kwargs) -> DashScopeAPIResponse:
140
163
  """Get log of the job.
141
164
 
@@ -144,8 +167,9 @@ class FineTune(CreateMixin, CancelMixin, DeleteMixin, ListMixin,
144
167
  offset (int, optional): start log line. Defaults to 1.
145
168
  line (int, optional): total line return. Defaults to 1000.
146
169
  api_key (str, optional): The api key. Defaults to None.
170
+ workspace (str): The dashscope workspace id.
147
171
 
148
172
  Returns:
149
173
  DashScopeAPIResponse: The response
150
174
  """
151
- return super().logs(job_id, offset, line)
175
+ return super().logs(job_id, offset, line, workspace=workspace)
dashscope/model.py CHANGED
@@ -9,23 +9,26 @@ class Model(ListMixin, GetMixin):
9
9
  def get(cls,
10
10
  name: str,
11
11
  api_key: str = None,
12
+ workspace: str = None,
12
13
  **kwargs) -> DashScopeAPIResponse:
13
14
  """Get the model information.
14
15
 
15
16
  Args:
16
17
  name (str): The model name.
17
18
  api_key (str, optional): The api key. Defaults to None.
19
+ workspace (str): The dashscope workspace id.
18
20
 
19
21
  Returns:
20
22
  DashScopeAPIResponse: The model information.
21
23
  """
22
- return super().get(name, api_key, **kwargs)
24
+ return super().get(name, api_key, workspace=workspace, **kwargs)
23
25
 
24
26
  @classmethod
25
27
  def list(cls,
26
28
  page=1,
27
29
  page_size=10,
28
30
  api_key: str = None,
31
+ workspace: str = None,
29
32
  **kwargs) -> DashScopeAPIResponse:
30
33
  """List models.
31
34
 
@@ -37,4 +40,8 @@ class Model(ListMixin, GetMixin):
37
40
  Returns:
38
41
  DashScopeAPIResponse: The models.
39
42
  """
40
- return super().list(api_key, page, page_size, **kwargs)
43
+ return super().list(api_key,
44
+ page,
45
+ page_size,
46
+ workspace=workspace,
47
+ **kwargs)
dashscope/models.py ADDED
@@ -0,0 +1,47 @@
1
+ from dashscope.api_entities.dashscope_response import DashScopeAPIResponse
2
+ from dashscope.client.base_api import GetMixin, ListMixin
3
+
4
+
5
+ class Model(ListMixin, GetMixin):
6
+ SUB_PATH = 'models'
7
+
8
+ @classmethod
9
+ def get(cls,
10
+ name: str,
11
+ api_key: str = None,
12
+ workspace: str = None,
13
+ **kwargs) -> DashScopeAPIResponse:
14
+ """Get the model information.
15
+
16
+ Args:
17
+ name (str): The model name.
18
+ api_key (str, optional): The api key. Defaults to None.
19
+ workspace (str): The dashscope workspace id.
20
+
21
+ Returns:
22
+ DashScopeAPIResponse: The model information.
23
+ """
24
+ return super().get(name, api_key, workspace=workspace, **kwargs)
25
+
26
+ @classmethod
27
+ def list(cls,
28
+ page=1,
29
+ page_size=10,
30
+ api_key: str = None,
31
+ workspace: str = None,
32
+ **kwargs) -> DashScopeAPIResponse:
33
+ """List models.
34
+
35
+ Args:
36
+ api_key (str, optional): The api key
37
+ page (int, optional): Page number. Defaults to 1.
38
+ page_size (int, optional): Items per page. Defaults to 10.
39
+
40
+ Returns:
41
+ DashScopeAPIResponse: The models.
42
+ """
43
+ return super().list(api_key,
44
+ page,
45
+ page_size,
46
+ workspace=workspace,
47
+ **kwargs)
@@ -25,8 +25,8 @@ class Understanding(BaseApi):
25
25
 
26
26
  Args:
27
27
  model (str): The requested model, such as opennlu-v1
28
- sentence (str): The text content entered by the user that needs to be processed supports both Chinese and English. (The maximum limit for input is 1024 tokens, which is the sum of all input fields).
29
- labels (list): For the extraction task, label is the name of the type that needs to be extracted. For classification tasks, label is the classification system. Separate different labels with Chinese commas..
28
+ sentence (str): The text content entered by the user that needs to be processed supports both Chinese and English. (The maximum limit for input is 1024 tokens, which is the sum of all input fields). # noqa E501
29
+ labels (list): For the extraction task, label is the name of the type that needs to be extracted. For classification tasks, label is the classification system. Separate different labels with Chinese commas.. # noqa E501
30
30
  task (str): Task type, optional as extraction or classification, default as extraction.
31
31
  api_key (str, optional): The api api_key, can be None,
32
32
  if None, will get by default rule(TODO: api key doc).
File without changes
@@ -0,0 +1,67 @@
1
+ from typing import List
2
+
3
+ from dashscope.api_entities.dashscope_response import ReRankResponse
4
+ from dashscope.client.base_api import BaseApi
5
+ from dashscope.common.error import InputRequired, ModelRequired
6
+ from dashscope.common.utils import _get_task_group_and_task
7
+
8
+
9
+ class TextReRank(BaseApi):
10
+ task = 'text-rerank'
11
+ """API for rerank models.
12
+
13
+ """
14
+ class Models:
15
+ gte_rerank = 'gte-rerank'
16
+
17
+ @classmethod
18
+ def call(cls,
19
+ model: str,
20
+ query: str,
21
+ documents: List[str],
22
+ return_documents: bool = None,
23
+ top_n: int = None,
24
+ api_key: str = None,
25
+ **kwargs) -> ReRankResponse:
26
+ """Calling rerank service.
27
+
28
+ Args:
29
+ model (str): The model to use.
30
+ query (str): The query string.
31
+ documents (List[str]): The documents to rank.
32
+ return_documents(bool, `optional`): enable return origin documents,
33
+ system default is false.
34
+ top_n(int, `optional`): how many documents to return, default return
35
+ all the documents.
36
+ api_key (str, optional): The DashScope api key. Defaults to None.
37
+
38
+ Raises:
39
+ InputRequired: The query and documents are required.
40
+ ModelRequired: The model is required.
41
+
42
+ Returns:
43
+ RerankResponse: The rerank result.
44
+ """
45
+
46
+ if query is None or documents is None or not documents:
47
+ raise InputRequired('query and documents are required!')
48
+ if model is None or not model:
49
+ raise ModelRequired('Model is required!')
50
+ task_group, function = _get_task_group_and_task(__name__)
51
+ input = {'query': query, 'documents': documents}
52
+ parameters = {}
53
+ if return_documents is not None:
54
+ parameters['return_documents'] = return_documents
55
+ if top_n is not None:
56
+ parameters['top_n'] = top_n
57
+ parameters = {**parameters, **kwargs}
58
+
59
+ response = super().call(model=model,
60
+ task_group=task_group,
61
+ task=TextReRank.task,
62
+ function=function,
63
+ api_key=api_key,
64
+ input=input,
65
+ **parameters)
66
+
67
+ return ReRankResponse.from_api_response(response)
@@ -0,0 +1,24 @@
1
+ # yapf: disable
2
+
3
+ from dashscope.threads.messages.messages import Messages
4
+ from dashscope.threads.runs.runs import Runs
5
+ from dashscope.threads.runs.steps import Steps
6
+ from dashscope.threads.thread_types import (MessageFile, Run, RunList, RunStep,
7
+ RunStepList, Thread, ThreadMessage,
8
+ ThreadMessageList)
9
+ from dashscope.threads.threads import Threads
10
+
11
+ __all__ = [
12
+ MessageFile,
13
+ Messages,
14
+ Run,
15
+ Runs,
16
+ RunList,
17
+ Steps,
18
+ RunStep,
19
+ RunStepList,
20
+ Threads,
21
+ Thread,
22
+ ThreadMessage,
23
+ ThreadMessageList,
24
+ ]
File without changes
@@ -0,0 +1,111 @@
1
+ from dashscope.client.base_api import GetStatusMixin, ListObjectMixin
2
+ from dashscope.common.error import InputRequired
3
+ from dashscope.threads.thread_types import MessageFile, MessageFileList
4
+
5
+ __all__ = ['Files']
6
+
7
+
8
+ class Files(ListObjectMixin, GetStatusMixin):
9
+ SUB_PATH = 'messages' # useless
10
+
11
+ @classmethod
12
+ def retrieve(cls,
13
+ file_id: str,
14
+ *,
15
+ thread_id: str,
16
+ message_id: str,
17
+ workspace: str = None,
18
+ api_key: str = None,
19
+ **kwargs) -> MessageFile:
20
+ """Retrieve the `MessageFile`.
21
+
22
+ Args:
23
+ thread_id (str): The thread id.
24
+ message_id (str): The message id.
25
+ file_id (str): The file id.
26
+ workspace (str): The dashscope workspace id.
27
+ api_key (str, optional): The api key. Defaults to None.
28
+
29
+ Returns:
30
+ MessageFile: The `MessageFile` object.
31
+ """
32
+ return cls.get(file_id,
33
+ thread_id=thread_id,
34
+ message_id=message_id,
35
+ workspace=workspace,
36
+ api_key=api_key,
37
+ **kwargs)
38
+
39
+ @classmethod
40
+ def get(cls,
41
+ file_id: str,
42
+ *,
43
+ message_id: str,
44
+ thread_id: str,
45
+ workspace: str = None,
46
+ api_key: str = None,
47
+ **kwargs) -> MessageFile:
48
+ """Retrieve the `MessageFile`.
49
+
50
+ Args:
51
+ assistant_id (str): The assistant id.
52
+ message_id (str): The message id.
53
+ file_id (str): The file id.
54
+ workspace (str): The dashscope workspace id.
55
+ api_key (str, optional): The api key. Defaults to None.
56
+
57
+ Returns:
58
+ MessageFile: The `MessageFile` object.
59
+ """
60
+ if not thread_id or not message_id or not file_id:
61
+ raise InputRequired(
62
+ 'thread id, message id and file id are required!')
63
+ response = super().get(
64
+ message_id,
65
+ path=f'threads/{thread_id}/messages/{message_id}/files/{file_id}',
66
+ workspace=workspace,
67
+ api_key=api_key,
68
+ flattened_output=True,
69
+ **kwargs)
70
+ return MessageFile(**response)
71
+
72
+ @classmethod
73
+ def list(cls,
74
+ message_id: str,
75
+ *,
76
+ thread_id: str,
77
+ limit: int = None,
78
+ order: str = None,
79
+ after: str = None,
80
+ before: str = None,
81
+ workspace: str = None,
82
+ api_key: str = None,
83
+ **kwargs) -> MessageFileList:
84
+ """List message files.
85
+
86
+ Args:
87
+ thread_id (str): The thread id.
88
+ message_id (str): The message_id.
89
+ limit (int, optional): How many assistant to retrieve. Defaults to None.
90
+ order (str, optional): Sort order by created_at. Defaults to None.
91
+ after (str, optional): Assistant id after. Defaults to None.
92
+ before (str, optional): Assistant id before. Defaults to None.
93
+ workspace (str, optional): The DashScope workspace id. Defaults to None.
94
+ api_key (str, optional): Your DashScope api key. Defaults to None.
95
+
96
+ Returns:
97
+ MessageFileList: The `MessageFileList`.
98
+ """
99
+ if not thread_id or not message_id:
100
+ raise InputRequired('thread id, message id are required!')
101
+ response = super().list(
102
+ limit=limit,
103
+ order=order,
104
+ after=after,
105
+ before=before,
106
+ path=f'threads/{thread_id}/messages/{message_id}/files',
107
+ workspace=workspace,
108
+ api_key=api_key,
109
+ flattened_output=True,
110
+ **kwargs)
111
+ return MessageFileList(**response)