|
2 | 2 |
|
3 | 3 | from __future__ import annotations
|
4 | 4 |
|
| 5 | +import warnings |
5 | 6 | from typing import List, Union, Iterable
|
6 | 7 | from functools import partial
|
7 | 8 | from itertools import chain
|
|
34 | 35 | from ....types.beta import message_create_params, message_count_tokens_params
|
35 | 36 | from ...._base_client import make_request_options
|
36 | 37 | from ....lib.streaming import BetaMessageStreamManager, BetaAsyncMessageStreamManager
|
| 38 | +from ...messages.messages import DEPRECATED_MODELS |
37 | 39 | from ....types.model_param import ModelParam
|
38 | 40 | from ....types.beta.beta_message import BetaMessage
|
39 | 41 | from ....types.anthropic_beta_param import AnthropicBetaParam
|
@@ -893,6 +895,14 @@ def create(
|
893 | 895 | ) -> BetaMessage | Stream[BetaRawMessageStreamEvent]:
|
894 | 896 | if not is_given(timeout) and self._client.timeout == DEFAULT_TIMEOUT:
|
895 | 897 | timeout = 600
|
| 898 | + |
| 899 | + if model in DEPRECATED_MODELS: |
| 900 | + warnings.warn( |
| 901 | + f"The model '{model}' is deprecated and will reach end-of-life on {DEPRECATED_MODELS[model]}.\nPlease migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.", |
| 902 | + DeprecationWarning, |
| 903 | + stacklevel=3, |
| 904 | + ) |
| 905 | + |
896 | 906 | extra_headers = {
|
897 | 907 | **strip_not_given({"anthropic-beta": ",".join(str(e) for e in betas) if is_given(betas) else NOT_GIVEN}),
|
898 | 908 | **(extra_headers or {}),
|
@@ -2061,6 +2071,14 @@ async def create(
|
2061 | 2071 | ) -> BetaMessage | AsyncStream[BetaRawMessageStreamEvent]:
|
2062 | 2072 | if not is_given(timeout) and self._client.timeout == DEFAULT_TIMEOUT:
|
2063 | 2073 | timeout = 600
|
| 2074 | + |
| 2075 | + if model in DEPRECATED_MODELS: |
| 2076 | + warnings.warn( |
| 2077 | + f"The model '{model}' is deprecated and will reach end-of-life on {DEPRECATED_MODELS[model]}.\nPlease migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.", |
| 2078 | + DeprecationWarning, |
| 2079 | + stacklevel=3, |
| 2080 | + ) |
| 2081 | + |
2064 | 2082 | extra_headers = {
|
2065 | 2083 | **strip_not_given({"anthropic-beta": ",".join(str(e) for e in betas) if is_given(betas) else NOT_GIVEN}),
|
2066 | 2084 | **(extra_headers or {}),
|
|
0 commit comments