Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions dashscope/assistants/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# -*- coding: utf-8 -*-
# Copyright (c) Alibaba, Inc. and its affiliates.

import warnings

# yapf: disable

from dashscope.assistants.assistant_types import (
Expand All @@ -17,3 +19,13 @@
'AssistantFile',
'DeleteResponse',
]

# Deprecation warning
_DEPRECATION_MSG = (
"The Assistants API (dashscope.assistants) is deprecated and will be "
"removed in a future release. Please migrate to the Responses API. "
"See https://help.aliyun.com/zh/model-studio/"
"synchronous-call-api-reference for migration details."
)

warnings.warn(_DEPRECATION_MSG, category=DeprecationWarning, stacklevel=2)
9 changes: 3 additions & 6 deletions dashscope/assistants/assistant_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,25 +114,22 @@ class Assistant(BaseObjectMixin):
"""ID of the assistant.
"""
model: str
name: Optional[str] = None
created_at: int # type: ignore[misc]
"""The Unix timestamp (in seconds) for when the assistant was created.
"""
description: Optional[str] = None

file_ids: List[str] # type: ignore[misc]
tools: List[Tool] # type: ignore[misc]

name: Optional[str] = None
description: Optional[str] = None
instructions: Optional[str] = None
metadata: Optional[object] = None
tools: List[Tool] # type: ignore[misc]

object: Optional[str] = None

top_p: Optional[float] = None
top_k: Optional[int] = None
temperature: Optional[float] = None
max_tokens: Optional[int] = None

request_id: Optional[str] = None

def __init__(self, **kwargs):
Expand Down
52 changes: 52 additions & 0 deletions dashscope/assistants/assistants.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
# Copyright (c) Alibaba, Inc. and its affiliates.

import warnings
from typing import Dict, List, Optional

