freeplay 0.3.14__tar.gz → 0.3.16__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.3.14 → freeplay-0.3.16}/PKG-INFO +1 -1
- {freeplay-0.3.14 → freeplay-0.3.16}/pyproject.toml +1 -1
- {freeplay-0.3.14 → freeplay-0.3.16}/src/freeplay/__init__.py +2 -1
- {freeplay-0.3.14 → freeplay-0.3.16}/src/freeplay/resources/recordings.py +30 -3
- {freeplay-0.3.14 → freeplay-0.3.16}/LICENSE +0 -0
- {freeplay-0.3.14 → freeplay-0.3.16}/README.md +0 -0
- {freeplay-0.3.14 → freeplay-0.3.16}/src/freeplay/api_support.py +0 -0
- {freeplay-0.3.14 → freeplay-0.3.16}/src/freeplay/errors.py +0 -0
- {freeplay-0.3.14 → freeplay-0.3.16}/src/freeplay/freeplay.py +0 -0
- {freeplay-0.3.14 → freeplay-0.3.16}/src/freeplay/freeplay_cli.py +0 -0
- {freeplay-0.3.14 → freeplay-0.3.16}/src/freeplay/llm_parameters.py +0 -0
- {freeplay-0.3.14 → freeplay-0.3.16}/src/freeplay/model.py +0 -0
- {freeplay-0.3.14 → freeplay-0.3.16}/src/freeplay/py.typed +0 -0
- {freeplay-0.3.14 → freeplay-0.3.16}/src/freeplay/resources/__init__.py +0 -0
- {freeplay-0.3.14 → freeplay-0.3.16}/src/freeplay/resources/customer_feedback.py +0 -0
- {freeplay-0.3.14 → freeplay-0.3.16}/src/freeplay/resources/prompts.py +0 -0
- {freeplay-0.3.14 → freeplay-0.3.16}/src/freeplay/resources/sessions.py +0 -0
- {freeplay-0.3.14 → freeplay-0.3.16}/src/freeplay/resources/test_cases.py +0 -0
- {freeplay-0.3.14 → freeplay-0.3.16}/src/freeplay/resources/test_runs.py +0 -0
- {freeplay-0.3.14 → freeplay-0.3.16}/src/freeplay/support.py +0 -0
- {freeplay-0.3.14 → freeplay-0.3.16}/src/freeplay/utils.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
from .freeplay import Freeplay
|
2
2
|
from .resources.prompts import PromptInfo
|
3
|
-
from .resources.recordings import CallInfo, ResponseInfo, RecordPayload, TestRunInfo
|
3
|
+
from .resources.recordings import CallInfo, ResponseInfo, RecordPayload, TestRunInfo, UsageTokens
|
4
4
|
from .resources.sessions import SessionInfo, TraceInfo
|
5
5
|
|
6
6
|
__all__ = [
|
@@ -12,4 +12,5 @@ __all__ = [
|
|
12
12
|
'SessionInfo',
|
13
13
|
'TestRunInfo',
|
14
14
|
'TraceInfo',
|
15
|
+
'UsageTokens',
|
15
16
|
]
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import json
|
2
2
|
import logging
|
3
3
|
from dataclasses import dataclass
|
4
|
-
from typing import Any, Dict, List, Optional, Union
|
4
|
+
from typing import Any, Dict, List, Optional, Union, Literal
|
5
5
|
from uuid import UUID
|
6
6
|
|
7
7
|
from requests import HTTPError
|
@@ -17,6 +17,15 @@ from freeplay.support import CallSupport
|
|
17
17
|
logger = logging.getLogger(__name__)
|
18
18
|
|
19
19
|
|
20
|
+
@dataclass
|
21
|
+
class UsageTokens:
|
22
|
+
prompt_tokens: int
|
23
|
+
completion_tokens: int
|
24
|
+
|
25
|
+
|
26
|
+
ApiStyle = Union[Literal['batch'], Literal['default']]
|
27
|
+
|
28
|
+
|
20
29
|
@dataclass
|
21
30
|
class CallInfo:
|
22
31
|
provider: str
|
@@ -25,9 +34,17 @@ class CallInfo:
|
|
25
34
|
end_time: float
|
26
35
|
model_parameters: LLMParameters
|
27
36
|
provider_info: Optional[Dict[str, Any]] = None
|
37
|
+
usage: Optional[UsageTokens] = None
|
38
|
+
api_style: Optional[ApiStyle] = None
|
28
39
|
|
29
40
|
@staticmethod
|
30
|
-
def from_prompt_info(
|
41
|
+
def from_prompt_info(
|
42
|
+
prompt_info: PromptInfo,
|
43
|
+
start_time: float,
|
44
|
+
end_time: float,
|
45
|
+
usage: Optional[UsageTokens] = None,
|
46
|
+
api_style: Optional[ApiStyle] = None
|
47
|
+
) -> 'CallInfo':
|
31
48
|
return CallInfo(
|
32
49
|
provider=prompt_info.provider,
|
33
50
|
model=prompt_info.model,
|
@@ -35,6 +52,8 @@ class CallInfo:
|
|
35
52
|
end_time=end_time,
|
36
53
|
model_parameters=prompt_info.model_parameters,
|
37
54
|
provider_info=prompt_info.provider_info,
|
55
|
+
usage=usage,
|
56
|
+
api_style=api_style
|
38
57
|
)
|
39
58
|
|
40
59
|
|
@@ -138,6 +157,15 @@ class Recordings:
|
|
138
157
|
"trace_id": record_payload.trace_info.trace_id
|
139
158
|
}
|
140
159
|
|
160
|
+
if record_payload.call_info.usage is not None:
|
161
|
+
record_api_payload['call_info']['usage'] = {
|
162
|
+
"prompt_tokens": record_payload.call_info.usage.prompt_tokens,
|
163
|
+
"completion_tokens": record_payload.call_info.usage.completion_tokens,
|
164
|
+
}
|
165
|
+
|
166
|
+
if record_payload.call_info.api_style is not None:
|
167
|
+
record_api_payload['call_info']['api_style'] = record_payload.call_info.api_style
|
168
|
+
|
141
169
|
try:
|
142
170
|
recorded_response = api_support.post_raw(
|
143
171
|
api_key=self.call_support.freeplay_api_key,
|
@@ -163,7 +191,6 @@ class Recordings:
|
|
163
191
|
|
164
192
|
raise FreeplayError(message) from e
|
165
193
|
|
166
|
-
|
167
194
|
def update(self, record_update_payload: RecordUpdatePayload) -> RecordResponse: # type: ignore
|
168
195
|
record_update_api_payload: Dict[str, Any] = {
|
169
196
|
"new_messages": record_update_payload.new_messages,
|
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
|