freeplay 0.3.10__py3-none-any.whl → 0.3.12__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 +14 -6
- freeplay/resources/recordings.py +6 -1
- {freeplay-0.3.10.dist-info → freeplay-0.3.12.dist-info}/METADATA +1 -1
- {freeplay-0.3.10.dist-info → freeplay-0.3.12.dist-info}/RECORD +7 -7
- {freeplay-0.3.10.dist-info → freeplay-0.3.12.dist-info}/LICENSE +0 -0
- {freeplay-0.3.10.dist-info → freeplay-0.3.12.dist-info}/WHEEL +0 -0
- {freeplay-0.3.10.dist-info → freeplay-0.3.12.dist-info}/entry_points.txt +0 -0
freeplay/resources/prompts.py
CHANGED
@@ -4,7 +4,7 @@ import logging
|
|
4
4
|
from abc import ABC, abstractmethod
|
5
5
|
from dataclasses import asdict, dataclass
|
6
6
|
from pathlib import Path
|
7
|
-
from typing import Dict, Optional, List, cast, Any, Union, runtime_checkable, Protocol
|
7
|
+
from typing import Dict, Optional, List, Sequence, cast, Any, Union, runtime_checkable, Protocol
|
8
8
|
|
9
9
|
from freeplay.errors import FreeplayConfigurationError, FreeplayClientError, log_freeplay_client_warning
|
10
10
|
from freeplay.llm_parameters import LLMParameters
|
@@ -211,12 +211,15 @@ class TemplatePrompt:
|
|
211
211
|
self.tool_schema = tool_schema
|
212
212
|
self.messages = messages
|
213
213
|
|
214
|
-
def bind(self, variables: InputVariables, history: Optional[
|
214
|
+
def bind(self, variables: InputVariables, history: Optional[Sequence[GenericProviderMessage]] = None) -> BoundPrompt:
|
215
215
|
# check history for a system message
|
216
216
|
history_clean = []
|
217
217
|
if history:
|
218
|
-
for
|
219
|
-
|
218
|
+
template_messages_contain_system = any(message.get('role') == 'system' for message in self.messages)
|
219
|
+
history_dict = [convert_provider_message_to_dict(msg) for msg in history]
|
220
|
+
for msg in history_dict:
|
221
|
+
history_has_system = msg.get('role', None) == 'system'
|
222
|
+
if history_has_system and template_messages_contain_system:
|
220
223
|
log_freeplay_client_warning("System message found in history, and prompt template."
|
221
224
|
"Removing system message from the history")
|
222
225
|
else:
|
@@ -341,7 +344,12 @@ class FilesystemTemplateResolver(TemplateResolver):
|
|
341
344
|
params=metadata.get('params'),
|
342
345
|
provider_info=metadata.get('provider_info')
|
343
346
|
),
|
344
|
-
project_id=str(json_dom.get('project_id'))
|
347
|
+
project_id=str(json_dom.get('project_id')),
|
348
|
+
tool_schema=[ToolSchema(
|
349
|
+
name=schema.get('name'),
|
350
|
+
description=schema.get('description'),
|
351
|
+
parameters=schema.get('parameters')
|
352
|
+
) for schema in json_dom.get('tool_schema', [])] if json_dom.get('tool_schema') else None
|
345
353
|
)
|
346
354
|
else:
|
347
355
|
metadata = json_dom['metadata']
|
@@ -518,7 +526,7 @@ class Prompts:
|
|
518
526
|
template_name: str,
|
519
527
|
environment: str,
|
520
528
|
variables: InputVariables,
|
521
|
-
history: Optional[
|
529
|
+
history: Optional[Sequence[GenericProviderMessage]] = None,
|
522
530
|
flavor_name: Optional[str] = None
|
523
531
|
) -> FormattedPrompt:
|
524
532
|
bound_prompt = self.get(
|
freeplay/resources/recordings.py
CHANGED
@@ -2,6 +2,7 @@ import json
|
|
2
2
|
import logging
|
3
3
|
from dataclasses import dataclass
|
4
4
|
from typing import Any, Dict, List, Optional, Union
|
5
|
+
from uuid import UUID
|
5
6
|
|
6
7
|
from requests import HTTPError
|
7
8
|
|
@@ -64,6 +65,7 @@ class RecordPayload:
|
|
64
65
|
test_run_info: Optional[TestRunInfo] = None
|
65
66
|
eval_results: Optional[Dict[str, Union[bool, float]]] = None
|
66
67
|
trace_info: Optional[TraceInfo] = None
|
68
|
+
completion_id: Optional[UUID] = None
|
67
69
|
|
68
70
|
|
69
71
|
@dataclass
|
@@ -80,7 +82,7 @@ class Recordings:
|
|
80
82
|
raise FreeplayClientError("Messages list must have at least one message. "
|
81
83
|
"The last message should be the current response.")
|
82
84
|
|
83
|
-
record_api_payload = {
|
85
|
+
record_api_payload: Dict[str, Any] = {
|
84
86
|
"messages": record_payload.all_messages,
|
85
87
|
"inputs": record_payload.inputs,
|
86
88
|
"tool_schema": record_payload.tool_schema,
|
@@ -99,6 +101,9 @@ class Recordings:
|
|
99
101
|
}
|
100
102
|
}
|
101
103
|
|
104
|
+
if record_payload.completion_id is not None:
|
105
|
+
record_api_payload['completion_id'] = str(record_payload.completion_id)
|
106
|
+
|
102
107
|
if record_payload.session_info.custom_metadata is not None:
|
103
108
|
record_api_payload['custom_metadata'] = record_payload.session_info.custom_metadata
|
104
109
|
|
@@ -8,14 +8,14 @@ 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
|
11
|
-
freeplay/resources/prompts.py,sha256
|
12
|
-
freeplay/resources/recordings.py,sha256=
|
11
|
+
freeplay/resources/prompts.py,sha256=-N8djt8VzqGqGNZbG23a9e_dFQfK1RTd6oDyt7Lfgn0,22155
|
12
|
+
freeplay/resources/recordings.py,sha256=1JLR82SdwkI7foB4rTGx_Mi6d4vtr5voFLlABALEKxs,6265
|
13
13
|
freeplay/resources/sessions.py,sha256=Qz5v7VOf1DmQTd1wCOFXnrizlW5WFJT5V8-pq22Ifvg,2793
|
14
14
|
freeplay/resources/test_runs.py,sha256=Tp2N-odInT5XEEWrEsVhdgfnsclOE8n92_C8gTwO2MI,2623
|
15
15
|
freeplay/support.py,sha256=RgC-EDMdxKu7iQEHQ16gxt9VGmjHLUbaKi_k0U5YR1I,8686
|
16
16
|
freeplay/utils.py,sha256=Xvt4mNLXLL7E6MI2hTuDLV5cl5Y83DgdjCZSyDGMjR0,3187
|
17
|
-
freeplay-0.3.
|
18
|
-
freeplay-0.3.
|
19
|
-
freeplay-0.3.
|
20
|
-
freeplay-0.3.
|
21
|
-
freeplay-0.3.
|
17
|
+
freeplay-0.3.12.dist-info/LICENSE,sha256=_jzIw45hB1XHGxiQ8leZ0GH_X7bR_a8qgxaqnHbCUOo,1064
|
18
|
+
freeplay-0.3.12.dist-info/METADATA,sha256=St91ojvaCRRtbnPnXk_XjWuBiZ1LWyzoo97OI3iymTM,1654
|
19
|
+
freeplay-0.3.12.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
20
|
+
freeplay-0.3.12.dist-info/entry_points.txt,sha256=32s3rf2UUCqiJT4jnClEXZhdXlvl30uwpcxz-Gsy4UU,54
|
21
|
+
freeplay-0.3.12.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|