freeplay 0.3.20__py3-none-any.whl → 0.3.22__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/adapters.py +22 -1
- freeplay/resources/prompts.py +27 -6
- {freeplay-0.3.20.dist-info → freeplay-0.3.22.dist-info}/METADATA +2 -2
- {freeplay-0.3.20.dist-info → freeplay-0.3.22.dist-info}/RECORD +7 -7
- {freeplay-0.3.20.dist-info → freeplay-0.3.22.dist-info}/LICENSE +0 -0
- {freeplay-0.3.20.dist-info → freeplay-0.3.22.dist-info}/WHEEL +0 -0
- {freeplay-0.3.20.dist-info → freeplay-0.3.22.dist-info}/entry_points.txt +0 -0
freeplay/resources/adapters.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import copy
|
2
2
|
from dataclasses import dataclass
|
3
|
-
from typing import
|
3
|
+
from typing import Any, Dict, List, Protocol, Union
|
4
4
|
|
5
5
|
from freeplay.errors import FreeplayConfigurationError
|
6
6
|
from freeplay.support import MediaType
|
@@ -221,6 +221,25 @@ class GeminiAdapter(LLMAdapter):
|
|
221
221
|
raise ValueError(f"Gemini formatting found unexpected role {role}")
|
222
222
|
|
223
223
|
|
224
|
+
class BedrockConverseAdapter(LLMAdapter):
|
225
|
+
def to_llm_syntax(self, messages: List[Dict[str, Any]]) -> List[Dict[str, Any]]:
|
226
|
+
converse_messages = []
|
227
|
+
for message in messages:
|
228
|
+
if message["role"] == "system":
|
229
|
+
continue
|
230
|
+
if "has_media" in message and message["has_media"]:
|
231
|
+
raise ValueError("Bedrock Converse does not support media content yet")
|
232
|
+
|
233
|
+
role = message["role"]
|
234
|
+
content = message["content"]
|
235
|
+
if role not in ["user", "assistant"]:
|
236
|
+
raise ValueError(f"Unexpected role for Bedrock Converse flavor: {role}")
|
237
|
+
if isinstance(content, str):
|
238
|
+
content = [{"text": content}]
|
239
|
+
converse_messages.append({"role": role, "content": content})
|
240
|
+
return converse_messages
|
241
|
+
|
242
|
+
|
224
243
|
def adaptor_for_flavor(flavor_name: str) -> LLMAdapter:
|
225
244
|
if flavor_name in ["baseten_mistral_chat", "mistral_chat", "perplexity_chat"]:
|
226
245
|
return PassthroughAdapter()
|
@@ -232,5 +251,7 @@ def adaptor_for_flavor(flavor_name: str) -> LLMAdapter:
|
|
232
251
|
return Llama3Adapter()
|
233
252
|
elif flavor_name == "gemini_chat":
|
234
253
|
return GeminiAdapter()
|
254
|
+
elif flavor_name == "amazon_bedrock_converse":
|
255
|
+
return BedrockConverseAdapter()
|
235
256
|
else:
|
236
257
|
raise MissingFlavorError(flavor_name)
|
freeplay/resources/prompts.py
CHANGED
@@ -8,6 +8,7 @@ from typing import (
|
|
8
8
|
Any,
|
9
9
|
Dict,
|
10
10
|
List,
|
11
|
+
Literal,
|
11
12
|
Optional,
|
12
13
|
Protocol,
|
13
14
|
Sequence,
|
@@ -15,7 +16,6 @@ from typing import (
|
|
15
16
|
Union,
|
16
17
|
cast,
|
17
18
|
runtime_checkable,
|
18
|
-
Literal,
|
19
19
|
)
|
20
20
|
|
21
21
|
from freeplay.errors import (
|
@@ -25,15 +25,24 @@ from freeplay.errors import (
|
|
25
25
|
)
|
26
26
|
from freeplay.llm_parameters import LLMParameters
|
27
27
|
from freeplay.model import InputVariables
|
28
|
-
from freeplay.resources.adapters import
|
29
|
-
|
28
|
+
from freeplay.resources.adapters import (
|
29
|
+
MediaContentBase64,
|
30
|
+
MediaContentUrl,
|
31
|
+
MissingFlavorError,
|
32
|
+
TextContent,
|
33
|
+
adaptor_for_flavor,
|
34
|
+
)
|
30
35
|
from freeplay.support import (
|
31
36
|
CallSupport,
|
37
|
+
HistoryTemplateMessage,
|
38
|
+
MediaSlot,
|
32
39
|
PromptTemplate,
|
33
40
|
PromptTemplateMetadata,
|
34
41
|
PromptTemplates,
|
42
|
+
Role,
|
43
|
+
TemplateChatMessage,
|
35
44
|
TemplateMessage,
|
36
|
-
ToolSchema,
|
45
|
+
ToolSchema,
|
37
46
|
)
|
38
47
|
from freeplay.utils import bind_template_variables, convert_provider_message_to_dict
|
39
48
|
|
@@ -147,7 +156,7 @@ class BoundPrompt:
|
|
147
156
|
self.tool_schema = tool_schema
|
148
157
|
|
149
158
|
@staticmethod
|
150
|
-
def __format_tool_schema(flavor_name: str, tool_schema: List[ToolSchema]) ->
|
159
|
+
def __format_tool_schema(flavor_name: str, tool_schema: List[ToolSchema]) -> Any:
|
151
160
|
if flavor_name == 'anthropic_chat':
|
152
161
|
return [{
|
153
162
|
'name': tool_schema.name,
|
@@ -161,6 +170,19 @@ class BoundPrompt:
|
|
161
170
|
'type': 'function'
|
162
171
|
} for tool_schema in tool_schema
|
163
172
|
]
|
173
|
+
elif flavor_name == "amazon_bedrock_converse":
|
174
|
+
return {
|
175
|
+
"tools": [
|
176
|
+
{
|
177
|
+
"toolSpec": {
|
178
|
+
"name": tool_schema.name,
|
179
|
+
"description": tool_schema.description,
|
180
|
+
"inputSchema": {"json": tool_schema.parameters},
|
181
|
+
}
|
182
|
+
}
|
183
|
+
for tool_schema in tool_schema
|
184
|
+
]
|
185
|
+
}
|
164
186
|
|
165
187
|
raise UnsupportedToolSchemaError()
|
166
188
|
|
@@ -171,7 +193,6 @@ class BoundPrompt:
|
|
171
193
|
final_flavor = flavor_name or self.prompt_info.flavor_name
|
172
194
|
adapter = adaptor_for_flavor(final_flavor)
|
173
195
|
formatted_prompt = adapter.to_llm_syntax(self.messages)
|
174
|
-
|
175
196
|
formatted_tool_schema = BoundPrompt.__format_tool_schema(
|
176
197
|
final_flavor,
|
177
198
|
self.tool_schema
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: freeplay
|
3
|
-
Version: 0.3.
|
3
|
+
Version: 0.3.22
|
4
4
|
Summary:
|
5
5
|
License: MIT
|
6
6
|
Author: FreePlay Engineering
|
@@ -14,7 +14,7 @@ Classifier: Programming Language :: Python :: 3.10
|
|
14
14
|
Classifier: Programming Language :: Python :: 3.11
|
15
15
|
Classifier: Programming Language :: Python :: 3.12
|
16
16
|
Classifier: Programming Language :: Python :: 3.13
|
17
|
-
Requires-Dist: click (
|
17
|
+
Requires-Dist: click (>=8.1.7,<9.0.0)
|
18
18
|
Requires-Dist: dacite (>=1.8.0,<2.0.0)
|
19
19
|
Requires-Dist: pystache (>=0.6.5,<0.7.0)
|
20
20
|
Requires-Dist: requests (>=2.20.0,<3.0.0dev)
|
@@ -7,17 +7,17 @@ freeplay/llm_parameters.py,sha256=bQbfuC8EICF0XMZQa5pwI3FkQqxmCUVqHO3gYHy3Tg8,89
|
|
7
7
|
freeplay/model.py,sha256=o0de_RZ2WTJ4m5OJw1ZVfC2xG6zBq_XShBrRt1laEjc,1405
|
8
8
|
freeplay/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
9
9
|
freeplay/resources/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
10
|
-
freeplay/resources/adapters.py,sha256=
|
10
|
+
freeplay/resources/adapters.py,sha256=0ZQdVNoa6JcWToaSyNLnK-WXRDk6UEksC9QBAkeFBiw,9102
|
11
11
|
freeplay/resources/customer_feedback.py,sha256=bw8MfEOKbGgn4FOyvcADrcs9GhcpNXNTgxKjBjIzywE,899
|
12
|
-
freeplay/resources/prompts.py,sha256=
|
12
|
+
freeplay/resources/prompts.py,sha256=mnL1VscMGM7D4ulGf3CBGQKdsSj8I5Wf_6nJEYa7mZI,23353
|
13
13
|
freeplay/resources/recordings.py,sha256=z2ARII1jCnmNh1GU3hGnXZUz5IF_KhyayQum71k-h9c,9213
|
14
14
|
freeplay/resources/sessions.py,sha256=J5A3CjiV2MFqQyxN3TWTvJaa9jmMza58mRFRq2v9iAk,3746
|
15
15
|
freeplay/resources/test_cases.py,sha256=nXL_976RwSJDT6OWDM4GEzbcOzcGkJ9ulvb0XOzCRDM,2240
|
16
16
|
freeplay/resources/test_runs.py,sha256=Tp2N-odInT5XEEWrEsVhdgfnsclOE8n92_C8gTwO2MI,2623
|
17
17
|
freeplay/support.py,sha256=kQMItnMGZT5TOdPQsSiKOlBbBqO4AyR91vito6wt4JM,12275
|
18
18
|
freeplay/utils.py,sha256=Xvt4mNLXLL7E6MI2hTuDLV5cl5Y83DgdjCZSyDGMjR0,3187
|
19
|
-
freeplay-0.3.
|
20
|
-
freeplay-0.3.
|
21
|
-
freeplay-0.3.
|
22
|
-
freeplay-0.3.
|
23
|
-
freeplay-0.3.
|
19
|
+
freeplay-0.3.22.dist-info/LICENSE,sha256=_jzIw45hB1XHGxiQ8leZ0GH_X7bR_a8qgxaqnHbCUOo,1064
|
20
|
+
freeplay-0.3.22.dist-info/METADATA,sha256=6wCrxA0QTHMq1JoLtxIfEsexI3lcRlxEFkwOHSvr8HM,1661
|
21
|
+
freeplay-0.3.22.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
|
22
|
+
freeplay-0.3.22.dist-info/entry_points.txt,sha256=32s3rf2UUCqiJT4jnClEXZhdXlvl30uwpcxz-Gsy4UU,54
|
23
|
+
freeplay-0.3.22.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|