-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbot.py
51 lines (37 loc) · 1.31 KB
/
bot.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
from pydantic import BaseModel, constr
from .voice import VoicePreset
from ..logger import model_logger
import random
class BotSecret(BaseModel):
model: str = "mockai"
api_key: str = "sk-"
base_url: str = "http://localhost:5002/v1"
class BotParams(BaseModel):
"""parameters to pass into bots"""
temperature: float = 1.5
presence_penalty: float = 1.0
class BotPreset(BaseModel):
"""Common for all LLM bots"""
llm_name: str
speaker: str
system_prompt: str = ""
welcome_message: str = ""
llm_params: BotParams = BotParams()
# class L2dAction(BaseModel):
# motion: str
# expression: str
class L2dBotPreset(BotPreset):
"""Bot with L2D, and controls of mood"""
live2d_model_path: str
bg_picture_path: str
mood: dict[str, list[constr(pattern="^[a-zA-Z0-9]+?\\:[a-zA-Z0-9]+?$")]]
bye_message: str = ""
voice: VoicePreset | None = None
def random_motion(self, test_mood: str = None):
"""choose a set of motion (motion:expression to be exact)
"""
if test_mood not in self.mood:
_test_mood = test_mood
test_mood = random.choice(list(self.mood.keys()))
model_logger.warning(f"unrecognized mood {_test_mood}, choose random one: {test_mood}")
return random.choice(self.mood[test_mood])