latitude-sdk 0.1.0b4__py3-none-any.whl → 0.1.0b6__py3-none-any.whl
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.
- latitude_sdk/sdk/latitude.py +29 -16
- latitude_sdk/sdk/types.py +11 -12
- latitude_sdk/util/utils.py +10 -2
- {latitude_sdk-0.1.0b4.dist-info → latitude_sdk-0.1.0b6.dist-info}/METADATA +4 -3
- {latitude_sdk-0.1.0b4.dist-info → latitude_sdk-0.1.0b6.dist-info}/RECORD +6 -6
- {latitude_sdk-0.1.0b4.dist-info → latitude_sdk-0.1.0b6.dist-info}/WHEEL +0 -0
latitude_sdk/sdk/latitude.py
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
from typing import Optional
|
2
2
|
|
3
|
+
from latitude_telemetry import InternalOptions as TelemetryInternalOptions
|
4
|
+
from latitude_telemetry import Telemetry, TelemetryOptions
|
5
|
+
|
3
6
|
from latitude_sdk.client import Client, ClientOptions, RouterOptions
|
4
7
|
from latitude_sdk.env import env
|
5
8
|
from latitude_sdk.sdk.evaluations import Evaluations
|
@@ -18,6 +21,7 @@ class InternalOptions(Model):
|
|
18
21
|
|
19
22
|
|
20
23
|
class LatitudeOptions(SdkOptions, Model):
|
24
|
+
telemetry: Optional[TelemetryOptions] = None
|
21
25
|
internal: Optional[InternalOptions] = None
|
22
26
|
|
23
27
|
|
@@ -35,42 +39,51 @@ DEFAULT_INTERNAL_OPTIONS = InternalOptions(
|
|
35
39
|
)
|
36
40
|
|
37
41
|
|
38
|
-
DEFAULT_LATITUDE_OPTIONS = LatitudeOptions(
|
42
|
+
DEFAULT_LATITUDE_OPTIONS = LatitudeOptions(
|
43
|
+
telemetry=None, # Note: Telemetry is opt-in
|
44
|
+
internal=DEFAULT_INTERNAL_OPTIONS,
|
45
|
+
)
|
39
46
|
|
40
47
|
|
41
48
|
class Latitude:
|
42
49
|
_options: LatitudeOptions
|
43
50
|
_client: Client
|
44
51
|
|
52
|
+
telemetry: Optional[Telemetry]
|
53
|
+
|
45
54
|
prompts: Prompts
|
46
55
|
logs: Logs
|
47
56
|
evaluations: Evaluations
|
48
57
|
|
49
58
|
def __init__(self, api_key: str, options: LatitudeOptions):
|
50
|
-
options.internal = options.internal or
|
51
|
-
options.internal = InternalOptions(**{**dict(DEFAULT_INTERNAL_OPTIONS), **dict(options.internal)})
|
59
|
+
options.internal = InternalOptions(**{**dict(DEFAULT_INTERNAL_OPTIONS), **dict(options.internal or {})})
|
52
60
|
options = LatitudeOptions(**{**dict(DEFAULT_LATITUDE_OPTIONS), **dict(options)})
|
61
|
+
self._options = options
|
53
62
|
|
54
|
-
assert
|
55
|
-
assert
|
56
|
-
assert
|
57
|
-
assert
|
58
|
-
assert
|
59
|
-
assert
|
63
|
+
assert self._options.internal is not None
|
64
|
+
assert self._options.internal.gateway is not None
|
65
|
+
assert self._options.internal.source is not None
|
66
|
+
assert self._options.internal.retries is not None
|
67
|
+
assert self._options.internal.delay is not None
|
68
|
+
assert self._options.internal.timeout is not None
|
60
69
|
|
61
|
-
self._options = options
|
62
70
|
self._client = Client(
|
63
71
|
ClientOptions(
|
64
72
|
api_key=api_key,
|
65
|
-
retries=
|
66
|
-
delay=
|
67
|
-
timeout=
|
68
|
-
source=
|
69
|
-
router=RouterOptions(gateway=
|
73
|
+
retries=self._options.internal.retries,
|
74
|
+
delay=self._options.internal.delay,
|
75
|
+
timeout=self._options.internal.timeout,
|
76
|
+
source=self._options.internal.source,
|
77
|
+
router=RouterOptions(gateway=self._options.internal.gateway),
|
70
78
|
)
|
71
79
|
)
|
72
80
|
|
81
|
+
if self._options.telemetry:
|
82
|
+
self._options.telemetry.internal = TelemetryInternalOptions(
|
83
|
+
**{**dict(self._options.internal), **dict(self._options.telemetry.internal or {})}
|
84
|
+
)
|
85
|
+
self.telemetry = Telemetry(api_key, self._options.telemetry)
|
86
|
+
|
73
87
|
self.prompts = Prompts(self._client, self._options)
|
74
88
|
self.logs = Logs(self._client, self._options)
|
75
89
|
self.evaluations = Evaluations(self._client, self._options)
|
76
|
-
# TODO: Telemetry - needs Telemetry SDK in Python
|
latitude_sdk/sdk/types.py
CHANGED
@@ -54,15 +54,15 @@ class FileContent(Model):
|
|
54
54
|
|
55
55
|
class ToolCallContent(Model):
|
56
56
|
type: Literal[ContentType.ToolCall] = ContentType.ToolCall
|
57
|
-
|
58
|
-
|
59
|
-
|
57
|
+
id: str = Field(alias=str("toolCallId"))
|
58
|
+
name: str = Field(alias=str("toolName"))
|
59
|
+
arguments: Dict[str, Any] = Field(alias=str("args"))
|
60
60
|
|
61
61
|
|
62
62
|
class ToolResultContent(Model):
|
63
63
|
type: Literal[ContentType.ToolResult] = ContentType.ToolResult
|
64
|
-
|
65
|
-
|
64
|
+
id: str = Field(alias=str("toolCallId"))
|
65
|
+
name: str = Field(alias=str("toolName"))
|
66
66
|
result: str
|
67
67
|
is_error: Optional[bool] = Field(default=None, alias=str("isError"))
|
68
68
|
|
@@ -95,16 +95,9 @@ class UserMessage(Model):
|
|
95
95
|
name: Optional[str] = None
|
96
96
|
|
97
97
|
|
98
|
-
class ToolCall(Model):
|
99
|
-
id: str
|
100
|
-
name: str
|
101
|
-
arguments: Dict[str, Any]
|
102
|
-
|
103
|
-
|
104
98
|
class AssistantMessage(Model):
|
105
99
|
role: Literal[MessageRole.Assistant] = MessageRole.Assistant
|
106
100
|
content: Union[str, List[Union[TextContent, ToolCallContent]]]
|
107
|
-
tool_calls: Optional[List[ToolCall]] = Field(default=None, alias=str("toolCalls"))
|
108
101
|
|
109
102
|
|
110
103
|
class ToolMessage(Model):
|
@@ -121,6 +114,12 @@ class ModelUsage(Model):
|
|
121
114
|
total_tokens: int = Field(alias=str("totalTokens"))
|
122
115
|
|
123
116
|
|
117
|
+
class ToolCall(Model):
|
118
|
+
id: str
|
119
|
+
name: str
|
120
|
+
arguments: Dict[str, Any]
|
121
|
+
|
122
|
+
|
124
123
|
class StreamTypes(StrEnum):
|
125
124
|
Text = "text"
|
126
125
|
Object = "object"
|
latitude_sdk/util/utils.py
CHANGED
@@ -3,7 +3,7 @@ from enum import Enum
|
|
3
3
|
from typing import Any, Callable, List, TypeVar
|
4
4
|
|
5
5
|
import pydantic
|
6
|
-
from typing_extensions import ParamSpec
|
6
|
+
from typing_extensions import ParamSpec, Self
|
7
7
|
|
8
8
|
T = TypeVar("T", str, bool, int, List[str])
|
9
9
|
|
@@ -49,7 +49,15 @@ class StrEnum(str, Enum):
|
|
49
49
|
return str(self.value)
|
50
50
|
|
51
51
|
@classmethod
|
52
|
-
def
|
52
|
+
def entries(cls) -> List[Self]:
|
53
|
+
return list(cls)
|
54
|
+
|
55
|
+
@classmethod
|
56
|
+
def names(cls) -> List[str]:
|
57
|
+
return [v.name for v in cls]
|
58
|
+
|
59
|
+
@classmethod
|
60
|
+
def values(cls) -> List[str]:
|
53
61
|
return [v.value for v in cls]
|
54
62
|
|
55
63
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: latitude-sdk
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.0b6
|
4
4
|
Summary: Latitude SDK for Python
|
5
5
|
Project-URL: repository, https://github.com/latitude-dev/latitude-llm/tree/main/packages/sdks/python
|
6
6
|
Project-URL: homepage, https://github.com/latitude-dev/latitude-llm/tree/main/packages/sdks/python#readme
|
@@ -8,9 +8,10 @@ Project-URL: documentation, https://github.com/latitude-dev/latitude-llm/tree/ma
|
|
8
8
|
Author-email: Latitude Data SL <hello@latitude.so>
|
9
9
|
Maintainer-email: Latitude Data SL <hello@latitude.so>
|
10
10
|
License-Expression: LGPL-3.0
|
11
|
-
Requires-Python: >=3.
|
11
|
+
Requires-Python: >=3.9
|
12
12
|
Requires-Dist: httpx-sse>=0.4.0
|
13
13
|
Requires-Dist: httpx>=0.28.1
|
14
|
+
Requires-Dist: latitude-telemetry>=0.1.0b4
|
14
15
|
Requires-Dist: pydantic>=2.10.3
|
15
16
|
Requires-Dist: typing-extensions>=4.12.2
|
16
17
|
Description-Content-Type: text/markdown
|
@@ -21,7 +22,7 @@ Description-Content-Type: text/markdown
|
|
21
22
|
pip install latitude-sdk
|
22
23
|
```
|
23
24
|
|
24
|
-
Requires Python `3.
|
25
|
+
Requires Python `3.9` or higher.
|
25
26
|
|
26
27
|
Go to the [documentation](https://docs.latitude.so/guides/sdk/python) to learn more.
|
27
28
|
|
@@ -9,12 +9,12 @@ latitude_sdk/env/env.py,sha256=MnXexPOHE6aXcAszrDCbW7hzACUv4YtU1bfxpYwvHNw,455
|
|
9
9
|
latitude_sdk/sdk/__init__.py,sha256=C9LlIjfnrS7KOK3-ruXKmbT77nSQMm23nZ6-t8sO8ME,137
|
10
10
|
latitude_sdk/sdk/errors.py,sha256=9GlGdDE8LGy3dE2Ry_BipBg-tDbQx7LWXJfSnTJSSBE,1747
|
11
11
|
latitude_sdk/sdk/evaluations.py,sha256=ASWfNfH124qeahzhAn-gb2Ep4QIew5uDveY5NbNsNfk,2086
|
12
|
-
latitude_sdk/sdk/latitude.py,sha256=
|
12
|
+
latitude_sdk/sdk/latitude.py,sha256=tVXxQeq9WAMv3ndsCE8V2cbzmGy3roUCMldhJiXOXoE,2985
|
13
13
|
latitude_sdk/sdk/logs.py,sha256=UBlQzNq8AtWVkeVztqUWTs78jGkfA8a2r6wOhasUpxs,2056
|
14
14
|
latitude_sdk/sdk/prompts.py,sha256=VaqI3qbVpcSbiT5xtd63eEwbIGTdMusDSoZeQZO8z4g,10134
|
15
|
-
latitude_sdk/sdk/types.py,sha256=
|
15
|
+
latitude_sdk/sdk/types.py,sha256=1sBtKNppipuayPj3j8qoUzMekIO0DxSBBXYNCEVsZjU,7866
|
16
16
|
latitude_sdk/util/__init__.py,sha256=alIDGBnxWH4JvP-UW-7N99seBBi0r1GV1h8f1ERFBec,21
|
17
|
-
latitude_sdk/util/utils.py,sha256=
|
18
|
-
latitude_sdk-0.1.
|
19
|
-
latitude_sdk-0.1.
|
20
|
-
latitude_sdk-0.1.
|
17
|
+
latitude_sdk/util/utils.py,sha256=MzEEIhM7yQKJ0btcf1U9rcRz7geHkYXEjGCDnLpNCSw,2885
|
18
|
+
latitude_sdk-0.1.0b6.dist-info/METADATA,sha256=9oJlJXlHpvOVLoDS8Y-UovOSVfmTg_hUFMpYCIZkcWs,2025
|
19
|
+
latitude_sdk-0.1.0b6.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
20
|
+
latitude_sdk-0.1.0b6.dist-info/RECORD,,
|
File without changes
|