promptlayer 1.0.72__py3-none-any.whl → 1.0.73__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.
Potentially problematic release.
This version of promptlayer might be problematic. Click here for more details.
- promptlayer/__init__.py +37 -2
- promptlayer/exceptions.py +119 -0
- promptlayer/groups/__init__.py +6 -4
- promptlayer/groups/groups.py +4 -4
- promptlayer/promptlayer.py +59 -18
- promptlayer/promptlayer_base.py +2 -1
- promptlayer/promptlayer_mixins.py +4 -2
- promptlayer/span_exporter.py +16 -7
- promptlayer/templates.py +9 -7
- promptlayer/track/__init__.py +28 -10
- promptlayer/track/track.py +45 -26
- promptlayer/utils.py +554 -246
- {promptlayer-1.0.72.dist-info → promptlayer-1.0.73.dist-info}/METADATA +2 -1
- promptlayer-1.0.73.dist-info/RECORD +23 -0
- promptlayer-1.0.72.dist-info/RECORD +0 -22
- {promptlayer-1.0.72.dist-info → promptlayer-1.0.73.dist-info}/WHEEL +0 -0
- {promptlayer-1.0.72.dist-info → promptlayer-1.0.73.dist-info}/licenses/LICENSE +0 -0
promptlayer/track/track.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
from promptlayer import exceptions as _exceptions
|
|
1
2
|
from promptlayer.utils import (
|
|
2
3
|
apromptlayer_track_group,
|
|
3
4
|
apromptlayer_track_metadata,
|
|
@@ -13,6 +14,7 @@ from promptlayer.utils import (
|
|
|
13
14
|
def prompt(
|
|
14
15
|
api_key: str,
|
|
15
16
|
base_url: str,
|
|
17
|
+
throw_on_error: bool,
|
|
16
18
|
request_id,
|
|
17
19
|
prompt_name,
|
|
18
20
|
prompt_input_variables,
|
|
@@ -20,38 +22,47 @@ def prompt(
|
|
|
20
22
|
label=None,
|
|
21
23
|
):
|
|
22
24
|
if not isinstance(prompt_input_variables, dict):
|
|
23
|
-
raise
|
|
25
|
+
raise _exceptions.PromptLayerValidationError(
|
|
26
|
+
"Please provide a dictionary of input variables.", response=None, body=None
|
|
27
|
+
)
|
|
24
28
|
return promptlayer_track_prompt(
|
|
25
|
-
api_key, base_url, request_id, prompt_name, prompt_input_variables, api_key, version, label
|
|
29
|
+
api_key, base_url, throw_on_error, request_id, prompt_name, prompt_input_variables, api_key, version, label
|
|
26
30
|
)
|
|
27
31
|
|
|
28
32
|
|
|
29
|
-
def metadata(api_key: str, base_url: str, request_id, metadata):
|
|
33
|
+
def metadata(api_key: str, base_url: str, throw_on_error: bool, request_id, metadata):
|
|
30
34
|
if not isinstance(metadata, dict):
|
|
31
|
-
raise
|
|
35
|
+
raise _exceptions.PromptLayerValidationError(
|
|
36
|
+
"Please provide a dictionary of metadata.", response=None, body=None
|
|
37
|
+
)
|
|
32
38
|
for key, value in metadata.items():
|
|
33
39
|
if not isinstance(key, str) or not isinstance(value, str):
|
|
34
|
-
raise
|
|
35
|
-
|
|
40
|
+
raise _exceptions.PromptLayerValidationError(
|
|
41
|
+
"Please provide a dictionary of metadata with key value pair of strings.", response=None, body=None
|
|
42
|
+
)
|
|
43
|
+
return promptlayer_track_metadata(api_key, base_url, throw_on_error, request_id, metadata)
|
|
36
44
|
|
|
37
45
|
|
|
38
|
-
def score(api_key: str, base_url: str, request_id, score, score_name=None):
|
|
46
|
+
def score(api_key: str, base_url: str, throw_on_error: bool, request_id, score, score_name=None):
|
|
39
47
|
if not isinstance(score, int):
|
|
40
|
-
raise
|
|
48
|
+
raise _exceptions.PromptLayerValidationError("Please provide a int score.", response=None, body=None)
|
|
41
49
|
if not isinstance(score_name, str) and score_name is not None:
|
|
42
|
-
raise
|
|
50
|
+
raise _exceptions.PromptLayerValidationError("Please provide a string as score name.", response=None, body=None)
|
|
43
51
|
if score < 0 or score > 100:
|
|
44
|
-
raise
|
|
45
|
-
|
|
52
|
+
raise _exceptions.PromptLayerValidationError(
|
|
53
|
+
"Please provide a score between 0 and 100.", response=None, body=None
|
|
54
|
+
)
|
|
55
|
+
return promptlayer_track_score(api_key, base_url, throw_on_error, request_id, score, score_name)
|
|
46
56
|
|
|
47
57
|
|
|
48
|
-
def group(api_key: str, base_url: str, request_id, group_id):
|
|
49
|
-
return promptlayer_track_group(api_key, base_url, request_id, group_id)
|
|
58
|
+
def group(api_key: str, base_url: str, throw_on_error: bool, request_id, group_id):
|
|
59
|
+
return promptlayer_track_group(api_key, base_url, throw_on_error, request_id, group_id)
|
|
50
60
|
|
|
51
61
|
|
|
52
62
|
async def aprompt(
|
|
53
63
|
api_key: str,
|
|
54
64
|
base_url: str,
|
|
65
|
+
throw_on_error: bool,
|
|
55
66
|
request_id,
|
|
56
67
|
prompt_name,
|
|
57
68
|
prompt_input_variables,
|
|
@@ -59,30 +70,38 @@ async def aprompt(
|
|
|
59
70
|
label=None,
|
|
60
71
|
):
|
|
61
72
|
if not isinstance(prompt_input_variables, dict):
|
|
62
|
-
raise
|
|
73
|
+
raise _exceptions.PromptLayerValidationError(
|
|
74
|
+
"Please provide a dictionary of input variables.", response=None, body=None
|
|
75
|
+
)
|
|
63
76
|
return await apromptlayer_track_prompt(
|
|
64
|
-
api_key, base_url, request_id, prompt_name, prompt_input_variables, version, label
|
|
77
|
+
api_key, base_url, throw_on_error, request_id, prompt_name, prompt_input_variables, version, label
|
|
65
78
|
)
|
|
66
79
|
|
|
67
80
|
|
|
68
|
-
async def ametadata(api_key: str, base_url: str, request_id, metadata):
|
|
81
|
+
async def ametadata(api_key: str, base_url: str, throw_on_error: bool, request_id, metadata):
|
|
69
82
|
if not isinstance(metadata, dict):
|
|
70
|
-
raise
|
|
83
|
+
raise _exceptions.PromptLayerValidationError(
|
|
84
|
+
"Please provide a dictionary of metadata.", response=None, body=None
|
|
85
|
+
)
|
|
71
86
|
for key, value in metadata.items():
|
|
72
87
|
if not isinstance(key, str) or not isinstance(value, str):
|
|
73
|
-
raise
|
|
74
|
-
|
|
88
|
+
raise _exceptions.PromptLayerValidationError(
|
|
89
|
+
"Please provide a dictionary of metadata with key-value pairs of strings.", response=None, body=None
|
|
90
|
+
)
|
|
91
|
+
return await apromptlayer_track_metadata(api_key, base_url, throw_on_error, request_id, metadata)
|
|
75
92
|
|
|
76
93
|
|
|
77
|
-
async def ascore(api_key: str, base_url: str, request_id, score, score_name=None):
|
|
94
|
+
async def ascore(api_key: str, base_url: str, throw_on_error: bool, request_id, score, score_name=None):
|
|
78
95
|
if not isinstance(score, int):
|
|
79
|
-
raise
|
|
96
|
+
raise _exceptions.PromptLayerValidationError("Please provide an integer score.", response=None, body=None)
|
|
80
97
|
if not isinstance(score_name, str) and score_name is not None:
|
|
81
|
-
raise
|
|
98
|
+
raise _exceptions.PromptLayerValidationError("Please provide a string as score name.", response=None, body=None)
|
|
82
99
|
if score < 0 or score > 100:
|
|
83
|
-
raise
|
|
84
|
-
|
|
100
|
+
raise _exceptions.PromptLayerValidationError(
|
|
101
|
+
"Please provide a score between 0 and 100.", response=None, body=None
|
|
102
|
+
)
|
|
103
|
+
return await apromptlayer_track_score(api_key, base_url, throw_on_error, request_id, score, score_name)
|
|
85
104
|
|
|
86
105
|
|
|
87
|
-
async def agroup(api_key: str, base_url: str, request_id, group_id):
|
|
88
|
-
return await apromptlayer_track_group(api_key, base_url, request_id, group_id)
|
|
106
|
+
async def agroup(api_key: str, base_url: str, throw_on_error: bool, request_id, group_id):
|
|
107
|
+
return await apromptlayer_track_group(api_key, base_url, throw_on_error, request_id, group_id)
|