promptlayer 1.0.35__py3-none-any.whl → 1.0.78__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.
- promptlayer/__init__.py +37 -2
- promptlayer/exceptions.py +119 -0
- promptlayer/groups/__init__.py +9 -5
- promptlayer/groups/groups.py +4 -6
- promptlayer/promptlayer.py +237 -104
- promptlayer/promptlayer_base.py +31 -40
- promptlayer/promptlayer_mixins.py +216 -65
- promptlayer/span_exporter.py +19 -24
- promptlayer/streaming/__init__.py +64 -0
- promptlayer/streaming/blueprint_builder.py +382 -0
- promptlayer/streaming/response_handlers.py +960 -0
- promptlayer/streaming/stream_processor.py +106 -0
- promptlayer/templates.py +14 -12
- promptlayer/track/__init__.py +32 -20
- promptlayer/track/track.py +47 -30
- promptlayer/types/prompt_template.py +33 -1
- promptlayer/utils.py +1256 -967
- {promptlayer-1.0.35.dist-info → promptlayer-1.0.78.dist-info}/METADATA +16 -12
- promptlayer-1.0.78.dist-info/RECORD +23 -0
- {promptlayer-1.0.35.dist-info → promptlayer-1.0.78.dist-info}/WHEEL +1 -1
- promptlayer-1.0.35.dist-info/RECORD +0 -18
- {promptlayer-1.0.35.dist-info → promptlayer-1.0.78.dist-info/licenses}/LICENSE +0 -0
promptlayer/__init__.py
CHANGED
|
@@ -1,4 +1,39 @@
|
|
|
1
|
+
from .exceptions import (
|
|
2
|
+
PromptLayerAPIConnectionError,
|
|
3
|
+
PromptLayerAPIError,
|
|
4
|
+
PromptLayerAPIStatusError,
|
|
5
|
+
PromptLayerAPITimeoutError,
|
|
6
|
+
PromptLayerAuthenticationError,
|
|
7
|
+
PromptLayerBadRequestError,
|
|
8
|
+
PromptLayerConflictError,
|
|
9
|
+
PromptLayerError,
|
|
10
|
+
PromptLayerInternalServerError,
|
|
11
|
+
PromptLayerNotFoundError,
|
|
12
|
+
PromptLayerPermissionDeniedError,
|
|
13
|
+
PromptLayerRateLimitError,
|
|
14
|
+
PromptLayerUnprocessableEntityError,
|
|
15
|
+
PromptLayerValidationError,
|
|
16
|
+
)
|
|
1
17
|
from .promptlayer import AsyncPromptLayer, PromptLayer
|
|
2
18
|
|
|
3
|
-
__version__ = "1.0.
|
|
4
|
-
__all__ = [
|
|
19
|
+
__version__ = "1.0.78"
|
|
20
|
+
__all__ = [
|
|
21
|
+
"PromptLayer",
|
|
22
|
+
"AsyncPromptLayer",
|
|
23
|
+
"__version__",
|
|
24
|
+
# Exceptions
|
|
25
|
+
"PromptLayerError",
|
|
26
|
+
"PromptLayerAPIError",
|
|
27
|
+
"PromptLayerBadRequestError",
|
|
28
|
+
"PromptLayerAuthenticationError",
|
|
29
|
+
"PromptLayerPermissionDeniedError",
|
|
30
|
+
"PromptLayerNotFoundError",
|
|
31
|
+
"PromptLayerConflictError",
|
|
32
|
+
"PromptLayerUnprocessableEntityError",
|
|
33
|
+
"PromptLayerRateLimitError",
|
|
34
|
+
"PromptLayerInternalServerError",
|
|
35
|
+
"PromptLayerAPIStatusError",
|
|
36
|
+
"PromptLayerAPIConnectionError",
|
|
37
|
+
"PromptLayerAPITimeoutError",
|
|
38
|
+
"PromptLayerValidationError",
|
|
39
|
+
]
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
class PromptLayerError(Exception):
|
|
2
|
+
"""Base exception for all PromptLayer SDK errors."""
|
|
3
|
+
|
|
4
|
+
def __init__(self, message: str, response=None, body=None):
|
|
5
|
+
super().__init__(message)
|
|
6
|
+
self.message = message
|
|
7
|
+
self.response = response
|
|
8
|
+
self.body = body
|
|
9
|
+
|
|
10
|
+
def __str__(self):
|
|
11
|
+
return self.message
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class PromptLayerAPIError(PromptLayerError):
|
|
15
|
+
"""Base exception for API-related errors."""
|
|
16
|
+
|
|
17
|
+
pass
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class PromptLayerBadRequestError(PromptLayerAPIError):
|
|
21
|
+
"""Exception raised for 400 Bad Request errors.
|
|
22
|
+
|
|
23
|
+
Indicates that the request was malformed or contained invalid parameters.
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
pass
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class PromptLayerAuthenticationError(PromptLayerAPIError):
|
|
30
|
+
"""Exception raised for 401 Unauthorized errors.
|
|
31
|
+
|
|
32
|
+
Indicates that the API key is missing, invalid, or expired.
|
|
33
|
+
"""
|
|
34
|
+
|
|
35
|
+
pass
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class PromptLayerPermissionDeniedError(PromptLayerAPIError):
|
|
39
|
+
"""Exception raised for 403 Forbidden errors.
|
|
40
|
+
|
|
41
|
+
Indicates that the API key doesn't have permission to perform the requested operation.
|
|
42
|
+
"""
|
|
43
|
+
|
|
44
|
+
pass
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class PromptLayerNotFoundError(PromptLayerAPIError):
|
|
48
|
+
"""Exception raised for 404 Not Found errors.
|
|
49
|
+
|
|
50
|
+
Indicates that the requested resource (e.g., prompt template) was not found.
|
|
51
|
+
"""
|
|
52
|
+
|
|
53
|
+
pass
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
class PromptLayerConflictError(PromptLayerAPIError):
|
|
57
|
+
"""Exception raised for 409 Conflict errors.
|
|
58
|
+
|
|
59
|
+
Indicates that the request conflicts with the current state of the resource.
|
|
60
|
+
"""
|
|
61
|
+
|
|
62
|
+
pass
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
class PromptLayerUnprocessableEntityError(PromptLayerAPIError):
|
|
66
|
+
"""Exception raised for 422 Unprocessable Entity errors.
|
|
67
|
+
|
|
68
|
+
Indicates that the request was well-formed but contains semantic errors.
|
|
69
|
+
"""
|
|
70
|
+
|
|
71
|
+
pass
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
class PromptLayerRateLimitError(PromptLayerAPIError):
|
|
75
|
+
"""Exception raised for 429 Too Many Requests errors.
|
|
76
|
+
|
|
77
|
+
Indicates that the API rate limit has been exceeded.
|
|
78
|
+
"""
|
|
79
|
+
|
|
80
|
+
pass
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
class PromptLayerInternalServerError(PromptLayerAPIError):
|
|
84
|
+
"""Exception raised for 500+ Internal Server errors.
|
|
85
|
+
|
|
86
|
+
Indicates that the PromptLayer API encountered an internal error.
|
|
87
|
+
"""
|
|
88
|
+
|
|
89
|
+
pass
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
class PromptLayerAPIStatusError(PromptLayerAPIError):
|
|
93
|
+
"""Exception raised for other API errors not covered by specific exception classes."""
|
|
94
|
+
|
|
95
|
+
pass
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
class PromptLayerAPIConnectionError(PromptLayerError):
|
|
99
|
+
"""Exception raised when unable to connect to the API.
|
|
100
|
+
|
|
101
|
+
This can be due to network issues, timeouts, or connection errors.
|
|
102
|
+
"""
|
|
103
|
+
|
|
104
|
+
pass
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
class PromptLayerAPITimeoutError(PromptLayerError):
|
|
108
|
+
"""Exception raised when an API request times out."""
|
|
109
|
+
|
|
110
|
+
pass
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
class PromptLayerValidationError(PromptLayerError):
|
|
114
|
+
"""Exception raised when input validation fails.
|
|
115
|
+
|
|
116
|
+
This can be due to invalid types, out of range values, or malformed data.
|
|
117
|
+
"""
|
|
118
|
+
|
|
119
|
+
pass
|
promptlayer/groups/__init__.py
CHANGED
|
@@ -2,19 +2,23 @@ from promptlayer.groups.groups import acreate, create
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
class GroupManager:
|
|
5
|
-
def __init__(self, api_key: str):
|
|
5
|
+
def __init__(self, api_key: str, base_url: str, throw_on_error: bool):
|
|
6
6
|
self.api_key = api_key
|
|
7
|
+
self.base_url = base_url
|
|
8
|
+
self.throw_on_error = throw_on_error
|
|
7
9
|
|
|
8
10
|
def create(self):
|
|
9
|
-
return create(self.api_key)
|
|
11
|
+
return create(self.api_key, self.base_url, self.throw_on_error)
|
|
10
12
|
|
|
11
13
|
|
|
12
14
|
class AsyncGroupManager:
|
|
13
|
-
def __init__(self, api_key: str):
|
|
15
|
+
def __init__(self, api_key: str, base_url: str, throw_on_error: bool):
|
|
14
16
|
self.api_key = api_key
|
|
17
|
+
self.base_url = base_url
|
|
18
|
+
self.throw_on_error = throw_on_error
|
|
15
19
|
|
|
16
|
-
async def create(self)
|
|
17
|
-
return await acreate(self.api_key)
|
|
20
|
+
async def create(self):
|
|
21
|
+
return await acreate(self.api_key, self.base_url, self.throw_on_error)
|
|
18
22
|
|
|
19
23
|
|
|
20
24
|
__all__ = ["GroupManager", "AsyncGroupManager"]
|
promptlayer/groups/groups.py
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
from promptlayer.utils import apromptlayer_create_group, promptlayer_create_group
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
def create(api_key: str
|
|
5
|
-
|
|
6
|
-
return promptlayer_create_group(api_key)
|
|
4
|
+
def create(api_key: str, base_url: str, throw_on_error: bool):
|
|
5
|
+
return promptlayer_create_group(api_key, base_url, throw_on_error)
|
|
7
6
|
|
|
8
7
|
|
|
9
|
-
async def acreate(api_key: str
|
|
10
|
-
|
|
11
|
-
return await apromptlayer_create_group(api_key)
|
|
8
|
+
async def acreate(api_key: str, base_url: str, throw_on_error: bool):
|
|
9
|
+
return await apromptlayer_create_group(api_key, base_url, throw_on_error)
|