dashscope 1.20.4__py3-none-any.whl → 1.20.6__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.

@@ -98,6 +98,7 @@ class Application(BaseApi):
98
98
  doc_reference_type(str, `optional`): The type of doc reference.
99
99
  simple: simple format of doc retrival which not include index in response text but in doc reference list.
100
100
  indexed: include both index in response text and doc reference list
101
+ memory_id(str, `optional`): Used to store long term context summary between end users and assistant.
101
102
  Raises:
102
103
  InvalidInput: The history and auto_history are mutually exclusive.
103
104
 
@@ -160,6 +161,10 @@ class Application(BaseApi):
160
161
  else:
161
162
  raise InvalidInput('doc_tag_codes is not a List[str]')
162
163
 
164
+ memory_id = kwargs.pop('memory_id', None)
165
+ if memory_id is not None:
166
+ input_param['memory_id'] = memory_id
167
+
163
168
  biz_params = kwargs.pop('biz_params', None)
164
169
  if biz_params is not None and biz_params:
165
170
  input_param['biz_params'] = biz_params
dashscope/common/utils.py CHANGED
@@ -207,7 +207,7 @@ class SSEEvent:
207
207
  def _handle_stream(response: requests.Response):
208
208
  # TODO define done message.
209
209
  is_error = False
210
- status_code = HTTPStatus.INTERNAL_SERVER_ERROR
210
+ status_code = HTTPStatus.BAD_REQUEST
211
211
  event = SSEEvent(None, None, None)
212
212
  eventType = None
213
213
  for line in response.iter_lines():
@@ -124,34 +124,36 @@ def upload_file(model: str, upload_path: str, api_key: str):
124
124
  def check_and_upload(model, elem: dict, api_key):
125
125
  is_upload = False
126
126
  for key, content in elem.items():
127
- if content.startswith(FILE_PATH_SCHEMA):
128
- parse_result = urlparse(content)
129
- if parse_result.netloc:
130
- file_path = parse_result.netloc + unquote_plus(
131
- parse_result.path)
132
- else:
133
- file_path = unquote_plus(parse_result.path)
134
- if os.path.exists(file_path):
135
- file_url = OssUtils.upload(model=model,
136
- file_path=file_path,
137
- api_key=api_key)
138
- if file_url is None:
139
- raise UploadFileException('Uploading file: %s failed' %
140
- content)
141
- elem[key] = file_url
142
- is_upload = True
143
- else:
144
- raise InvalidInput('The file: %s is not exists!' % file_path)
145
- elif not content.startswith('http'):
146
- if os.path.exists(content):
147
- file_url = OssUtils.upload(model=model,
148
- file_path=content,
149
- api_key=api_key)
150
- if file_url is None:
151
- raise UploadFileException('Uploading file: %s failed' %
152
- content)
153
- elem[key] = file_url
154
- is_upload = True
127
+ if key in ['image', 'video', 'audio', 'text']:
128
+ if content.startswith(FILE_PATH_SCHEMA):
129
+ parse_result = urlparse(content)
130
+ if parse_result.netloc:
131
+ file_path = parse_result.netloc + unquote_plus(
132
+ parse_result.path)
133
+ else:
134
+ file_path = unquote_plus(parse_result.path)
135
+ if os.path.exists(file_path):
136
+ file_url = OssUtils.upload(model=model,
137
+ file_path=file_path,
138
+ api_key=api_key)
139
+ if file_url is None:
140
+ raise UploadFileException('Uploading file: %s failed' %
141
+ content)
142
+ elem[key] = file_url
143
+ is_upload = True
144
+ else:
145
+ raise InvalidInput('The file: %s is not exists!' %
146
+ file_path)
147
+ elif not content.startswith('http'):
148
+ if os.path.exists(content):
149
+ file_url = OssUtils.upload(model=model,
150
+ file_path=content,
151
+ api_key=api_key)
152
+ if file_url is None:
153
+ raise UploadFileException('Uploading file: %s failed' %
154
+ content)
155
+ elem[key] = file_url
156
+ is_upload = True
155
157
 
