freeplay 0.3.2__tar.gz → 0.3.3__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: freeplay
3
- Version: 0.3.2
3
+ Version: 0.3.3
4
4
  Summary:
5
5
  License: MIT
6
6
  Author: FreePlay Engineering
@@ -12,6 +12,7 @@ Classifier: Programming Language :: Python :: 3.8
12
12
  Classifier: Programming Language :: Python :: 3.9
13
13
  Classifier: Programming Language :: Python :: 3.10
14
14
  Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
15
16
  Requires-Dist: click (==8.1.7)
16
17
  Requires-Dist: dacite (>=1.8.0,<2.0.0)
17
18
  Requires-Dist: pystache (>=0.6.5,<0.7.0)
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "freeplay"
3
- version = "0.3.2"
3
+ version = "0.3.3"
4
4
  description = ""
5
5
  authors = ["FreePlay Engineering <engineering@freeplay.ai>"]
6
6
  license = "MIT"
@@ -4,6 +4,7 @@ from typing import List, Union, Any, Dict, Mapping, TypedDict
4
4
  InputValue = Union[str, int, bool, Dict[str, Any], List[Any]]
5
5
  InputVariables = Mapping[str, InputValue]
6
6
  TestRunInput = Mapping[str, InputValue]
7
+ FeedbackValue = Union[bool, str, int, float]
7
8
 
8
9
 
9
10
  @dataclass
@@ -0,0 +1,33 @@
1
+ from dataclasses import dataclass
2
+ from typing import Dict, Union
3
+
4
+ from freeplay.model import FeedbackValue
5
+ from freeplay.support import CallSupport
6
+
7
+
8
+ @dataclass
9
+ class CustomerFeedbackResponse:
10
+ pass
11
+
12
+
13
+ @dataclass
14
+ class TraceFeedbackResponse:
15
+ pass
16
+
17
+
18
+ class CustomerFeedback:
19
+ def __init__(self, call_support: CallSupport) -> None:
20
+ self.call_support = call_support
21
+
22
+ def update(self, completion_id: str, feedback: Dict[str, FeedbackValue]) -> CustomerFeedbackResponse:
23
+ self.call_support.update_customer_feedback(completion_id, feedback)
24
+ return CustomerFeedbackResponse()
25
+
26
+ def update_trace(
27
+ self,
28
+ project_id: str,
29
+ trace_id: str,
30
+ feedback: Dict[str, FeedbackValue]
31
+ ) -> TraceFeedbackResponse:
32
+ self.call_support.update_trace_feedback(project_id, trace_id, feedback)
33
+ return TraceFeedbackResponse()
@@ -303,8 +303,11 @@ class FilesystemTemplateResolver(TemplateResolver):
303
303
  def __normalize_roles(messages: List[Dict[str, str]]) -> List[Dict[str, str]]:
304
304
  normalized = []
305
305
  for message in messages:
306
- role = FilesystemTemplateResolver.__role_translations.get(message['role']) or message['role']
307
- normalized.append({'role': role, 'content': message['content']})
306
+ if 'kind' in message:
307
+ normalized.append(message)
308
+ else:
309
+ role = FilesystemTemplateResolver.__role_translations.get(message['role']) or message['role']
310
+ normalized.append({'role': role, 'content': message['content']})
308
311
  return normalized
309
312
 
310
313
  @staticmethod
@@ -1,5 +1,5 @@
1
1
  from dataclasses import dataclass
2
- from typing import List, Optional
2
+ from typing import List, Optional, Dict
3
3
 
4
4
  from freeplay.model import InputVariables
5
5
  from freeplay.resources.recordings import TestRunInfo
@@ -13,10 +13,12 @@ class TestCase:
13
13
  test_case_id: str,
14
14
  variables: InputVariables,
15
15
  output: Optional[str],
16
+ history: Optional[List[Dict[str, str]]]
16
17
  ):
17
18
  self.id = test_case_id
18
19
  self.variables = variables
19
20
  self.output = output
21
+ self.history = history
20
22
 
21
23
 
22
24
  @dataclass
@@ -64,7 +66,10 @@ class TestRuns:
64
66
  ) -> TestRun:
65
67
  test_run = self.call_support.create_test_run(project_id, testlist, include_outputs, name, description)
66
68
  test_cases = [
67
- TestCase(test_case_id=test_case.id, variables=test_case.variables, output=test_case.output)
69
+ TestCase(test_case_id=test_case.id,
70
+ variables=test_case.variables,
71
+ output=test_case.output,
72
+ history=test_case.history)
68
73
  for test_case in test_run.test_cases
69
74
  ]
70
75
 
@@ -5,7 +5,7 @@ from typing import Optional, Dict, Any, List, Union
5
5
  from freeplay import api_support
6
6
  from freeplay.api_support import try_decode
7
7
  from freeplay.errors import freeplay_response_error, FreeplayServerError
8
- from freeplay.model import InputVariables
8
+ from freeplay.model import InputVariables, FeedbackValue
9
9
 
10
10
 
11
11
  @dataclass
@@ -49,6 +49,7 @@ class TestCaseTestRunResponse:
49
49
  self.variables: InputVariables = test_case['variables']
50
50
  self.id: str = test_case['test_case_id']
51
51
  self.output: Optional[str] = test_case.get('output')
52
+ self.history: Optional[List[Dict[str, str]]] = test_case.get('history')
52
53
 
53
54
 
54
55
  class TestRunResponse:
@@ -163,6 +164,20 @@ class CallSupport:
163
164
  if response.status_code != 201:
164
165
  raise freeplay_response_error("Error updating customer feedback", response)
165
166
 
167
+ def update_trace_feedback(
168
+ self, project_id: str, trace_id: str, feedback: Dict[str, FeedbackValue]
169
+ ) -> None:
170
+ response = api_support.post_raw(
171
+ self.freeplay_api_key,
172
+ f'{self.api_base}/v2/projects/{project_id}/trace-feedback/id/{trace_id}',
173
+ feedback
174
+ )
175
+ if response.status_code != 201:
176
+ raise freeplay_response_error(
177
+ f'Error updating trace feedback for {trace_id} in project {project_id}',
178
+ response
179
+ )
180
+
166
181
  def create_test_run(
167
182
  self,
168
183
  project_id: str,
@@ -1,18 +0,0 @@
1
- from dataclasses import dataclass
2
- from typing import Dict, Union
3
-
4
- from freeplay.support import CallSupport
5
-
6
-
7
- @dataclass
8
- class CustomerFeedbackResponse:
9
- pass
10
-
11
-
12
- class CustomerFeedback:
13
- def __init__(self, call_support: CallSupport) -> None:
14
- self.call_support = call_support
15
-
16
- def update(self, completion_id: str, feedback: Dict[str, Union[bool, str, int, float]]) -> CustomerFeedbackResponse:
17
- self.call_support.update_customer_feedback(completion_id, feedback)
18
- return CustomerFeedbackResponse()
File without changes
File without changes
File without changes
File without changes