together 1.5.3__tar.gz → 1.5.4__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.
- {together-1.5.3 → together-1.5.4}/PKG-INFO +1 -1
- {together-1.5.3 → together-1.5.4}/pyproject.toml +3 -4
- {together-1.5.3 → together-1.5.4}/src/together/client.py +5 -0
- together-1.5.4/src/together/resources/code_interpreter.py +58 -0
- together-1.5.4/src/together/types/code_interpreter.py +46 -0
- {together-1.5.3 → together-1.5.4}/LICENSE +0 -0
- {together-1.5.3 → together-1.5.4}/README.md +0 -0
- {together-1.5.3 → together-1.5.4}/src/together/__init__.py +0 -0
- {together-1.5.3 → together-1.5.4}/src/together/abstract/__init__.py +0 -0
- {together-1.5.3 → together-1.5.4}/src/together/abstract/api_requestor.py +0 -0
- {together-1.5.3 → together-1.5.4}/src/together/cli/__init__.py +0 -0
- {together-1.5.3 → together-1.5.4}/src/together/cli/api/__init__.py +0 -0
- {together-1.5.3 → together-1.5.4}/src/together/cli/api/chat.py +0 -0
- {together-1.5.3 → together-1.5.4}/src/together/cli/api/completions.py +0 -0
- {together-1.5.3 → together-1.5.4}/src/together/cli/api/endpoints.py +0 -0
- {together-1.5.3 → together-1.5.4}/src/together/cli/api/files.py +0 -0
- {together-1.5.3 → together-1.5.4}/src/together/cli/api/finetune.py +0 -0
- {together-1.5.3 → together-1.5.4}/src/together/cli/api/images.py +0 -0
- {together-1.5.3 → together-1.5.4}/src/together/cli/api/models.py +0 -0
- {together-1.5.3 → together-1.5.4}/src/together/cli/api/utils.py +0 -0
- {together-1.5.3 → together-1.5.4}/src/together/cli/cli.py +0 -0
- {together-1.5.3 → together-1.5.4}/src/together/constants.py +0 -0
- {together-1.5.3 → together-1.5.4}/src/together/error.py +0 -0
- {together-1.5.3 → together-1.5.4}/src/together/filemanager.py +0 -0
- {together-1.5.3 → together-1.5.4}/src/together/legacy/__init__.py +0 -0
- {together-1.5.3 → together-1.5.4}/src/together/legacy/base.py +0 -0
- {together-1.5.3 → together-1.5.4}/src/together/legacy/complete.py +0 -0
- {together-1.5.3 → together-1.5.4}/src/together/legacy/embeddings.py +0 -0
- {together-1.5.3 → together-1.5.4}/src/together/legacy/files.py +0 -0
- {together-1.5.3 → together-1.5.4}/src/together/legacy/finetune.py +0 -0
- {together-1.5.3 → together-1.5.4}/src/together/legacy/images.py +0 -0
- {together-1.5.3 → together-1.5.4}/src/together/legacy/models.py +0 -0
- {together-1.5.3 → together-1.5.4}/src/together/resources/__init__.py +0 -0
- {together-1.5.3 → together-1.5.4}/src/together/resources/audio/__init__.py +0 -0
- {together-1.5.3 → together-1.5.4}/src/together/resources/audio/speech.py +0 -0
- {together-1.5.3 → together-1.5.4}/src/together/resources/chat/__init__.py +0 -0
- {together-1.5.3 → together-1.5.4}/src/together/resources/chat/completions.py +0 -0
- {together-1.5.3 → together-1.5.4}/src/together/resources/completions.py +0 -0
- {together-1.5.3 → together-1.5.4}/src/together/resources/embeddings.py +0 -0
- {together-1.5.3 → together-1.5.4}/src/together/resources/endpoints.py +0 -0
- {together-1.5.3 → together-1.5.4}/src/together/resources/files.py +0 -0
- {together-1.5.3 → together-1.5.4}/src/together/resources/finetune.py +0 -0
- {together-1.5.3 → together-1.5.4}/src/together/resources/images.py +0 -0
- {together-1.5.3 → together-1.5.4}/src/together/resources/models.py +0 -0
- {together-1.5.3 → together-1.5.4}/src/together/resources/rerank.py +0 -0
- {together-1.5.3 → together-1.5.4}/src/together/together_response.py +0 -0
- {together-1.5.3 → together-1.5.4}/src/together/types/__init__.py +0 -0
- {together-1.5.3 → together-1.5.4}/src/together/types/abstract.py +0 -0
- {together-1.5.3 → together-1.5.4}/src/together/types/audio_speech.py +0 -0
- {together-1.5.3 → together-1.5.4}/src/together/types/chat_completions.py +0 -0
- {together-1.5.3 → together-1.5.4}/src/together/types/common.py +0 -0
- {together-1.5.3 → together-1.5.4}/src/together/types/completions.py +0 -0
- {together-1.5.3 → together-1.5.4}/src/together/types/embeddings.py +0 -0
- {together-1.5.3 → together-1.5.4}/src/together/types/endpoints.py +0 -0
- {together-1.5.3 → together-1.5.4}/src/together/types/error.py +0 -0
- {together-1.5.3 → together-1.5.4}/src/together/types/files.py +0 -0
- {together-1.5.3 → together-1.5.4}/src/together/types/finetune.py +0 -0
- {together-1.5.3 → together-1.5.4}/src/together/types/images.py +0 -0
- {together-1.5.3 → together-1.5.4}/src/together/types/models.py +0 -0
- {together-1.5.3 → together-1.5.4}/src/together/types/rerank.py +0 -0
- {together-1.5.3 → together-1.5.4}/src/together/utils/__init__.py +0 -0
- {together-1.5.3 → together-1.5.4}/src/together/utils/_log.py +0 -0
- {together-1.5.3 → together-1.5.4}/src/together/utils/api_helpers.py +0 -0
- {together-1.5.3 → together-1.5.4}/src/together/utils/files.py +0 -0
- {together-1.5.3 → together-1.5.4}/src/together/utils/tools.py +0 -0
- {together-1.5.3 → together-1.5.4}/src/together/version.py +0 -0
|
@@ -12,10 +12,8 @@ build-backend = "poetry.masonry.api"
|
|
|
12
12
|
|
|
13
13
|
[tool.poetry]
|
|
14
14
|
name = "together"
|
|
15
|
-
version = "1.5.
|
|
16
|
-
authors = [
|
|
17
|
-
"Together AI <support@together.ai>"
|
|
18
|
-
]
|
|
15
|
+
version = "1.5.4"
|
|
16
|
+
authors = ["Together AI <support@together.ai>"]
|
|
19
17
|
description = "Python client for Together's Cloud Platform!"
|
|
20
18
|
readme = "README.md"
|
|
21
19
|
license = "Apache-2.0"
|
|
@@ -65,6 +63,7 @@ optional = true
|
|
|
65
63
|
[tool.poetry.group.tests.dependencies]
|
|
66
64
|
pytest = ">=7.4.2,<9.0.0"
|
|
67
65
|
pytest-watch = "^4.2.0"
|
|
66
|
+
pytest-mock = "^3.14.0"
|
|
68
67
|
tox = "^4.14.1"
|
|
69
68
|
|
|
70
69
|
[tool.poetry.group.examples]
|
|
@@ -7,6 +7,7 @@ from typing import Dict, TYPE_CHECKING
|
|
|
7
7
|
from together import resources
|
|
8
8
|
from together.constants import BASE_URL, MAX_RETRIES, TIMEOUT_SECS
|
|
9
9
|
from together.error import AuthenticationError
|
|
10
|
+
from together.resources.code_interpreter import CodeInterpreter
|
|
10
11
|
from together.types import TogetherClient
|
|
11
12
|
from together.utils import enforce_trailing_slash
|
|
12
13
|
from together.utils.api_helpers import get_google_colab_secret
|
|
@@ -22,6 +23,7 @@ class Together:
|
|
|
22
23
|
fine_tuning: resources.FineTuning
|
|
23
24
|
rerank: resources.Rerank
|
|
24
25
|
audio: resources.Audio
|
|
26
|
+
code_interpreter: CodeInterpreter
|
|
25
27
|
|
|
26
28
|
# client options
|
|
27
29
|
client: TogetherClient
|
|
@@ -87,6 +89,7 @@ class Together:
|
|
|
87
89
|
self.rerank = resources.Rerank(self.client)
|
|
88
90
|
self.audio = resources.Audio(self.client)
|
|
89
91
|
self.endpoints = resources.Endpoints(self.client)
|
|
92
|
+
self.code_interpreter = CodeInterpreter(self.client)
|
|
90
93
|
|
|
91
94
|
|
|
92
95
|
class AsyncTogether:
|
|
@@ -98,6 +101,7 @@ class AsyncTogether:
|
|
|
98
101
|
models: resources.AsyncModels
|
|
99
102
|
fine_tuning: resources.AsyncFineTuning
|
|
100
103
|
rerank: resources.AsyncRerank
|
|
104
|
+
code_interpreter: CodeInterpreter
|
|
101
105
|
|
|
102
106
|
# client options
|
|
103
107
|
client: TogetherClient
|
|
@@ -161,6 +165,7 @@ class AsyncTogether:
|
|
|
161
165
|
self.models = resources.AsyncModels(self.client)
|
|
162
166
|
self.fine_tuning = resources.AsyncFineTuning(self.client)
|
|
163
167
|
self.rerank = resources.AsyncRerank(self.client)
|
|
168
|
+
self.code_interpreter = CodeInterpreter(self.client)
|
|
164
169
|
|
|
165
170
|
|
|
166
171
|
Client = Together
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import Dict, Literal, Optional
|
|
4
|
+
|
|
5
|
+
from together.abstract import api_requestor
|
|
6
|
+
from together.together_response import TogetherResponse
|
|
7
|
+
from together.types import TogetherClient, TogetherRequest
|
|
8
|
+
from together.types.code_interpreter import ExecuteResponse
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class CodeInterpreter:
|
|
12
|
+
"""Code Interpreter resource for executing code snippets."""
|
|
13
|
+
|
|
14
|
+
def __init__(self, client: TogetherClient) -> None:
|
|
15
|
+
self._client = client
|
|
16
|
+
|
|
17
|
+
def run(
|
|
18
|
+
self,
|
|
19
|
+
code: str,
|
|
20
|
+
language: Literal["python"],
|
|
21
|
+
session_id: Optional[str] = None,
|
|
22
|
+
) -> ExecuteResponse:
|
|
23
|
+
"""Execute a code snippet.
|
|
24
|
+
|
|
25
|
+
Args:
|
|
26
|
+
code (str): Code snippet to execute
|
|
27
|
+
language (str): Programming language for the code to execute. Currently only supports Python.
|
|
28
|
+
session_id (str, optional): Identifier of the current session. Used to make follow-up calls.
|
|
29
|
+
|
|
30
|
+
Returns:
|
|
31
|
+
ExecuteResponse: Object containing execution results and outputs
|
|
32
|
+
"""
|
|
33
|
+
requestor = api_requestor.APIRequestor(
|
|
34
|
+
client=self._client,
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
data: Dict[str, str] = {
|
|
38
|
+
"code": code,
|
|
39
|
+
"language": language,
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if session_id is not None:
|
|
43
|
+
data["session_id"] = session_id
|
|
44
|
+
|
|
45
|
+
# Use absolute URL to bypass the /v1 prefix
|
|
46
|
+
response, _, _ = requestor.request(
|
|
47
|
+
options=TogetherRequest(
|
|
48
|
+
method="POST",
|
|
49
|
+
url="/tci/execute",
|
|
50
|
+
params=data,
|
|
51
|
+
),
|
|
52
|
+
stream=False,
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
assert isinstance(response, TogetherResponse)
|
|
56
|
+
|
|
57
|
+
# Return the response data directly since our types match the API structure
|
|
58
|
+
return ExecuteResponse(**response.data)
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import Any, Dict, Literal, Union
|
|
4
|
+
|
|
5
|
+
from pydantic import Field
|
|
6
|
+
|
|
7
|
+
from together.types.endpoints import TogetherJSONModel
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class InterpreterOutput(TogetherJSONModel):
|
|
11
|
+
"""Base class for interpreter output types."""
|
|
12
|
+
|
|
13
|
+
type: Literal["stdout", "stderr", "error", "display_data", "execute_result"] = (
|
|
14
|
+
Field(description="The type of output")
|
|
15
|
+
)
|
|
16
|
+
data: Union[str, Dict[str, Any]] = Field(description="The output data")
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class ExecuteResponseData(TogetherJSONModel):
|
|
20
|
+
"""Data from code execution response."""
|
|
21
|
+
|
|
22
|
+
outputs: list[InterpreterOutput] = Field(
|
|
23
|
+
description="List of outputs from execution", default_factory=list
|
|
24
|
+
)
|
|
25
|
+
errors: Union[str, None] = Field(
|
|
26
|
+
description="Any errors that occurred during execution", default=None
|
|
27
|
+
)
|
|
28
|
+
session_id: str = Field(
|
|
29
|
+
description="Identifier of the current session. Used to make follow-up calls."
|
|
30
|
+
)
|
|
31
|
+
status: str = Field(description="Status of the execution", default="completed")
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class ExecuteResponse(TogetherJSONModel):
|
|
35
|
+
"""Response from code execution."""
|
|
36
|
+
|
|
37
|
+
data: ExecuteResponseData = Field(
|
|
38
|
+
description="The response data containing outputs and session information"
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
__all__ = [
|
|
43
|
+
"InterpreterOutput",
|
|
44
|
+
"ExecuteResponseData",
|
|
45
|
+
"ExecuteResponse",
|
|
46
|
+
]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|