156
158
  return is_upload
157
159
 
dashscope/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = '1.20.4'
1
+ __version__ = '1.20.6'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dashscope
3
- Version: 1.20.4
3
+ Version: 1.20.6
4
4
  Summary: dashscope client sdk library
5
5
  Home-page: https://dashscope.aliyun.com/
6
6
  Author: Alibaba Cloud
@@ -18,6 +18,7 @@ Classifier: Programming Language :: Python :: 3.10
18
18
  Classifier: Programming Language :: Python :: 3.11
19
19
  Requires-Python: >=3.8.0
20
20
  Description-Content-Type: text/markdown
21
+ License-File: LICENSE
21
22
  Requires-Dist: aiohttp
22
23
  Requires-Dist: requests
23
24
  Requires-Dist: websocket-client
@@ -221,5 +222,3 @@ Coming soon.
221
222
 
222
223
  ## License
223
224
  This project is licensed under the Apache License (Version 2.0).
224
-
225
-
@@ -1,12 +1,9 @@
1
1
  dashscope/__init__.py,sha256=lIBZR5fWUiO1L62J_17Gri7Dwk9kCf2xhWl8eRw8bkQ,2933
2
2
  dashscope/cli.py,sha256=amegoTkGOs6TlHMdoo4JVOqBePo3lGs745rc7leEyrE,24020
3
- dashscope/deployment.py,sha256=ljmVi-ny6SjEs8v4oIGNWIw8UQTorE7dl5QJv7dEPIQ,5728
4
- dashscope/file.py,sha256=Dv2Fz3DLbcye2uuQxyQwRM7ky27OthouLXIpSQagQy4,3324
5
3
  dashscope/files.py,sha256=QgJjwhtn9F548nCA8jD8OvE6aQEj-20hZqJgYXsUdQU,3930
6
- dashscope/finetune.py,sha256=_tflDUvu0KagSoCzLaf0hofpG_P8NU6PylL8CPjVhrA,6243
7
4
  dashscope/model.py,sha256=UPOn1qMYFhX-ovXi3BMxZEBk8qOK7WLJOYHMbPZwYBo,1440
8
5
  dashscope/models.py,sha256=1-bc-Ue68zurgu_y6RhfFr9uzeQMF5AZq-C32lJGMGU,1224
9
- dashscope/version.py,sha256=F9uXsS9G7U6denIIAr8vp6GOvDWEm4lYN6mAx36-rZE,23
6
+ dashscope/version.py,sha256=6axGZRlohq7vksayxvwN9xJ80lUuSFmXPRMwGYpne_w,23
10
7
  dashscope/aigc/__init__.py,sha256=s-MCA87KYiVumYtKtJi5IMN7xelSF6TqEU3s3_7RF-Y,327
11
8
  dashscope/aigc/code_generation.py,sha256=KAJVrGp6tiNFBBg64Ovs9RfcP5SrIhrbW3wdA89NKso,10885
12
9
  dashscope/aigc/conversation.py,sha256=xRoJlCR-IXHjSdkDrK74a9ut1FJg0FZhTNXZAJC18MA,14231
@@ -22,7 +19,7 @@ dashscope/api_entities/dashscope_response.py,sha256=Bp1T7HwVlkOvpMNg-AEjz-BScxhL
22
19
  dashscope/api_entities/http_request.py,sha256=pYE8qRMu9CaQDiugPlXeYoaj_diBv-ZDExCD3WNhehI,13259
23
20
  dashscope/api_entities/websocket_request.py,sha256=Xr6IJ9WqrIw5ouBQLpgoRSwL1C09jkb4u1EZdxhVQy0,15039
24
21
  dashscope/app/__init__.py,sha256=UiN_9i--z84Dw5wUehOh_Tkk_9Gq_td_Kbz1dobBEKg,62
25
- dashscope/app/application.py,sha256=AegGVsk3dDzYACoYRNNjo3eG-2wrDd0dlOjYHpF0r2Y,7949
22
+ dashscope/app/application.py,sha256=uIWVEupscDGpUl7t6b8JZeTTlCaCQA1bznI_QdxNrj8,8200
26
23
  dashscope/app/application_response.py,sha256=U5I8Yb1IlXzj2L5a1OAl55i0MCB3kG9Qp4aY17_73pI,6886
