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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: freeplay
3
- Version: 0.1.0
3
+ Version: 0.1.1
4
4
  Summary:
5
5
  License: MIT
6
6
  Author: FreePlay Engineering
@@ -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 get_template(self, template_name: str) -> str:
25
- for t in self.prompt_templates:
26
- if t.name == template_name:
27
- return t.content
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:
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "freeplay"
3
- version = "0.1.0"
3
+ version = "0.1.1"
4
4
  description = ""
5
5
  authors = ["FreePlay Engineering <engineering@freeplay.ai>"]
6
6
  license = "MIT"
File without changes
File without changes