together 1.4.4__tar.gz → 1.4.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. {together-1.4.4 → together-1.4.5}/PKG-INFO +1 -1
  2. {together-1.4.4 → together-1.4.5}/pyproject.toml +1 -1
  3. {together-1.4.4 → together-1.4.5}/src/together/client.py +9 -1
  4. {together-1.4.4 → together-1.4.5}/src/together/utils/api_helpers.py +40 -0
  5. {together-1.4.4 → together-1.4.5}/LICENSE +0 -0
  6. {together-1.4.4 → together-1.4.5}/README.md +0 -0
  7. {together-1.4.4 → together-1.4.5}/src/together/__init__.py +0 -0
  8. {together-1.4.4 → together-1.4.5}/src/together/abstract/__init__.py +0 -0
  9. {together-1.4.4 → together-1.4.5}/src/together/abstract/api_requestor.py +0 -0
  10. {together-1.4.4 → together-1.4.5}/src/together/cli/__init__.py +0 -0
  11. {together-1.4.4 → together-1.4.5}/src/together/cli/api/__init__.py +0 -0
  12. {together-1.4.4 → together-1.4.5}/src/together/cli/api/chat.py +0 -0
  13. {together-1.4.4 → together-1.4.5}/src/together/cli/api/completions.py +0 -0
  14. {together-1.4.4 → together-1.4.5}/src/together/cli/api/endpoints.py +0 -0
  15. {together-1.4.4 → together-1.4.5}/src/together/cli/api/files.py +0 -0
  16. {together-1.4.4 → together-1.4.5}/src/together/cli/api/finetune.py +0 -0
  17. {together-1.4.4 → together-1.4.5}/src/together/cli/api/images.py +0 -0
  18. {together-1.4.4 → together-1.4.5}/src/together/cli/api/models.py +0 -0
  19. {together-1.4.4 → together-1.4.5}/src/together/cli/api/utils.py +0 -0
  20. {together-1.4.4 → together-1.4.5}/src/together/cli/cli.py +0 -0
  21. {together-1.4.4 → together-1.4.5}/src/together/constants.py +0 -0
  22. {together-1.4.4 → together-1.4.5}/src/together/error.py +0 -0
  23. {together-1.4.4 → together-1.4.5}/src/together/filemanager.py +0 -0
  24. {together-1.4.4 → together-1.4.5}/src/together/legacy/__init__.py +0 -0
  25. {together-1.4.4 → together-1.4.5}/src/together/legacy/base.py +0 -0
  26. {together-1.4.4 → together-1.4.5}/src/together/legacy/complete.py +0 -0
  27. {together-1.4.4 → together-1.4.5}/src/together/legacy/embeddings.py +0 -0
  28. {together-1.4.4 → together-1.4.5}/src/together/legacy/files.py +0 -0
  29. {together-1.4.4 → together-1.4.5}/src/together/legacy/finetune.py +0 -0
  30. {together-1.4.4 → together-1.4.5}/src/together/legacy/images.py +0 -0
  31. {together-1.4.4 → together-1.4.5}/src/together/legacy/models.py +0 -0
  32. {together-1.4.4 → together-1.4.5}/src/together/resources/__init__.py +0 -0
  33. {together-1.4.4 → together-1.4.5}/src/together/resources/audio/__init__.py +0 -0
  34. {together-1.4.4 → together-1.4.5}/src/together/resources/audio/speech.py +0 -0
  35. {together-1.4.4 → together-1.4.5}/src/together/resources/chat/__init__.py +0 -0
  36. {together-1.4.4 → together-1.4.5}/src/together/resources/chat/completions.py +0 -0
  37. {together-1.4.4 → together-1.4.5}/src/together/resources/completions.py +0 -0
  38. {together-1.4.4 → together-1.4.5}/src/together/resources/embeddings.py +0 -0
  39. {together-1.4.4 → together-1.4.5}/src/together/resources/endpoints.py +0 -0
  40. {together-1.4.4 → together-1.4.5}/src/together/resources/files.py +0 -0
  41. {together-1.4.4 → together-1.4.5}/src/together/resources/finetune.py +0 -0
  42. {together-1.4.4 → together-1.4.5}/src/together/resources/images.py +0 -0
  43. {together-1.4.4 → together-1.4.5}/src/together/resources/models.py +0 -0
  44. {together-1.4.4 → together-1.4.5}/src/together/resources/rerank.py +0 -0
  45. {together-1.4.4 → together-1.4.5}/src/together/together_response.py +0 -0
  46. {together-1.4.4 → together-1.4.5}/src/together/types/__init__.py +0 -0
  47. {together-1.4.4 → together-1.4.5}/src/together/types/abstract.py +0 -0
  48. {together-1.4.4 → together-1.4.5}/src/together/types/audio_speech.py +0 -0
  49. {together-1.4.4 → together-1.4.5}/src/together/types/chat_completions.py +0 -0
  50. {together-1.4.4 → together-1.4.5}/src/together/types/common.py +0 -0
  51. {together-1.4.4 → together-1.4.5}/src/together/types/completions.py +0 -0
  52. {together-1.4.4 → together-1.4.5}/src/together/types/embeddings.py +0 -0
  53. {together-1.4.4 → together-1.4.5}/src/together/types/endpoints.py +0 -0
  54. {together-1.4.4 → together-1.4.5}/src/together/types/error.py +0 -0
  55. {together-1.4.4 → together-1.4.5}/src/together/types/files.py +0 -0
  56. {together-1.4.4 → together-1.4.5}/src/together/types/finetune.py +0 -0
  57. {together-1.4.4 → together-1.4.5}/src/together/types/images.py +0 -0
  58. {together-1.4.4 → together-1.4.5}/src/together/types/models.py +0 -0
  59. {together-1.4.4 → together-1.4.5}/src/together/types/rerank.py +0 -0
  60. {together-1.4.4 → together-1.4.5}/src/together/utils/__init__.py +0 -0
  61. {together-1.4.4 → together-1.4.5}/src/together/utils/_log.py +0 -0
  62. {together-1.4.4 → together-1.4.5}/src/together/utils/files.py +0 -0
  63. {together-1.4.4 → together-1.4.5}/src/together/utils/tools.py +0 -0
  64. {together-1.4.4 → together-1.4.5}/src/together/version.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: together