27
24
  dashscope/assistants/__init__.py,sha256=i9N5OxHgY7edlOhTdPyC0N5Uc0uMCkB2vbMPDCD1zX0,383
28
25
  dashscope/assistants/assistant_types.py,sha256=1jNL30TOlrkiYhvCaB3E8jkPLG8CnQ6I3tHpYXZCsD0,4211
@@ -47,7 +44,7 @@ dashscope/common/env.py,sha256=oQOZW5JyEeTSde394un2lpDJ5RBh4fMU9hBfbtrKKkc,869
47
44
  dashscope/common/error.py,sha256=Q7GRhniP-7ap4HBpU69frRdKgKLwmH4ySYxCtupsr60,2638
48
45
  dashscope/common/logging.py,sha256=ecGxylG3bWES_Xv5-BD6ep4_0Ciu7F6ZPBjiZtu9Jx4,984
49
46
  dashscope/common/message_manager.py,sha256=i5149WzDk6nWmdFaHzYx4USXMBeX18GKSI-F4fLwbN0,1097
50
- dashscope/common/utils.py,sha256=yIHbbHZlK5UUGVZDizzjFENYb9S6JeJ-qqefP5IdGr4,15392
47
+ dashscope/common/utils.py,sha256=QM1ksr4fodmu_W6Zk1Ds9KayE2KDhpSEDNr-vyledEs,15382
51
48
  dashscope/customize/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
52
49
  dashscope/customize/customize_types.py,sha256=ZtEwSXA4dbjIYr5vgQQNkMuXyC2BNmznGuaF6b7jwr0,4803
53
50
  dashscope/customize/deployments.py,sha256=LIkM-hmJHcJZCKV6WJIPSXQ5CAhB5PUxnt5mqKbVbfE,5189
@@ -65,7 +62,6 @@ dashscope/protocol/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuF
65
62
  dashscope/protocol/websocket.py,sha256=z-v6PGx3L4zYBANuC48s7SWSQSwRCDoh0zcfhv9Bf8U,561
66
63
  dashscope/rerank/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
67
64
  dashscope/rerank/text_rerank.py,sha256=1L-RLUxMCvNhbMud1FUG6YFWT7ZV979fzhMEuVjJ1oI,2398
68
- dashscope/resources/qwen.tiktoken,sha256=srG437XMXwJLr8NzEhxquj9m-aWgJp4kNHCh3hajMYY,2561218
69
65
  dashscope/threads/__init__.py,sha256=md5bsHekHHGOg3uQrBCk8f4BCNnA1AuI_-LDf92pNVU,621
70
66
  dashscope/threads/thread_types.py,sha256=SwAJNi-RbqFXlrztDUCt0q0MfgfJLHyYl9qWrQDmQQo,18280
71
67
  dashscope/threads/threads.py,sha256=dD72xklN71KFGBVoBVHEbCbZADwLbi9yGS9LbFpnlAI,7665
@@ -81,10 +77,10 @@ dashscope/tokenizers/tokenization.py,sha256=G6cSEmVLr3pjXUC3EOU9ot8MYxNnOQ4wOB2m
81
77
  dashscope/tokenizers/tokenizer.py,sha256=y6P91qTCYo__pEx_0VHAcj9YECfbUdRqZU1fdGTjF4o,1154
82
78
  dashscope/tokenizers/tokenizer_base.py,sha256=REDhzRyDT13iequ61-a6_KcTy0GFKlihQve5HkyoyRs,656
83
79
  dashscope/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
