|
1 | 1 | from __future__ import annotations |
2 | 2 |
|
| 3 | +import os |
| 4 | +import sys |
| 5 | +import warnings |
| 6 | + |
| 7 | +# ============================================================================= |
| 8 | +# DEPRECATION NOTICE |
| 9 | +# ============================================================================= |
| 10 | +_DEPRECATION_MESSAGE = """ |
| 11 | +================================================================================ |
| 12 | +DEPRECATION WARNING: The 'together' package is deprecated and will no longer |
| 13 | +be maintained after January 2026. |
| 14 | +
|
| 15 | +Please migrate to the new SDK: https://github.com/togethercomputer/together-py |
| 16 | +
|
| 17 | +Migration guide: https://docs.together.ai/docs/pythonv2-migration-guide |
| 18 | +================================================================================ |
| 19 | +""" |
| 20 | + |
| 21 | +# Show deprecation warning (visible to developers with warnings enabled) |
| 22 | +warnings.warn( |
| 23 | + "The 'together' package is deprecated and will no longer be maintained after " |
| 24 | + "January 2026. Please migrate to the new SDK: " |
| 25 | + "https://github.com/togethercomputer/together-py " |
| 26 | + "Migration guide: https://docs.together.ai/docs/pythonv2-migration-guide", |
| 27 | + DeprecationWarning, |
| 28 | + stacklevel=2, |
| 29 | +) |
| 30 | + |
| 31 | +# Also print a visible notice to stderr (unless suppressed) |
| 32 | +if not os.environ.get("TOGETHER_SUPPRESS_DEPRECATION_WARNING"): |
| 33 | + try: |
| 34 | + from rich.console import Console |
| 35 | + from rich.panel import Panel |
| 36 | + |
| 37 | + console = Console(stderr=True) |
| 38 | + console.print( |
| 39 | + Panel( |
| 40 | + "[bold yellow]DEPRECATION WARNING[/bold yellow]\n\n" |
| 41 | + "The [cyan]together[/cyan] package is deprecated and will no longer " |
| 42 | + "be maintained after [bold]January 2026[/bold].\n\n" |
| 43 | + "Please migrate to the new SDK:\n" |
| 44 | + "[link=https://github.com/togethercomputer/together-py]" |
| 45 | + "https://github.com/togethercomputer/together-py[/link]\n\n" |
| 46 | + "Migration guide:\n" |
| 47 | + "[link=https://docs.together.ai/docs/pythonv2-migration-guide]" |
| 48 | + "https://docs.together.ai/docs/pythonv2-migration-guide[/link]\n\n" |
| 49 | + "[dim]Set TOGETHER_SUPPRESS_DEPRECATION_WARNING=1 to hide this message.[/dim]", |
| 50 | + title="⚠️ Deprecation Notice", |
| 51 | + border_style="yellow", |
| 52 | + ) |
| 53 | + ) |
| 54 | + except ImportError: |
| 55 | + # Fallback if rich is not available |
| 56 | + print(_DEPRECATION_MESSAGE, file=sys.stderr) |
| 57 | + |
| 58 | +# ============================================================================= |
| 59 | + |
3 | 60 | from contextvars import ContextVar |
4 | 61 | from typing import TYPE_CHECKING, Callable |
5 | 62 |
|
|
0 commit comments