freeplay 0.3.0a6__tar.gz → 0.3.0a7__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.0a6 → freeplay-0.3.0a7}/PKG-INFO +1 -1
- {freeplay-0.3.0a6 → freeplay-0.3.0a7}/pyproject.toml +2 -1
- {freeplay-0.3.0a6 → freeplay-0.3.0a7}/src/freeplay/resources/prompts.py +29 -8
- {freeplay-0.3.0a6 → freeplay-0.3.0a7}/LICENSE +0 -0
- {freeplay-0.3.0a6 → freeplay-0.3.0a7}/README.md +0 -0
- {freeplay-0.3.0a6 → freeplay-0.3.0a7}/src/freeplay/__init__.py +0 -0
- {freeplay-0.3.0a6 → freeplay-0.3.0a7}/src/freeplay/api_support.py +0 -0
- {freeplay-0.3.0a6 → freeplay-0.3.0a7}/src/freeplay/errors.py +0 -0
- {freeplay-0.3.0a6 → freeplay-0.3.0a7}/src/freeplay/freeplay.py +0 -0
- {freeplay-0.3.0a6 → freeplay-0.3.0a7}/src/freeplay/freeplay_cli.py +0 -0
- {freeplay-0.3.0a6 → freeplay-0.3.0a7}/src/freeplay/llm_parameters.py +0 -0
- {freeplay-0.3.0a6 → freeplay-0.3.0a7}/src/freeplay/model.py +0 -0
- {freeplay-0.3.0a6 → freeplay-0.3.0a7}/src/freeplay/py.typed +0 -0
- {freeplay-0.3.0a6 → freeplay-0.3.0a7}/src/freeplay/resources/__init__.py +0 -0
- {freeplay-0.3.0a6 → freeplay-0.3.0a7}/src/freeplay/resources/customer_feedback.py +0 -0
- {freeplay-0.3.0a6 → freeplay-0.3.0a7}/src/freeplay/resources/recordings.py +0 -0
- {freeplay-0.3.0a6 → freeplay-0.3.0a7}/src/freeplay/resources/sessions.py +0 -0
- {freeplay-0.3.0a6 → freeplay-0.3.0a7}/src/freeplay/resources/test_runs.py +0 -0
- {freeplay-0.3.0a6 → freeplay-0.3.0a7}/src/freeplay/support.py +0 -0
- {freeplay-0.3.0a6 → freeplay-0.3.0a7}/src/freeplay/utils.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
[tool.poetry]
|
2
2
|
name = "freeplay"
|
3
|
-
version = "0.3.0-alpha.
|
3
|
+
version = "0.3.0-alpha.7"
|
4
4
|
description = ""
|
5
5
|
authors = ["FreePlay Engineering <engineering@freeplay.ai>"]
|
6
6
|
license = "MIT"
|
@@ -18,6 +18,7 @@ mypy = "^1"
|
|
18
18
|
types-requests = "^2.31"
|
19
19
|
anthropic = { version="^0.20.0", extras = ["bedrock"] }
|
20
20
|
openai = "^1"
|
21
|
+
boto3 = "^1.34.97"
|
21
22
|
|
22
23
|
[tool.poetry.group.test.dependencies]
|
23
24
|
responses = "^0.23.1"
|
@@ -3,7 +3,7 @@ import json
|
|
3
3
|
from abc import ABC, abstractmethod
|
4
4
|
from dataclasses import dataclass
|
5
5
|
from pathlib import Path
|
6
|
-
from typing import Dict, Optional, List, cast, Any
|
6
|
+
from typing import Dict, Optional, List, cast, Any, Union
|
7
7
|
|
8
8
|
from freeplay.errors import FreeplayConfigurationError, FreeplayClientError
|
9
9
|
from freeplay.llm_parameters import LLMParameters
|
@@ -40,10 +40,13 @@ class FormattedPrompt:
|
|
40
40
|
self,
|
41
41
|
prompt_info: PromptInfo,
|
42
42
|
messages: List[Dict[str, str]],
|
43
|
-
formatted_prompt: List[Dict[str, str]]
|
43
|
+
formatted_prompt: Optional[List[Dict[str, str]]] = None,
|
44
|
+
formatted_prompt_text: Optional[str] = None
|
44
45
|
):
|
45
46
|
self.prompt_info = prompt_info
|
46
47
|
self.llm_prompt = formatted_prompt
|
48
|
+
if formatted_prompt_text:
|
49
|
+
self.llm_prompt_text = formatted_prompt_text
|
47
50
|
|
48
51
|
maybe_system_content = next(
|
49
52
|
(message['content'] for message in messages if message['role'] == 'system'), None)
|
@@ -72,13 +75,24 @@ class BoundPrompt:
|
|
72
75
|
def __format_messages_for_flavor(
|
73
76
|
flavor_name: str,
|
74
77
|
messages: List[Dict[str, str]]
|
75
|
-
) -> List[Dict[str, str]]:
|
78
|
+
) -> Union[str, List[Dict[str, str]]]:
|
76
79
|
if flavor_name == 'azure_openai_chat' or flavor_name == 'openai_chat':
|
77
80
|
# We need a deepcopy here to avoid referential equality with the llm_prompt
|
78
81
|
return copy.deepcopy(messages)
|
79
82
|
elif flavor_name == 'anthropic_chat':
|
80
83
|
messages_without_system = [message for message in messages if message['role'] != 'system']
|
81
84
|
return messages_without_system
|
85
|
+
elif flavor_name == 'llama_3_chat':
|
86
|
+
if len(messages) < 1:
|
87
|
+
raise ValueError("Must have at least one message to format")
|
88
|
+
|
89
|
+
formatted = "<|begin_of_text|>"
|
90
|
+
for message in messages:
|
91
|
+
formatted += f"<|start_header_id|>{message['role']}<|end_header_id|>\n{message['content']}<|eot_id|>"
|
92
|
+
formatted += "<|start_header_id|>assistant<|end_header_id|>"
|
93
|
+
|
94
|
+
return formatted
|
95
|
+
|
82
96
|
raise MissingFlavorError(flavor_name)
|
83
97
|
|
84
98
|
def format(
|
@@ -88,11 +102,18 @@ class BoundPrompt:
|
|
88
102
|
final_flavor = flavor_name or self.prompt_info.flavor_name
|
89
103
|
formatted_prompt = BoundPrompt.__format_messages_for_flavor(final_flavor, self.messages)
|
90
104
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
105
|
+
if isinstance(formatted_prompt, str):
|
106
|
+
return FormattedPrompt(
|
107
|
+
prompt_info=self.prompt_info,
|
108
|
+
messages=self.messages,
|
109
|
+
formatted_prompt_text=formatted_prompt
|
110
|
+
)
|
111
|
+
else:
|
112
|
+
return FormattedPrompt(
|
113
|
+
prompt_info=self.prompt_info,
|
114
|
+
messages=self.messages,
|
115
|
+
formatted_prompt=formatted_prompt
|
116
|
+
)
|
96
117
|
|
97
118
|
|
98
119
|
class TemplatePrompt:
|
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
|