freeplay 0.3.5__py3-none-any.whl → 0.3.7__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.
- freeplay/model.py +1 -1
- freeplay/utils.py +15 -2
- {freeplay-0.3.5.dist-info → freeplay-0.3.7.dist-info}/METADATA +1 -1
- {freeplay-0.3.5.dist-info → freeplay-0.3.7.dist-info}/RECORD +7 -7
- {freeplay-0.3.5.dist-info → freeplay-0.3.7.dist-info}/LICENSE +0 -0
- {freeplay-0.3.5.dist-info → freeplay-0.3.7.dist-info}/WHEEL +0 -0
- {freeplay-0.3.5.dist-info → freeplay-0.3.7.dist-info}/entry_points.txt +0 -0
freeplay/model.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
from dataclasses import dataclass
|
2
2
|
from typing import List, Union, Any, Dict, Mapping, TypedDict
|
3
3
|
|
4
|
-
InputValue = Union[str, int, bool, Dict[str, Any], List[Any]]
|
4
|
+
InputValue = Union[str, int, bool, float, Dict[str, Any], List[Any]]
|
5
5
|
InputVariables = Mapping[str, InputValue]
|
6
6
|
TestRunInput = Mapping[str, InputValue]
|
7
7
|
FeedbackValue = Union[bool, str, int, float]
|
freeplay/utils.py
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
import json
|
1
2
|
from typing import Dict, Union, Optional, Any
|
2
3
|
import importlib.metadata
|
3
4
|
import platform
|
@@ -10,7 +11,7 @@ from .model import InputVariables
|
|
10
11
|
|
11
12
|
# Validate that the variables are of the correct type, and do not include functions, dates, classes or None values.
|
12
13
|
def all_valid(obj: Any) -> bool:
|
13
|
-
if isinstance(obj, (int, str, bool)):
|
14
|
+
if isinstance(obj, (int, str, bool, float)):
|
14
15
|
return True
|
15
16
|
elif isinstance(obj, list):
|
16
17
|
return all(all_valid(item) for item in obj)
|
@@ -20,6 +21,18 @@ def all_valid(obj: Any) -> bool:
|
|
20
21
|
return False
|
21
22
|
|
22
23
|
|
24
|
+
class StandardPystache(pystache.Renderer): # type: ignore
|
25
|
+
|
26
|
+
def __init__(self) -> None:
|
27
|
+
super().__init__(escape=lambda s: s)
|
28
|
+
|
29
|
+
def str_coerce(self, val: Any) -> str:
|
30
|
+
if isinstance(val, dict) or isinstance(val, list):
|
31
|
+
# We hide spacing after punctuation so that the templating is the same across all SDKs.
|
32
|
+
return json.dumps(val, separators=(',', ':'))
|
33
|
+
return str(val)
|
34
|
+
|
35
|
+
|
23
36
|
def bind_template_variables(template: str, variables: InputVariables) -> str:
|
24
37
|
if not all_valid(variables):
|
25
38
|
raise FreeplayError(
|
@@ -28,7 +41,7 @@ def bind_template_variables(template: str, variables: InputVariables) -> str:
|
|
28
41
|
)
|
29
42
|
|
30
43
|
# When rendering mustache, do not escape HTML special characters.
|
31
|
-
rendered: str =
|
44
|
+
rendered: str = StandardPystache().render(template, variables)
|
32
45
|
return rendered
|
33
46
|
|
34
47
|
|
@@ -4,7 +4,7 @@ freeplay/errors.py,sha256=vwotUBldxDzREZOmLUeoiDoZjcvDwgH1AMwKBLhLooE,807
|
|
4
4
|
freeplay/freeplay.py,sha256=cj0TGxIziS5tEL12czMJrrKrCKRoYR_Qxsipg3ClpsU,1496
|
5
5
|
freeplay/freeplay_cli.py,sha256=lmdsYwzdpWmUKHz_ieCzB-e6j1EnDHlVw3XIEyP_NEk,3460
|
6
6
|
freeplay/llm_parameters.py,sha256=bQbfuC8EICF0XMZQa5pwI3FkQqxmCUVqHO3gYHy3Tg8,898
|
7
|
-
freeplay/model.py,sha256=
|
7
|
+
freeplay/model.py,sha256=bh3TmINOxvKFxeVO8Uz7ybX28eD1tmO0XLewwLOtS7I,436
|
8
8
|
freeplay/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
9
9
|
freeplay/resources/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
10
10
|
freeplay/resources/customer_feedback.py,sha256=bw8MfEOKbGgn4FOyvcADrcs9GhcpNXNTgxKjBjIzywE,899
|
@@ -13,9 +13,9 @@ freeplay/resources/recordings.py,sha256=kUElo6Yvc6lyo221ghbElx75uxftw7HpgBV_R9gY
|
|
13
13
|
freeplay/resources/sessions.py,sha256=Qz5v7VOf1DmQTd1wCOFXnrizlW5WFJT5V8-pq22Ifvg,2793
|
14
14
|
freeplay/resources/test_runs.py,sha256=qF4CE4XiX_6epcs5bFKJg73C94YgrJQTxnCJLBERkos,2549
|
15
15
|
freeplay/support.py,sha256=nuly_GCWEAEz0CmjlviadKK2_r4X6RdxxiQ6yo78wdk,8449
|
16
|
-
freeplay/utils.py,sha256=
|
17
|
-
freeplay-0.3.
|
18
|
-
freeplay-0.3.
|
19
|
-
freeplay-0.3.
|
20
|
-
freeplay-0.3.
|
21
|
-
freeplay-0.3.
|
16
|
+
freeplay/utils.py,sha256=roDF_4QYKt93XO_hRdQC_mFAORVuqUWgCVAPXTj_vsU,2488
|
17
|
+
freeplay-0.3.7.dist-info/LICENSE,sha256=_jzIw45hB1XHGxiQ8leZ0GH_X7bR_a8qgxaqnHbCUOo,1064
|
18
|
+
freeplay-0.3.7.dist-info/METADATA,sha256=Br__sIy9olEIWT4tFGfZVXGgDYKMJMpM4NgHXoxhSGw,1602
|
19
|
+
freeplay-0.3.7.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
20
|
+
freeplay-0.3.7.dist-info/entry_points.txt,sha256=32s3rf2UUCqiJT4jnClEXZhdXlvl30uwpcxz-Gsy4UU,54
|
21
|
+
freeplay-0.3.7.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|