|
1 | 1 | from __future__ import annotations |
2 | 2 |
|
| 3 | +import os |
| 4 | +import sys |
| 5 | + |
| 6 | +# ============================================================================= |
| 7 | +# SDK 2.0 ANNOUNCEMENT |
| 8 | +# ============================================================================= |
| 9 | +_ANNOUNCEMENT_MESSAGE = """ |
| 10 | +================================================================================ |
| 11 | +Together Python SDK 2.0 is now available! |
| 12 | +
|
| 13 | +Install: pip install --pre together |
| 14 | +New SDK: https://github.com/togethercomputer/together-py |
| 15 | +Migration guide: https://docs.together.ai/docs/pythonv2-migration-guide |
| 16 | +
|
| 17 | +This package will be maintained until January 2026. |
| 18 | +================================================================================ |
| 19 | +""" |
| 20 | + |
| 21 | +# Show info banner (unless suppressed) |
| 22 | +if not os.environ.get("TOGETHER_NO_BANNER"): |
| 23 | + try: |
| 24 | + from rich.console import Console |
| 25 | + from rich.panel import Panel |
| 26 | + |
| 27 | + console = Console(stderr=True) |
| 28 | + console.print( |
| 29 | + Panel( |
| 30 | + "[bold cyan]Together Python SDK 2.0 is now available![/bold cyan]\n\n" |
| 31 | + "Install the beta:\n" |
| 32 | + "[green]pip install --pre together[/green] or " |
| 33 | + "[green]uv add together --prerelease allow[/green]\n\n" |
| 34 | + "New SDK: [link=https://github.com/togethercomputer/together-py]" |
| 35 | + "https://github.com/togethercomputer/together-py[/link]\n" |
| 36 | + "Migration guide: [link=https://docs.together.ai/docs/pythonv2-migration-guide]" |
| 37 | + "https://docs.together.ai/docs/pythonv2-migration-guide[/link]\n\n" |
| 38 | + "[dim]This package will be maintained until January 2026.\n" |
| 39 | + "Set TOGETHER_NO_BANNER=1 to hide this message.[/dim]", |
| 40 | + title="🚀 New SDK Available", |
| 41 | + border_style="cyan", |
| 42 | + ) |
| 43 | + ) |
| 44 | + except Exception: |
| 45 | + # Fallback for any error (ImportError, OSError in daemons, rich errors, etc.) |
| 46 | + # Banner display should never break module imports |
| 47 | + try: |
| 48 | + print(_ANNOUNCEMENT_MESSAGE, file=sys.stderr) |
| 49 | + except Exception: |
| 50 | + pass # Silently ignore if even stderr is unavailable |
| 51 | + |
| 52 | +# ============================================================================= |
| 53 | + |
3 | 54 | from contextvars import ContextVar |
4 | 55 | from typing import TYPE_CHECKING, Callable |
5 | 56 |
|
|
0 commit comments