from dashscope.assistants.assistant_types import (
Expand All @@ -20,6 +21,14 @@

__all__ = ["Assistants"]

# Deprecation warning message
_DEPRECATION_MSG = (
"The Assistants API (dashscope.assistants) is deprecated and will be "
"removed in a future release. Please migrate to the Responses API. "
"See https://help.aliyun.com/zh/model-studio/"
"synchronous-call-api-reference for migration details."
)


class Assistants(
CreateMixin,
Expand All @@ -29,6 +38,14 @@ class Assistants(
GetStatusMixin,
UpdateMixin,
):
"""
.. deprecated::
The Assistants API is deprecated and will be removed in a future
release. Please migrate to the Responses API.
See https://help.aliyun.com/zh/model-studio/
synchronous-call-api-reference for migration details.
"""

SUB_PATH = "assistants"

@classmethod
Expand Down Expand Up @@ -114,6 +131,11 @@ def call( # type: ignore[override]
Returns:
Assistant: The `Assistant` object.
"""
warnings.warn(
_DEPRECATION_MSG,
category=DeprecationWarning,
stacklevel=2,
)
return cls.create(
model=model,
name=name,
Expand Down Expand Up @@ -180,6 +202,11 @@ def create(
Returns:
Assistant: The `Assistant` object.
"""
warnings.warn(
_DEPRECATION_MSG,
category=DeprecationWarning,
stacklevel=2,
)
if not model:
raise ModelRequired("Model is required!")
data = cls._create_assistant_object(
Expand Down Expand Up @@ -223,6 +250,11 @@ def retrieve(
Returns:
Assistant: The `Assistant` object.
"""
warnings.warn(
_DEPRECATION_MSG,
category=DeprecationWarning,
stacklevel=2,
)
return cls.get(
assistant_id,
workspace=workspace,
Expand All @@ -249,6 +281,11 @@ def get( # type: ignore[override]
Returns:
Assistant: The `Assistant` object.
"""
warnings.warn(
_DEPRECATION_MSG,
category=DeprecationWarning,
stacklevel=2,
)
if not assistant_id:
raise ModelRequired("assistant_id is required!")
response = super().get(
Expand Down Expand Up @@ -287,6 +324,11 @@ def list( # type: ignore[override]
Returns:
AssistantList: The list of assistants.
"""
warnings.warn(
_DEPRECATION_MSG,
category=DeprecationWarning,
stacklevel=2,
)
response = super().list(
limit=limit,
order=order,
Expand Down Expand Up @@ -348,6 +390,11 @@ def update( # type: ignore[override]
Returns:
Assistant: The updated assistant.
"""
warnings.warn(
_DEPRECATION_MSG,
category=DeprecationWarning,
stacklevel=2,
)
if not assistant_id:
raise ModelRequired("assistant_id is required!")
response = super().update(
Expand Down Expand Up @@ -392,6 +439,11 @@ def delete( # type: ignore[override]
Returns:
AssistantsDeleteResponse: Delete result.
"""
warnings.warn(
_DEPRECATION_MSG,
category=DeprecationWarning,
stacklevel=2,
)
if not assistant_id:
raise ModelRequired("assistant_id is required!")
response = super().delete(
Expand Down
47 changes: 47 additions & 0 deletions dashscope/assistants/files.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
# Copyright (c) Alibaba, Inc. and its affiliates.
import warnings
from typing import Optional

from dashscope.assistants.assistant_types import (
Expand All @@ -17,8 +18,24 @@

__all__ = ["Files"]

# Deprecation warning message
_DEPRECATION_MSG = (
"The Assistants API (dashscope.assistants) is deprecated and will be "
"removed in a future release. Please migrate to the Responses API. "
"See https://help.aliyun.com/zh/model-studio/"
"synchronous-call-api-reference for migration details."
)


class Files(CreateMixin, DeleteMixin, ListObjectMixin, GetStatusMixin):
"""
.. deprecated::
The Files API (Assistants API) is deprecated and will be removed in
a future release. Please migrate to the Responses API.
See https://help.aliyun.com/zh/model-studio/
synchronous-call-api-reference for migration details.
"""

SUB_PATH = "assistants"

@classmethod
Expand Down Expand Up @@ -46,6 +63,11 @@ def call( # type: ignore[override]
Returns:
AssistantFile: The assistant file object.
"""
warnings.warn(
_DEPRECATION_MSG,
category=DeprecationWarning,
stacklevel=2,
)
return cls.create(
assistant_id,
file_id=file_id,
Expand Down Expand Up @@ -79,6 +101,11 @@ def create(
Returns:
AssistantFile: _description_
"""
warnings.warn(
_DEPRECATION_MSG,
category=DeprecationWarning,
stacklevel=2,
)
if not file_id or not assistant_id:
raise InputRequired("input file_id and assistant_id is required!")

Expand Down Expand Up @@ -121,6 +148,11 @@ def list( # type: ignore[override]
Returns:
ListAssistantFile: The list of file objects.
"""
warnings.warn(
_DEPRECATION_MSG,
category=DeprecationWarning,
stacklevel=2,
)

response = super().list(
limit=limit,
Expand Down Expand Up @@ -157,6 +189,11 @@ def retrieve(
Returns:
AssistantFile: The `AssistantFile` object.
"""
warnings.warn(
_DEPRECATION_MSG,
category=DeprecationWarning,
stacklevel=2,
)
if not assistant_id or not file_id:
raise InputRequired("assistant id and file id are required!")
response = super().get(
Expand Down Expand Up @@ -191,6 +228,11 @@ def get( # type: ignore[override]
Returns:
AssistantFile: The `AssistantFile` object.
"""
warnings.warn(
_DEPRECATION_MSG,
category=DeprecationWarning,
stacklevel=2,
)
response = super().get(
target=assistant_id + "/files/" + file_id,
api_key=api_key,
Expand Down Expand Up @@ -224,6 +266,11 @@ def delete( # type: ignore[override]
Returns:
AssistantsDeleteResponse: _description_
"""
warnings.warn(
_DEPRECATION_MSG,
category=DeprecationWarning,
stacklevel=2,
)

response = super().delete(
file_id,
Expand Down
Loading