84
- dashscope/utils/oss_utils.py,sha256=Ha4VdeO5D4lHa-xE3-iUdZFOsHS5pe_Oz1Tg5P605bY,6487
85
- dashscope-1.20.4.dist-info/LICENSE,sha256=Izp5L1DF1Mbza6qojkqNNWlE_mYLnr4rmzx2EBF8YFw,11413
86
- dashscope-1.20.4.dist-info/METADATA,sha256=2r20We1APpu60VMdSe6UXLYXuHXywQZC-hkGyF-RYRc,6641
87
- dashscope-1.20.4.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
88
- dashscope-1.20.4.dist-info/entry_points.txt,sha256=raEp5dOuj8whJ7yqZlDM8WQ5p2RfnGrGNo0QLQEnatY,50
89
- dashscope-1.20.4.dist-info/top_level.txt,sha256=woqavFJK9zas5xTqynmALqOtlafghjsk63Xk86powTU,10
90
- dashscope-1.20.4.dist-info/RECORD,,
80
+ dashscope/utils/oss_utils.py,sha256=zxe2NtIwcVWclVM24Ls0Flnkl66NMsUpr7TnH_6w5hs,6693
81
+ dashscope-1.20.6.dist-info/LICENSE,sha256=Izp5L1DF1Mbza6qojkqNNWlE_mYLnr4rmzx2EBF8YFw,11413
82
+ dashscope-1.20.6.dist-info/METADATA,sha256=mOswMqzMSwkTw9q8O5k_xu2OqiA5jSpJFEAMpaniIIA,6661
83
+ dashscope-1.20.6.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
84
+ dashscope-1.20.6.dist-info/entry_points.txt,sha256=e9C3sOf9zDYL0O5ROEGX6FT8w-QK_kaGRWmPZDHAFys,49
85
+ dashscope-1.20.6.dist-info/top_level.txt,sha256=woqavFJK9zas5xTqynmALqOtlafghjsk63Xk86powTU,10
86
+ dashscope-1.20.6.dist-info/RECORD,,
@@ -1,3 +1,2 @@
1
1
  [console_scripts]
2
2
  dashscope = dashscope.cli:main
