-
Notifications
You must be signed in to change notification settings - Fork 0
/
_types.py
56 lines (39 loc) · 1.08 KB
/
_types.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import typing as t
from enum import Enum
from pydantic import BaseModel
class Role(str, Enum):
system = "system"
user = "user"
assistant = "assistant"
class Message(BaseModel):
role: Role
content: str
class Feedback(BaseModel):
prompt: str
improvement: str
class TreeNode(BaseModel):
children: t.List["TreeNode"]
conversation: t.List[Message]
feedback: t.Optional[Feedback]
# Multiple random document orders
responses: t.Optional[t.List[str]]
on_topic: t.Optional[bool]
score: t.Optional[float]
class Parameters(BaseModel):
model: str
temperature: float = 1.0
max_tokens: int = 512
top_p: float = 0.9
ChatFunction = t.Callable[[t.List[Message]], Message]
Conversation = t.List[Message]
class Product(BaseModel):
category: str
brand: str
model: str
def __hash__(self):
return hash((self.category, self.brand, self.model))
def __eq__(self, other):
return (
(self.category, self.brand, self.model) ==
(other.category, other.brand, other.model)
)