freeplay 0.4.1__py3-none-any.whl → 0.5.0a1__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/resources/prompts.py +0 -4
- freeplay/resources/recordings.py +26 -20
- {freeplay-0.4.1.dist-info → freeplay-0.5.0a1.dist-info}/METADATA +1 -1
- {freeplay-0.4.1.dist-info → freeplay-0.5.0a1.dist-info}/RECORD +7 -7
- {freeplay-0.4.1.dist-info → freeplay-0.5.0a1.dist-info}/WHEEL +1 -1
- {freeplay-0.4.1.dist-info → freeplay-0.5.0a1.dist-info}/LICENSE +0 -0
- {freeplay-0.4.1.dist-info → freeplay-0.5.0a1.dist-info}/entry_points.txt +0 -0
freeplay/resources/prompts.py
CHANGED
@@ -100,8 +100,6 @@ class PromptInfo:
|
|
100
100
|
provider: str
|
101
101
|
model: str
|
102
102
|
flavor_name: str
|
103
|
-
project_id: str
|
104
|
-
|
105
103
|
|
106
104
|
class FormattedPrompt:
|
107
105
|
def __init__(
|
@@ -540,7 +538,6 @@ class Prompts:
|
|
540
538
|
model=model,
|
541
539
|
flavor_name=prompt.metadata.flavor,
|
542
540
|
provider_info=prompt.metadata.provider_info,
|
543
|
-
project_id=prompt.project_id
|
544
541
|
)
|
545
542
|
|
546
543
|
return TemplatePrompt(prompt_info, prompt.content, prompt.tool_schema)
|
@@ -576,7 +573,6 @@ class Prompts:
|
|
576
573
|
model=model,
|
577
574
|
flavor_name=prompt.metadata.flavor,
|
578
575
|
provider_info=prompt.metadata.provider_info,
|
579
|
-
project_id=prompt.project_id
|
580
576
|
)
|
581
577
|
|
582
578
|
return TemplatePrompt(prompt_info, prompt.content, prompt.tool_schema)
|
freeplay/resources/recordings.py
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
import json
|
2
2
|
import logging
|
3
|
-
from dataclasses import dataclass
|
3
|
+
from dataclasses import dataclass, field
|
4
4
|
from typing import Any, Dict, List, Literal, Optional, Union
|
5
|
-
from uuid import UUID
|
5
|
+
from uuid import UUID, uuid4
|
6
6
|
|
7
7
|
from requests import HTTPError
|
8
8
|
|
@@ -37,11 +37,11 @@ ApiStyle = Union[Literal['batch'], Literal['default']]
|
|
37
37
|
|
38
38
|
@dataclass
|
39
39
|
class CallInfo:
|
40
|
-
provider: str
|
41
|
-
model: str
|
42
|
-
start_time: float
|
43
|
-
end_time: float
|
44
|
-
model_parameters: LLMParameters
|
40
|
+
provider: Optional[str] = None
|
41
|
+
model: Optional[str] = None
|
42
|
+
start_time: Optional[float] = None
|
43
|
+
end_time: Optional[float] = None
|
44
|
+
model_parameters: Optional[LLMParameters] = None
|
45
45
|
provider_info: Optional[Dict[str, Any]] = None
|
46
46
|
usage: Optional[UsageTokens] = None
|
47
47
|
api_style: Optional[ApiStyle] = None
|
@@ -77,12 +77,15 @@ class ResponseInfo:
|
|
77
77
|
|
78
78
|
@dataclass
|
79
79
|
class RecordPayload:
|
80
|
+
project_id: str
|
80
81
|
all_messages: List[Dict[str, Any]]
|
81
|
-
inputs: InputVariables
|
82
82
|
|
83
|
-
session_info: SessionInfo
|
84
|
-
|
85
|
-
|
83
|
+
session_info: SessionInfo = field(
|
84
|
+
default_factory=lambda: SessionInfo(session_id=str(uuid4()), custom_metadata=None)
|
85
|
+
)
|
86
|
+
inputs: Optional[InputVariables] = None
|
87
|
+
prompt_info: Optional[PromptInfo] = None
|
88
|
+
call_info: Optional[CallInfo] = None
|
86
89
|
media_inputs: Optional[MediaInputMap] = None
|
87
90
|
tool_schema: Optional[List[Dict[str, Any]]] = None
|
88
91
|
response_info: Optional[ResponseInfo] = None
|
@@ -132,19 +135,25 @@ class Recordings:
|
|
132
135
|
"inputs": record_payload.inputs,
|
133
136
|
"tool_schema": record_payload.tool_schema,
|
134
137
|
"session_info": {"custom_metadata": record_payload.session_info.custom_metadata},
|
135
|
-
|
138
|
+
|
139
|
+
}
|
140
|
+
|
141
|
+
if record_payload.prompt_info is not None:
|
142
|
+
record_api_payload["prompt_info"] = {
|
136
143
|
"environment": record_payload.prompt_info.environment,
|
137
144
|
"prompt_template_version_id": record_payload.prompt_info.prompt_template_version_id,
|
138
|
-
}
|
139
|
-
|
145
|
+
}
|
146
|
+
|
147
|
+
if record_payload.call_info is not None:
|
148
|
+
record_api_payload["call_info"] = {
|
140
149
|
"start_time": record_payload.call_info.start_time,
|
141
150
|
"end_time": record_payload.call_info.end_time,
|
142
151
|
"model": record_payload.call_info.model,
|
143
152
|
"provider": record_payload.call_info.provider,
|
144
153
|
"provider_info": record_payload.call_info.provider_info,
|
145
154
|
"llm_parameters": record_payload.call_info.model_parameters,
|
155
|
+
"api_style": record_payload.call_info.api_style,
|
146
156
|
}
|
147
|
-
}
|
148
157
|
|
149
158
|
if record_payload.completion_id is not None:
|
150
159
|
record_api_payload['completion_id'] = str(record_payload.completion_id)
|
@@ -175,15 +184,12 @@ class Recordings:
|
|
175
184
|
"trace_id": record_payload.trace_info.trace_id
|
176
185
|
}
|
177
186
|
|
178
|
-
if record_payload.call_info.usage is not None:
|
187
|
+
if record_payload.call_info is not None and record_payload.call_info.usage is not None:
|
179
188
|
record_api_payload['call_info']['usage'] = {
|
180
189
|
"prompt_tokens": record_payload.call_info.usage.prompt_tokens,
|
181
190
|
"completion_tokens": record_payload.call_info.usage.completion_tokens,
|
182
191
|
}
|
183
192
|
|
184
|
-
if record_payload.call_info.api_style is not None:
|
185
|
-
record_api_payload['call_info']['api_style'] = record_payload.call_info.api_style
|
186
|
-
|
187
193
|
if record_payload.media_inputs is not None:
|
188
194
|
record_api_payload['media_inputs'] = {
|
189
195
|
name: media_inputs_to_json(media_input)
|
@@ -193,7 +199,7 @@ class Recordings:
|
|
193
199
|
try:
|
194
200
|
recorded_response = api_support.post_raw(
|
195
201
|
api_key=self.call_support.freeplay_api_key,
|
196
|
-
url=f'{self.call_support.api_base}/v2/projects/{record_payload.
|
202
|
+
url=f'{self.call_support.api_base}/v2/projects/{record_payload.project_id}/sessions/{record_payload.session_info.session_id}/completions',
|
197
203
|
payload=record_api_payload
|
198
204
|
)
|
199
205
|
recorded_response.raise_for_status()
|
@@ -9,15 +9,15 @@ freeplay/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
9
9
|
freeplay/resources/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
10
10
|
freeplay/resources/adapters.py,sha256=6ZAPpoLeOkUkV1s9VNQNsYrnupV0-sy11zFfKfctM1Y,9296
|
11
11
|
freeplay/resources/customer_feedback.py,sha256=6AUgHyOcXIpHvrxGAhsQgmDERvRHKutB6J-GkhkGH6s,928
|
12
|
-
freeplay/resources/prompts.py,sha256=
|
13
|
-
freeplay/resources/recordings.py,sha256=
|
12
|
+
freeplay/resources/prompts.py,sha256=WNxQEXPFCSwp0SiK_qrqwPLgUTOAJXDLFvH52kbJXmg,23196
|
13
|
+
freeplay/resources/recordings.py,sha256=gWFn4KavvSiPq43Atxy4qLuVKdJ0-OwnFkh7mEFHm9k,9570
|
14
14
|
freeplay/resources/sessions.py,sha256=dZtd9nq2nH8pmXxQOJitBnN5Jl3kjggDItDcjC69TYo,3883
|
15
15
|
freeplay/resources/test_cases.py,sha256=nXL_976RwSJDT6OWDM4GEzbcOzcGkJ9ulvb0XOzCRDM,2240
|
16
16
|
freeplay/resources/test_runs.py,sha256=IkqW2LrVrLzFcGtalwP4FV-DeQKKb6Nekvy02FfoH8k,5007
|
17
17
|
freeplay/support.py,sha256=9X-utKyM9BkhCLJbPT184ud26Dc69f3DiHjyN8qq0vQ,15266
|
18
18
|
freeplay/utils.py,sha256=Xvt4mNLXLL7E6MI2hTuDLV5cl5Y83DgdjCZSyDGMjR0,3187
|
19
|
-
freeplay-0.
|
20
|
-
freeplay-0.
|
21
|
-
freeplay-0.
|
22
|
-
freeplay-0.
|
23
|
-
freeplay-0.
|
19
|
+
freeplay-0.5.0a1.dist-info/LICENSE,sha256=_jzIw45hB1XHGxiQ8leZ0GH_X7bR_a8qgxaqnHbCUOo,1064
|
20
|
+
freeplay-0.5.0a1.dist-info/METADATA,sha256=-AHpXBmS7SOEoM9bRpCSj_VXxNf5e6HiNMY40dg6Vy4,1662
|
21
|
+
freeplay-0.5.0a1.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
|
22
|
+
freeplay-0.5.0a1.dist-info/entry_points.txt,sha256=32s3rf2UUCqiJT4jnClEXZhdXlvl30uwpcxz-Gsy4UU,54
|
23
|
+
freeplay-0.5.0a1.dist-info/RECORD,,
|
File without changes
|
File without changes
|