freeplay 0.2.38__tar.gz → 0.2.40__tar.gz
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-0.2.38 → freeplay-0.2.40}/PKG-INFO +1 -1
- {freeplay-0.2.38 → freeplay-0.2.40}/pyproject.toml +1 -1
- {freeplay-0.2.38 → freeplay-0.2.40}/src/freeplay/api_support.py +6 -1
- {freeplay-0.2.38 → freeplay-0.2.40}/src/freeplay/support.py +16 -4
- {freeplay-0.2.38 → freeplay-0.2.40}/src/freeplay/thin/resources/recordings.py +24 -5
- {freeplay-0.2.38 → freeplay-0.2.40}/src/freeplay/thin/resources/test_runs.py +11 -5
- {freeplay-0.2.38 → freeplay-0.2.40}/LICENSE +0 -0
- {freeplay-0.2.38 → freeplay-0.2.40}/README.md +0 -0
- {freeplay-0.2.38 → freeplay-0.2.40}/src/freeplay/__init__.py +0 -0
- {freeplay-0.2.38 → freeplay-0.2.40}/src/freeplay/completions.py +0 -0
- {freeplay-0.2.38 → freeplay-0.2.40}/src/freeplay/errors.py +0 -0
- {freeplay-0.2.38 → freeplay-0.2.40}/src/freeplay/flavors.py +0 -0
- {freeplay-0.2.38 → freeplay-0.2.40}/src/freeplay/freeplay.py +0 -0
- {freeplay-0.2.38 → freeplay-0.2.40}/src/freeplay/freeplay_cli.py +0 -0
- {freeplay-0.2.38 → freeplay-0.2.40}/src/freeplay/llm_parameters.py +0 -0
- {freeplay-0.2.38 → freeplay-0.2.40}/src/freeplay/model.py +0 -0
- {freeplay-0.2.38 → freeplay-0.2.40}/src/freeplay/provider_config.py +0 -0
- {freeplay-0.2.38 → freeplay-0.2.40}/src/freeplay/py.typed +0 -0
- {freeplay-0.2.38 → freeplay-0.2.40}/src/freeplay/record.py +0 -0
- {freeplay-0.2.38 → freeplay-0.2.40}/src/freeplay/thin/__init__.py +0 -0
- {freeplay-0.2.38 → freeplay-0.2.40}/src/freeplay/thin/freeplay_thin.py +0 -0
- {freeplay-0.2.38 → freeplay-0.2.40}/src/freeplay/thin/resources/__init__.py +0 -0
- {freeplay-0.2.38 → freeplay-0.2.40}/src/freeplay/thin/resources/customer_feedback.py +0 -0
- {freeplay-0.2.38 → freeplay-0.2.40}/src/freeplay/thin/resources/prompts.py +0 -0
- {freeplay-0.2.38 → freeplay-0.2.40}/src/freeplay/thin/resources/sessions.py +0 -0
- {freeplay-0.2.38 → freeplay-0.2.40}/src/freeplay/utils.py +0 -0
@@ -76,8 +76,13 @@ def get(target_type: t.Type[T], api_key: str, url: str) -> T:
|
|
76
76
|
return maybe_object
|
77
77
|
|
78
78
|
|
79
|
-
def get_raw(
|
79
|
+
def get_raw(
|
80
|
+
api_key: str,
|
81
|
+
url: str,
|
82
|
+
params: t.Optional[Dict[str, str]] = None
|
83
|
+
) -> Response:
|
80
84
|
return requests.get(
|
81
85
|
url=url,
|
82
86
|
headers=build_request_header(api_key),
|
87
|
+
params=params
|
83
88
|
)
|
@@ -21,8 +21,9 @@ JsonDom = Dict[str, Any]
|
|
21
21
|
|
22
22
|
class TestCaseTestRunResponse:
|
23
23
|
def __init__(self, test_case: JsonDom):
|
24
|
-
self.variables: InputVariables = test_case['variables']
|
25
24
|
self.id: str = test_case['id']
|
25
|
+
self.variables: InputVariables = test_case['variables']
|
26
|
+
self.output: Optional[str] = test_case.get('output')
|
26
27
|
|
27
28
|
|
28
29
|
class TestRunResponse:
|
@@ -104,7 +105,10 @@ class CallSupport:
|
|
104
105
|
def get_prompt(self, project_id: str, template_name: str, environment: str) -> PromptTemplate:
|
105
106
|
response = api_support.get_raw(
|
106
107
|
api_key=self.freeplay_api_key,
|
107
|
-
url=f'{self.api_base}/v2/projects/{project_id}/prompt-templates/name/{template_name}'
|
108
|
+
url=f'{self.api_base}/v2/projects/{project_id}/prompt-templates/name/{template_name}',
|
109
|
+
params={
|
110
|
+
'environment': environment
|
111
|
+
}
|
108
112
|
)
|
109
113
|
|
110
114
|
if response.status_code != 200:
|
@@ -138,11 +142,19 @@ class CallSupport:
|
|
138
142
|
|
139
143
|
return maybe_prompts
|
140
144
|
|
141
|
-
def create_test_run(
|
145
|
+
def create_test_run(
|
146
|
+
self,
|
147
|
+
project_id: str,
|
148
|
+
testlist: str,
|
149
|
+
include_test_case_outputs: bool = False
|
150
|
+
) -> TestRunResponse:
|
142
151
|
response = api_support.post_raw(
|
143
152
|
api_key=self.freeplay_api_key,
|
144
153
|
url=f'{self.api_base}/projects/{project_id}/test-runs-cases',
|
145
|
-
payload={
|
154
|
+
payload={
|
155
|
+
'testlist_name': testlist,
|
156
|
+
'include_test_case_outputs': include_test_case_outputs,
|
157
|
+
},
|
146
158
|
)
|
147
159
|
|
148
160
|
if response.status_code != 201:
|
@@ -3,6 +3,8 @@ import logging
|
|
3
3
|
from dataclasses import dataclass
|
4
4
|
from typing import Dict, Optional, List
|
5
5
|
|
6
|
+
from requests import HTTPError
|
7
|
+
|
6
8
|
from freeplay import api_support
|
7
9
|
from freeplay.completions import PromptTemplateWithMetadata, OpenAIFunctionCall
|
8
10
|
from freeplay.errors import FreeplayClientError, FreeplayError
|
@@ -125,12 +127,29 @@ class Recordings:
|
|
125
127
|
recorded_response.raise_for_status()
|
126
128
|
json_dom = recorded_response.json()
|
127
129
|
return RecordResponse(completion_id=str(json_dom['completion_id']))
|
130
|
+
except HTTPError as e:
|
131
|
+
message = f'There was an error recording to Freeplay. Call will not be logged. ' \
|
132
|
+
f'Status: {e.response.status_code}. '
|
133
|
+
|
134
|
+
if e.response.content:
|
135
|
+
try:
|
136
|
+
content = e.response.content
|
137
|
+
json_body = json.loads(content)
|
138
|
+
if 'message' in json_body:
|
139
|
+
message += json_body['message']
|
140
|
+
except:
|
141
|
+
pass
|
142
|
+
else:
|
143
|
+
message += f'{e.__class__}'
|
144
|
+
|
145
|
+
raise FreeplayError(message) from e
|
146
|
+
|
128
147
|
except Exception as e:
|
129
148
|
status_code = -1
|
130
149
|
if hasattr(e, 'response') and hasattr(e.response, 'status_code'):
|
131
150
|
status_code = e.response.status_code
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
raise FreeplayError from e
|
151
|
+
|
152
|
+
message = f'There was an error recording to Freeplay. Call will not be logged. ' \
|
153
|
+
f'Status: {status_code}. {e.__class__}'
|
154
|
+
|
155
|
+
raise FreeplayError(message) from e
|
@@ -1,5 +1,5 @@
|
|
1
1
|
from dataclasses import dataclass
|
2
|
-
from typing import List
|
2
|
+
from typing import List, Optional
|
3
3
|
|
4
4
|
from freeplay.model import InputVariables
|
5
5
|
from freeplay.support import CallSupport
|
@@ -8,9 +8,15 @@ from freeplay.thin.resources.recordings import TestRunInfo
|
|
8
8
|
|
9
9
|
@dataclass
|
10
10
|
class TestCase:
|
11
|
-
def __init__(
|
11
|
+
def __init__(
|
12
|
+
self,
|
13
|
+
test_case_id: str,
|
14
|
+
variables: InputVariables,
|
15
|
+
output: Optional[str],
|
16
|
+
):
|
12
17
|
self.id = test_case_id
|
13
18
|
self.variables = variables
|
19
|
+
self.output = output
|
14
20
|
|
15
21
|
|
16
22
|
@dataclass
|
@@ -34,10 +40,10 @@ class TestRuns:
|
|
34
40
|
def __init__(self, call_support: CallSupport) -> None:
|
35
41
|
self.call_support = call_support
|
36
42
|
|
37
|
-
def create(self, project_id: str, testlist: str) -> TestRun:
|
38
|
-
test_run = self.call_support.create_test_run(project_id, testlist)
|
43
|
+
def create(self, project_id: str, testlist: str, include_outputs: bool = False) -> TestRun:
|
44
|
+
test_run = self.call_support.create_test_run(project_id, testlist, include_outputs)
|
39
45
|
test_cases = [
|
40
|
-
TestCase(test_case_id=test_case.id, variables=test_case.variables)
|
46
|
+
TestCase(test_case_id=test_case.id, variables=test_case.variables, output=test_case.output)
|
41
47
|
for test_case in test_run.test_cases
|
42
48
|
]
|
43
49
|
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|