freeplay 0.1.0__tar.gz → 0.1.1__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.1.0 → freeplay-0.1.1}/PKG-INFO +1 -1
- {freeplay-0.1.0 → freeplay-0.1.1}/freeplay/freeplay.py +26 -4
- {freeplay-0.1.0 → freeplay-0.1.1}/pyproject.toml +1 -1
- {freeplay-0.1.0 → freeplay-0.1.1}/README.md +0 -0
- {freeplay-0.1.0 → freeplay-0.1.1}/freeplay/__init__.py +0 -0
- {freeplay-0.1.0 → freeplay-0.1.1}/freeplay/api_support.py +0 -0
@@ -7,10 +7,23 @@ from . import api_support
|
|
7
7
|
T = t.TypeVar("T")
|
8
8
|
|
9
9
|
|
10
|
+
@dataclass
|
11
|
+
class ChatMessage:
|
12
|
+
role: str
|
13
|
+
content: str
|
14
|
+
|
15
|
+
def format(self, **kwargs: str) -> dict[str, str]:
|
16
|
+
return {
|
17
|
+
'role': self.role,
|
18
|
+
'content': self.content.format(**kwargs)
|
19
|
+
}
|
20
|
+
|
21
|
+
|
10
22
|
@dataclass
|
11
23
|
class FreePlayPromptTemplate:
|
12
24
|
name: str
|
13
25
|
content: str
|
26
|
+
messages: list[ChatMessage]
|
14
27
|
|
15
28
|
|
16
29
|
@dataclass
|
@@ -21,13 +34,22 @@ class FreePlayProjectSession:
|
|
21
34
|
def __all_names(self) -> list[str]:
|
22
35
|
return [t.name for t in self.prompt_templates]
|
23
36
|
|
24
|
-
def
|
25
|
-
for
|
26
|
-
if
|
27
|
-
return
|
37
|
+
def __find_template(self, template_name: str) -> FreePlayPromptTemplate:
|
38
|
+
for template in self.prompt_templates:
|
39
|
+
if template.name == template_name:
|
40
|
+
return template
|
28
41
|
|
29
42
|
raise Exception(f'Template with name {template_name} not found. Available names are: {self.__all_names()}')
|
30
43
|
|
44
|
+
def get_template(self, template_name: str) -> str:
|
45
|
+
return self.__find_template(template_name).content
|
46
|
+
|
47
|
+
def get_formatted_chat_messages(self, template_name: str, **kwargs: str) -> list[dict[str, str]]:
|
48
|
+
return [
|
49
|
+
message.format(**kwargs)
|
50
|
+
for message in self.__find_template(template_name).messages
|
51
|
+
]
|
52
|
+
|
31
53
|
|
32
54
|
@dataclass
|
33
55
|
class FreePlayTestRunRecord:
|
File without changes
|
File without changes
|
File without changes
|