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.

@@ -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 Exception("Please provide a dictionary of input variables.")
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 Exception("Please provide a dictionary of metadata.")
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 Exception("Please provide a dictionary of metadata with key value pair of strings.")
35
- return promptlayer_track_metadata(api_key, base_url, request_id, metadata)
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 Exception("Please provide a int score.")
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 Exception("Please provide a string as score name.")
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 Exception("Please provide a score between 0 and 100.")
45
- return promptlayer_track_score(api_key, base_url, request_id, score, score_name)
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 Exception("Please provide a dictionary of input variables.")
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 Exception("Please provide a dictionary of metadata.")
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 Exception("Please provide a dictionary of metadata with key-value pairs of strings.")
74
- return await apromptlayer_track_metadata(api_key, base_url, request_id, metadata)
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 Exception("Please provide an integer score.")
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 Exception("Please provide a string as score name.")
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 Exception("Please provide a score between 0 and 100.")
84
- return await apromptlayer_track_score(api_key, base_url, request_id, score, score_name)
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)