-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy path__init__.py
More file actions
124 lines (103 loc) · 3.79 KB
/
__init__.py
File metadata and controls
124 lines (103 loc) · 3.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
from __future__ import annotations
import os
import sys
# =============================================================================
# SDK 2.0 ANNOUNCEMENT
# =============================================================================
_ANNOUNCEMENT_MESSAGE = """
================================================================================
Together Python SDK 2.0 is now available!
Install: pip install together --upgrade
Install: uv sync --upgrade-package together
New SDK: https://github.com/togethercomputer/together-py
Migration guide: https://docs.together.ai/docs/pythonv2-migration-guide
Together V1 is now deprecated and will be maintained in maintanence mode.
All new features and development will occur in the 2.0 SDK.
================================================================================
"""
# Show info banner (unless suppressed)
if not os.environ.get("TOGETHER_NO_BANNER"):
try:
from rich.console import Console
from rich.panel import Panel
console = Console(stderr=True)
console.print(
Panel(
"[bold cyan]Together Python SDK 2.0 is now available![/bold cyan]\n\n"
"Upgrade to the latest version:\n"
"[green]pip install together --upgrade[/green] or "
"[green]uv sync --upgrade-package together[/green]\n\n"
"New SDK: [link=https://github.com/togethercomputer/together-py]"
"https://github.com/togethercomputer/together-py[/link]\n"
"Migration guide: [link=https://docs.together.ai/docs/pythonv2-migration-guide]"
"https://docs.together.ai/docs/pythonv2-migration-guide[/link]\n\n"
"[dim]Together V1 is now deprecated and will be maintained in maintanence mode. All new features and development will occur in the 2.0 SDK.[/dim]\n",
title="🚀 New SDK Available",
border_style="cyan",
)
)
except Exception:
# Fallback for any error (ImportError, OSError in daemons, rich errors, etc.)
# Banner display should never break module imports
try:
print(_ANNOUNCEMENT_MESSAGE, file=sys.stderr)
except Exception:
pass # Silently ignore if even stderr is unavailable
# =============================================================================
from contextvars import ContextVar
from typing import TYPE_CHECKING, Callable
from together import (
abstract,
client,
constants,
error,
filemanager,
resources,
together_response,
types,
utils,
)
from together.version import VERSION
from together.legacy.complete import AsyncComplete, Complete, Completion
from together.legacy.embeddings import Embeddings
from together.legacy.files import Files
from together.legacy.finetune import Finetune
from together.legacy.images import Image
from together.legacy.models import Models
version = VERSION
log: str | None = None # Set to either 'debug' or 'info', controls console logging
if TYPE_CHECKING:
import requests
from aiohttp import ClientSession
requestssession: "requests.Session" | Callable[[], "requests.Session"] | None = None
aiosession: ContextVar["ClientSession" | None] = ContextVar(
"aiohttp-session", default=None
)
from together.client import AsyncClient, AsyncTogether, Client, Together
api_key: str | None = None # To be deprecated in the next major release
# Legacy functions
__all__ = [
"aiosession",
"constants",
"version",
"Together",
"AsyncTogether",
"Client",
"AsyncClient",
"resources",
"types",
"abstract",
"filemanager",
"error",
"together_response",
"client",
"utils",
"Complete",
"AsyncComplete",
"Completion",
"Embeddings",
"Files",
"Finetune",
"Image",
"Models",
]