Skip to content

Commit cb1caa0

Browse files
author
zhansheng.lzs
committed
deprecate: mark dashscope.threads (Assistants API) as deprecated
Add DeprecationWarning to Threads, Messages, Runs, Steps classes. Warns only when methods are actually called, not on import. Users should migrate to the Responses API. See https://help.aliyun.com/zh/model-studio/synchronous-call-api-reference for migration details.
1 parent 8789b24 commit cb1caa0

4 files changed

Lines changed: 44 additions & 0 deletions

File tree

dashscope/threads/messages/messages.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# Copyright (c) Alibaba, Inc. and its affiliates.
33

44
from typing import Dict, List, Optional
5+
import warnings
56

67
from dashscope.client.base_api import (
78
CreateMixin,
@@ -16,6 +17,12 @@
1617

1718

1819
class Messages(CreateMixin, ListObjectMixin, GetStatusMixin, UpdateMixin):
20+
"""
21+
.. deprecated::
22+
The Messages API (Assistants API) is deprecated and will be removed
23+
in a future release. Please migrate to the Responses API.
24+
See https://help.aliyun.com/zh/model-studio/ for migration details.
25+
"""
1926
SUB_PATH = "messages" # useless
2027

2128
@classmethod
@@ -73,6 +80,7 @@ def create(
7380
api_key: str = None,
7481
**kwargs,
7582
) -> ThreadMessage:
83+
warnings.warn("The Assistants API (dashscope.threads) is deprecated and will be removed in a future release. Please migrate to the Responses API. See https://help.aliyun.com/zh/model-studio/ for migration details.", category=DeprecationWarning, stacklevel=2)
7684
"""Create message of thread.
7785
7886
Args:
@@ -149,6 +157,7 @@ def get( # type: ignore[override]
149157
api_key: str = None,
150158
**kwargs,
151159
) -> ThreadMessage:
160+
warnings.warn("The Assistants API (dashscope.threads) is deprecated and will be removed in a future release. Please migrate to the Responses API. See https://help.aliyun.com/zh/model-studio/ for migration details.", category=DeprecationWarning, stacklevel=2)
152161
"""Get the `ThreadMessage`.
153162
154163
Args:
@@ -185,6 +194,7 @@ def list( # type: ignore[override]
185194
api_key: str = None,
186195
**kwargs,
187196
) -> ThreadMessageList:
197+
warnings.warn("The Assistants API (dashscope.threads) is deprecated and will be removed in a future release. Please migrate to the Responses API. See https://help.aliyun.com/zh/model-studio/ for migration details.", category=DeprecationWarning, stacklevel=2)
188198
"""List message of the thread.
189199
190200
Args:

dashscope/threads/runs/runs.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import time
55
from http import HTTPStatus
6+
import warnings
67
from typing import Dict, List, Optional
78

89
from dashscope.client.base_api import (
@@ -38,6 +39,12 @@ class Runs(
3839
GetStatusMixin,
3940
UpdateMixin,
4041
):
42+
"""
43+
.. deprecated::
44+
The Runs API (Assistants API) is deprecated and will be removed
45+
in a future release. Please migrate to the Responses API.
46+
See https://help.aliyun.com/zh/model-studio/ for migration details.
47+
"""
4148
SUB_PATH = "RUNS" # useless
4249

4350
@classmethod
@@ -57,6 +64,7 @@ def create_thread_and_run(
5764
api_key: str = None,
5865
**kwargs,
5966
) -> Run:
67+
warnings.warn("The Assistants API (dashscope.threads) is deprecated and will be removed in a future release. Please migrate to the Responses API. See https://help.aliyun.com/zh/model-studio/ for migration details.", category=DeprecationWarning, stacklevel=2)
6068
if not assistant_id:
6169
raise InputRequired("assistant_id is required")
6270
data = {"assistant_id": assistant_id}
@@ -114,6 +122,7 @@ def create( # pylint: disable=too-many-branches
114122
max_tokens: Optional[int] = None,
115123
**kwargs,
116124
) -> Run:
125+
warnings.warn("The Assistants API (dashscope.threads) is deprecated and will be removed in a future release. Please migrate to the Responses API. See https://help.aliyun.com/zh/model-studio/ for migration details.", category=DeprecationWarning, stacklevel=2)
117126
"""Create a run.
118127
119128
Args:
@@ -293,6 +302,7 @@ def list( # type: ignore[override]
293302
api_key: str = None,
294303
**kwargs,
295304
) -> RunList:
305+
warnings.warn("The Assistants API (dashscope.threads) is deprecated and will be removed in a future release. Please migrate to the Responses API. See https://help.aliyun.com/zh/model-studio/ for migration details.", category=DeprecationWarning, stacklevel=2)
296306
"""List `Run`.
297307
298308
Args:
@@ -334,6 +344,7 @@ def retrieve(
334344
api_key: str = None,
335345
**kwargs,
336346
) -> Run:
347+
warnings.warn("The Assistants API (dashscope.threads) is deprecated and will be removed in a future release. Please migrate to the Responses API. See https://help.aliyun.com/zh/model-studio/ for migration details.", category=DeprecationWarning, stacklevel=2)
337348
"""Retrieve the `Run`.
338349
339350
Args:
@@ -399,6 +410,7 @@ def submit_tool_outputs(
399410
api_key: str = None,
400411
**kwargs,
401412
) -> Run:
413+
warnings.warn("The Assistants API (dashscope.threads) is deprecated and will be removed in a future release. Please migrate to the Responses API. See https://help.aliyun.com/zh/model-studio/ for migration details.", category=DeprecationWarning, stacklevel=2)
402414
"""_summary_
403415
404416
Args:
@@ -557,6 +569,7 @@ def cancel( # type: ignore[override]
557569
api_key: str = None,
558570
**kwargs,
559571
) -> Run:
572+
warnings.warn("The Assistants API (dashscope.threads) is deprecated and will be removed in a future release. Please migrate to the Responses API. See https://help.aliyun.com/zh/model-studio/ for migration details.", category=DeprecationWarning, stacklevel=2)
560573
"""Cancel the `Run`.
561574
562575
Args:

dashscope/threads/runs/steps.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,20 @@
22
# Copyright (c) Alibaba, Inc. and its affiliates.
33

44
from dashscope.client.base_api import GetStatusMixin, ListObjectMixin
5+
import warnings
56
from dashscope.common.error import InputRequired
67
from dashscope.threads.thread_types import RunStep, RunStepList
78

89
__all__ = ["Steps"]
910

1011

1112
class Steps(ListObjectMixin, GetStatusMixin):
13+
"""
14+
.. deprecated::
15+
The Steps API (Assistants API) is deprecated and will be removed
16+
in a future release. Please migrate to the Responses API.
17+
See https://help.aliyun.com/zh/model-studio/ for migration details.
18+
"""
1219
SUB_PATH = "RUNS" # useless
1320

1421
@classmethod
@@ -25,6 +32,7 @@ def list( # type: ignore[override]
2532
api_key: str = None,
2633
**kwargs,
2734
) -> RunStepList:
35+
warnings.warn("The Assistants API (dashscope.threads) is deprecated and will be removed in a future release. Please migrate to the Responses API. See https://help.aliyun.com/zh/model-studio/ for migration details.", category=DeprecationWarning, stacklevel=2)
2836
"""List `RunStep` of `Run`.
2937
3038
Args:
@@ -68,6 +76,7 @@ def retrieve(
6876
api_key: str = None,
6977
**kwargs,
7078
) -> RunStep:
79+
warnings.warn("The Assistants API (dashscope.threads) is deprecated and will be removed in a future release. Please migrate to the Responses API. See https://help.aliyun.com/zh/model-studio/ for migration details.", category=DeprecationWarning, stacklevel=2)
7180
"""Retrieve the `RunStep`.
7281
7382
Args:

dashscope/threads/threads.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# Copyright (c) Alibaba, Inc. and its affiliates.
33

44
from typing import Dict, List, Optional
5+
import warnings
56

67
from dashscope.assistants.assistant_types import DeleteResponse
78
from dashscope.client.base_api import (
@@ -17,6 +18,12 @@
1718

1819

1920
class Threads(CreateMixin, DeleteMixin, GetStatusMixin, UpdateMixin):
21+
"""
22+
.. deprecated::
23+
The Threads API is deprecated and will be removed in a future release.
24+
Please migrate to the Responses API.
25+
See https://help.aliyun.com/zh/model-studio/ for migration details.
26+
"""
2027
SUB_PATH = "threads"
2128

2229
@classmethod
@@ -62,6 +69,7 @@ def create(
6269
api_key: str = None,
6370
**kwargs,
6471
) -> Thread:
72+
warnings.warn("The Assistants API (dashscope.threads) is deprecated and will be removed in a future release. Please migrate to the Responses API. See https://help.aliyun.com/zh/model-studio/ for migration details.", category=DeprecationWarning, stacklevel=2)
6573
"""Create a thread.
6674
6775
Args:
@@ -127,6 +135,7 @@ def retrieve(
127135
api_key: str = None,
128136
**kwargs,
129137
) -> Thread:
138+
warnings.warn("The Assistants API (dashscope.threads) is deprecated and will be removed in a future release. Please migrate to the Responses API. See https://help.aliyun.com/zh/model-studio/ for migration details.", category=DeprecationWarning, stacklevel=2)
130139
"""Retrieve the thread.
131140
132141
Args:
@@ -159,6 +168,7 @@ def update( # type: ignore[override]
159168
api_key: str = None,
160169
**kwargs,
161170
) -> Thread:
171+
warnings.warn("The Assistants API (dashscope.threads) is deprecated and will be removed in a future release. Please migrate to the Responses API. See https://help.aliyun.com/zh/model-studio/ for migration details.", category=DeprecationWarning, stacklevel=2)
162172
"""Update thread information.
163173
164174
Args:
@@ -194,6 +204,7 @@ def delete( # type: ignore[override]
194204
api_key: str = None,
195205
**kwargs,
196206
) -> DeleteResponse:
207+
warnings.warn("The Assistants API (dashscope.threads) is deprecated and will be removed in a future release. Please migrate to the Responses API. See https://help.aliyun.com/zh/model-studio/ for migration details.", category=DeprecationWarning, stacklevel=2)
197208
"""Delete thread.
198209
199210
Args:
@@ -231,6 +242,7 @@ def create_and_run(
231242
api_key: str = None,
232243
**kwargs,
233244
) -> Run:
245+
warnings.warn("The Assistants API (dashscope.threads) is deprecated and will be removed in a future release. Please migrate to the Responses API. See https://help.aliyun.com/zh/model-studio/ for migration details.", category=DeprecationWarning, stacklevel=2)
234246
if not assistant_id:
235247
raise InputRequired("assistant_id is required")
236248
data = {"assistant_id": assistant_id}

0 commit comments

Comments
 (0)