3
- Version: 1.4.4
3
+ Version: 1.4.5
4
4
  Summary: Python client for Together's Cloud Platform!
5
5
  License: Apache-2.0
6
6
  Author: Together AI
@@ -12,7 +12,7 @@ build-backend = "poetry.masonry.api"
12
12
 
13
13
  [tool.poetry]
14
14
  name = "together"
15
- version = "1.4.4"
15
+ version = "1.4.5"
16
16
  authors = [
17
17
  "Together AI <support@together.ai>"
18
18
  ]
@@ -1,13 +1,15 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  import os
4
- from typing import Dict
4
+ import sys
5
+ from typing import Dict, TYPE_CHECKING
5
6
 
6
7
  from together import resources
7
8
  from together.constants import BASE_URL, MAX_RETRIES, TIMEOUT_SECS
8
9
  from together.error import AuthenticationError
9
10
  from together.types import TogetherClient
10
11
  from together.utils import enforce_trailing_slash
12
+ from together.utils.api_helpers import get_google_colab_secret
11
13
 
12
14
 
13
15
  class Together:
@@ -44,6 +46,9 @@ class Together:
44
46
  if not api_key:
45
47
  api_key = os.environ.get("TOGETHER_API_KEY")
46
48
 
49
+ if not api_key and "google.colab" in sys.modules:
50
+ api_key = get_google_colab_secret("TOGETHER_API_KEY")
51
+
47
52
  if not api_key:
48
53
  raise AuthenticationError(
49
54
  "The api_key client option must be set either by passing api_key to the client or by setting the "
@@ -117,6 +122,9 @@ class AsyncTogether:
117
122
  if not api_key:
118
123
  api_key = os.environ.get("TOGETHER_API_KEY")
119
124
 
125
+ if not api_key and "google.colab" in sys.modules:
126
+ api_key = get_google_colab_secret("TOGETHER_API_KEY")
127
+
120
128
  if not api_key:
121
129
  raise AuthenticationError(
122
130
  "The api_key client option must be set either by passing api_key to the client or by setting the "
@@ -2,6 +2,7 @@ from __future__ import annotations
2
2
 
3
3
  import json
4
4
  import os
5
+ import sys
5
6
  import platform
6
7
  from typing import TYPE_CHECKING, Any, Dict
7
8
 
@@ -12,6 +13,7 @@ if TYPE_CHECKING:
12
13
  import together
13
14
  from together import error
14
15
  from together.utils._log import _console_log_level
16
+ from together.utils import log_info
15
17
 
16
18
 
17
19
  def get_headers(
@@ -82,3 +84,41 @@ def default_api_key(api_key: str | None = None) -> str | None:
82
84
  return os.environ.get("TOGETHER_API_KEY")
83
85
 
84
86
  raise error.AuthenticationError(together.constants.MISSING_API_KEY_MESSAGE)
87
+
88
+
89
+ def get_google_colab_secret(secret_name: str = "TOGETHER_API_KEY") -> str | None:
90
+ """
91
+ Checks to see if the user is running in Google Colab, and looks for the Together API Key secret.
92
+
93
+ Args:
94
+ secret_name (str, optional). Defaults to TOGETHER_API_KEY
95
+
96
+ Returns:
97
+ str: if the API key is found; None if an error occurred or the secret was not found.
98
+ """
99
+ # If running in Google Colab, check for Together in notebook secrets
100
+ if "google.colab" in sys.modules:
101
+ if TYPE_CHECKING:
102
+ from google.colab import userdata # type: ignore
103
+ else:
104
+ from google.colab import userdata
105
+
106
+ try:
107
+ api_key = userdata.get(secret_name)
108
+ if not isinstance(api_key, str):
109
+ return None
110
+ else:
111
+ return str(api_key)
112
+ except userdata.NotebookAccessError:
113
+ log_info(
114
+ "The TOGETHER_API_KEY Colab secret was found, but notebook access is disabled. Please enable notebook "
115
+ "access for the secret."
116
+ )
117
+ except userdata.SecretNotFoundError:
118
+ # warn and carry on
119
+ log_info("Colab: No Google Colab secret named TOGETHER_API_KEY was found.")
120
+
121
+ return None
122
+
123
+ else:
124
+ return None
File without changes
File without changes
File without changes