3
-
dashscope/deployment.py DELETED
@@ -1,163 +0,0 @@
1
- from dashscope.api_entities.dashscope_response import DashScopeAPIResponse
2
- from dashscope.client.base_api import (CreateMixin, DeleteMixin, GetMixin,
3
- ListMixin, PutMixin, StreamEventMixin)
4
-
5
-
6
- class Deployment(CreateMixin, DeleteMixin, ListMixin, GetMixin,
7
- StreamEventMixin, PutMixin):
8
- SUB_PATH = 'deployments'
9
- """Deploy a model.
10
- """
11
- @classmethod
12
- def call(cls,
13
- model: str,
14
- capacity: int,
15
- version: str = None,
16
- suffix: str = None,
17
- api_key: str = None,
18
- workspace: str = None,
19
- **kwargs) -> DashScopeAPIResponse:
20
- """Call to deployment a model service.
21
-
22
- Args:
23
- model (str): The model name.
24
- version (str, optional): The model version, unnecessary
25
- for fine-tuned model. Defaults to None.
26
- suffix (str, optional): The name suffix of the model deployment,
27
- If specified, the final model name will be model_suffix.
28
- Defaults to None.
29
- capacity (int, optional): The model service capacity.
30
- api_key (str, optional): The api-key. Defaults to None.
31
- workspace (str): The dashscope workspace id.
32
-
33
- Returns:
34
- DashScopeAPIResponse: _description_
35
- """
36
- req = {'model_name': model, 'capacity': capacity}
37
-
38
- if version is not None:
39
- req['model_version'] = version
40
- if suffix is not None:
41
- req['suffix'] = suffix
42
- return super().call(req,
43
- api_key=api_key,
44
- workspace=workspace,
45
- **kwargs)
46
-
47
- @classmethod
48
- def list(cls,
49
- page_no=1,
50
- page_size=10,
51
- api_key: str = None,
52
- workspace: str = None,
53
- **kwargs) -> DashScopeAPIResponse:
54
- """List deployments.
55
-
56
- Args:
57
- api_key (str, optional): The api api_key, if not present,
58
- will get by default rule(TODO: api key doc). Defaults to None.
59
- page_no (int, optional): Page number. Defaults to 1.
60
- page_size (int, optional): Items per page. Defaults to 10.
61
- workspace (str): The dashscope workspace id.
62
-
63
- Returns:
64
- DashScopeAPIResponse: The deployment list.
65
- """
66
- return super().list(page_no,
67
- page_size,
68
- api_key,
69
- workspace=workspace,
70
- **kwargs)
71
-
72
- @classmethod
73
- def get(cls,
74
- deployed_model: str,
75
- api_key: str = None,
76
- workspace: str = None,
77
- **kwargs) -> DashScopeAPIResponse:
78
- """Get model deployment information.
79
-
80
- Args:
81
- deployed_model (str): The deployment_id.
82
- api_key (str, optional): The api key. Defaults to None.
83
- workspace (str): The dashscope workspace id.
84
-
85
- Returns:
86
- DashScopeAPIResponse: The deployment information.
87
- """
88
- return super().get(deployed_model,
89
- api_key,
90
- workspace=workspace,
91
- **kwargs)
92
-
93
- @classmethod
94
- def delete(cls,
95
- deployment_id: str,
96
- api_key: str = None,
97
- workspace: str = None,
98
- **kwargs) -> DashScopeAPIResponse:
99
- """Delete model deployment.
100
-
101
- Args:
102
- deployment_id (str): The deployment id.
103
- api_key (str, optional): The api key. Defaults to None.
104
- workspace (str): The dashscope workspace id.
105
-
106
- Returns:
107
- DashScopeAPIResponse: The delete result.
108
- """
109
- return super().delete(deployment_id,
110
- api_key,
111
- workspace=workspace,
112
- **kwargs)
113
-
114
- @classmethod
115
- def update(cls,
116
- deployment_id: str,
117
- version: str,
118
- api_key: str = None,
119
- workspace: str = None,
120
- **kwargs) -> DashScopeAPIResponse:
121
- """Update model deployment.
122
-
123
- Args:
124
- deployment_id (str): The deployment id.
125
- version (str): The target model version.
126
- api_key (str, optional): The api key. Defaults to None.
127
- workspace (str): The dashscope workspace id.
128
-
129
- Returns:
130
- DashScopeAPIResponse: The delete result.
131
- """
132
- req = {'deployment_model': deployment_id, 'model_version': version}
133
- return super().put(deployment_id,
134
- req,
135
- api_key,
136
- workspace=workspace,
137
- **kwargs)
138
-
139
- @classmethod
140
- def scale(cls,
141
- deployment_id: str,
142
- capacity: int,
143
- api_key: str = None,
144
- workspace: str = None,
145
- **kwargs) -> DashScopeAPIResponse:
146
- """Scaling model deployment.
147
-
148
- Args:
149
- deployment_id (str): The deployment id.
150
- capacity (int): The target service capacity.
151
- api_key (str, optional): The api key. Defaults to None.
152
-
153
- Returns:
154
- DashScopeAPIResponse: The delete result.
155
- """
156
- req = {'deployed_model': deployment_id, 'capacity': capacity}
157
- path = '%s/%s/scale' % (cls.SUB_PATH.lower(), deployment_id)
158
- return super().put(deployment_id,
159
- req,
160
- path=path,
161
- api_key=api_key,
162
- workspace=workspace,
163
- **kwargs)
dashscope/file.py DELETED
@@ -1,94 +0,0 @@
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 File(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
- **kwargs) -> DashScopeAPIResponse:
21
- """Upload file for model fine-tune or other tasks.
22
-
23
- Args:
24
- file_path (str): The local file name to upload.
25
- purpose (str): The purpose of the file[fine-tune|inference]
26
- description (str, optional): The file description message.
27
- api_key (str, optional): The api key. Defaults to None.
28
-
29
- Returns:
30
- DashScopeAPIResponse: The upload information
31
- """
32
- if purpose == FilePurpose.fine_tune:
33
- if not is_validate_fine_tune_file(file_path):
34
- raise InvalidFileFormat(
35
- 'The file %s is not in valid jsonl format' % file_path)
36
- with open(file_path, 'rb') as f:
37
- return super().upload(files=[('files', (os.path.basename(f.name),
38
- f, None))],
39
- descriptions=[description]
40
- if description is not None else None,
41
- api_key=api_key,
42
- **kwargs)
43
-
44
- @classmethod
45
- def list(cls,
46
- page=1,
47
- page_size=10,
48
- api_key: str = None,
49
- **kwargs) -> DashScopeAPIResponse:
50
- """List uploaded files.
51
-
52
- Args:
53
- api_key (str, optional):
54
- The api api_key, can be None,
55
- if None, will get by default rule(TODO: api key doc).
56
- page (int, optional): Page number. Defaults to 1.
57
- page_size (int, optional): Items per page. Defaults to 10.
58
-
59
- Returns:
60
- DashScopeAPIResponse: The fine-tune jobs in the result.
61
- """
62
- return super().list(page, page_size, api_key, **kwargs)
63
-
64
- @classmethod
65
- def get(cls,
66
- file_id: str,
67
- api_key: str = None,
68
- **kwargs) -> DashScopeAPIResponse:
69
- """Get the file info.
70
-
71
- Args:
72
- file_id (str): The file id.
73
- api_key (str, optional): The api key. Defaults to None.
74
-
75
- Returns:
76
- DashScopeAPIResponse: The job info
77
- """
78
- return super().get(file_id, api_key, **kwargs)
79
-
80
- @classmethod
81
- def delete(cls,
82
- file_id: str,
83
- api_key: str = None,
84
- **kwargs) -> DashScopeAPIResponse:
85
- """Delete uploaded file.
86
-
87
- Args:
88
- file_id (str): The file id want to delete.
89
- api_key (str, optional): The api key. Defaults to None.
90
-
91
- Returns:
92
- DashScopeAPIResponse: Delete result.
93
- """
94
- return super().delete(file_id, api_key, **kwargs)
dashscope/finetune.py DELETED
@@ -1,175 +0,0 @@
1
- from typing import Union
2
-
3
- from dashscope.api_entities.dashscope_response import DashScopeAPIResponse
4
- from dashscope.client.base_api import (CancelMixin, CreateMixin, DeleteMixin,
5
- GetStatusMixin, ListMixin, LogMixin,
6
- StreamEventMixin)
7
-
8
-
9
- class FineTune(CreateMixin, CancelMixin, DeleteMixin, ListMixin,
10
- GetStatusMixin, StreamEventMixin, LogMixin):
11
- SUB_PATH = 'fine-tunes'
12
-
13
- @classmethod
14
- def call(cls,
15
- model: str,
16
- training_file_ids: Union[list, str],
17
- validation_file_ids: Union[list, str] = None,
18
- mode: str = None,
19
- hyper_parameters: dict = {},
20
- api_key: str = None,
21
- workspace: str = None,
22
- **kwargs) -> DashScopeAPIResponse:
23
- """Create fine-tune job
24
-
25
- Args:
26
- model (str): The model to be fine-tuned
27
- training_file_ids (list, str): Ids of the fine-tune training data,
28
- which can be pre-uploaded using the File API.
29
- validation_file_ids ([list,str], optional): Ids of the fine-tune
30
- validating data, which can be pre-uploaded using the File API.
31
- mode (str): The fine-tune mode, sft or efficient_sft.
32
- hyper_parameters (dict, optional): The fine-tune hyper parameters.
33
- Defaults to empty.
34
- api_key (str, optional): The api key. Defaults to None.
35
- workspace (str): The dashscope workspace id.
36
-
37
- Returns:
38
- DashScopeAPIResponse: The request result.
39
- """
40
- request = {
41
- 'model': model,
42
- 'training_file_ids': training_file_ids,
43
- 'validation_file_ids': validation_file_ids,
44
- 'hyper_parameters': hyper_parameters if hyper_parameters else {},
45
- }
46
- if mode is not None:
47
- request['training_type'] = mode
48
- if 'finetuned_output' in kwargs:
49
- request['finetuned_output'] = kwargs['finetuned_output']
50
- return super().call(request,
51
- api_key=api_key,
52
- workspace=workspace,
53
- **kwargs)
54
-
55
- @classmethod
56
- def cancel(cls,
57
- job_id: str,
58
- api_key: str = None,
59
- workspace: str = None,
60
- **kwargs) -> DashScopeAPIResponse:
61
- """Cancel a running fine-tune job.
62
-
63
- Args:
64
- job_id (str): The fine-tune job id.
65
- api_key (str, optional): The api api_key, can be None,
66
- if None, will get by default rule(TODO: api key doc).
67
- workspace (str): The dashscope workspace id.
68
-
69
- Returns:
70
- DashScopeAPIResponse: The request result.
71
- """
72
- return super().cancel(job_id, api_key, workspace=workspace, **kwargs)
73
-
74
- @classmethod
75
- def list(cls,
76
- page=1,
77
- page_size=10,
78
- api_key: str = None,
79
- workspace: str = None,
80
- **kwargs) -> DashScopeAPIResponse:
81
- """List fine-tune job.
82
-
83
- Args:
84
- api_key (str, optional): The api key
85
- page (int, optional): Page number. Defaults to 1.
86
- page_size (int, optional): Items per page. Defaults to 10.
87
- workspace (str): The dashscope workspace id.
88
-
89
- Returns:
90
- DashScopeAPIResponse: The fine-tune jobs in the result.
91
- """
92
- return super().list(page,
93
- page_size,
94
- api_key,
95
- workspace=workspace,
96
- **kwargs)
97
-
98
- @classmethod
99
- def get(cls,
100
- job_id: str,
101
- api_key: str = None,
102
- workspace: str = None,
103
- **kwargs) -> DashScopeAPIResponse:
104
- """Get fine-tune job information.
105
-
106
- Args:
107
- job_id (str): The fine-tune job id
108
- api_key (str, optional): The api key. Defaults to None.
109
- workspace (str): The dashscope workspace id.
110
-
111
- Returns:
112
- DashScopeAPIResponse: The job info
113
- """
114
- return super().get(job_id, api_key, workspace=workspace, **kwargs)
115
-
116
- @classmethod
117
- def delete(cls,
118
- job_id: str,
119
- api_key: str = None,
120
- workspace: str = None,
121
- **kwargs) -> DashScopeAPIResponse:
122
- """Delete a fine-tune job.
123
-
124
- Args:
125
- job_id (str): The fine-tune job id.
126
- api_key (str, optional): The api key. Defaults to None.
127
- workspace (str): The dashscope workspace id.
128
-
129
- Returns:
130
- DashScopeAPIResponse: The delete result.
131
- """
132
- return super().delete(job_id, api_key, workspace=workspace, **kwargs)
133
-
134
- @classmethod
135
- def stream_events(cls,
136
- job_id: str,
137
- api_key: str = None,
138
- workspace: str = None,
139
- **kwargs) -> DashScopeAPIResponse:
140
- """Get fine-tune job events.
141
-
142
- Args:
143
- job_id (str): The fine-tune job id
144
- api_key (str, optional): the api key. Defaults to None.
145
- workspace (str): The dashscope workspace id.
146
-
147
- Returns:
148
- DashScopeAPIResponse: The job log events.
149
- """
150
- return super().stream_events(job_id,
151
- api_key,
152
- workspace=workspace,
153
- **kwargs)
154
-
155
- @classmethod
156
- def logs(cls,
157
- job_id: str,
158
- offset=1,
159
- line=1000,
160
- api_key: str = None,
161
- workspace: str = None,
162
- **kwargs) -> DashScopeAPIResponse:
163
- """Get log of the job.
164
-
165
- Args:
166
- job_id (str): The job id(used for fine-tune)
167
- offset (int, optional): start log line. Defaults to 1.
168
- line (int, optional): total line return. Defaults to 1000.
169
- api_key (str, optional): The api key. Defaults to None.
170
- workspace (str): The dashscope workspace id.
171
-
172
- Returns:
173
- DashScopeAPIResponse: The response
174
- """
175
- return super().logs(job_id, offset, line, workspace=workspace)