Spaces:
Runtime error
Runtime error
Saksorn ruangtanusak
commited on
Commit
•
aff673e
1
Parent(s):
e2c5599
add yaml load persona
Browse files
app.py
CHANGED
@@ -6,6 +6,7 @@ import os
|
|
6 |
import threading
|
7 |
import time
|
8 |
import torch
|
|
|
9 |
|
10 |
tokenizer = None
|
11 |
model = None
|
@@ -29,17 +30,10 @@ def threaded_load_model():
|
|
29 |
print(f"Model loaded after {elapsed} seconds")
|
30 |
|
31 |
# personalities
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
"I love candy", "I love eating cake",
|
37 |
-
"I like reading romance novels", "I'm a romantic cat",
|
38 |
-
"I can play guitar very well",
|
39 |
-
"I'm feeling cold because now it is winter",
|
40 |
-
"My favorite colors are green and brown",
|
41 |
-
"I am lazy", "I want to sleep all day",
|
42 |
-
]
|
43 |
for i in range(len(personas_text)):
|
44 |
response = personas_text[i] + tokenizer.eos_token
|
45 |
personas.append(response)
|
|
|
6 |
import threading
|
7 |
import time
|
8 |
import torch
|
9 |
+
import yaml
|
10 |
|
11 |
tokenizer = None
|
12 |
model = None
|
|
|
30 |
print(f"Model loaded after {elapsed} seconds")
|
31 |
|
32 |
# personalities
|
33 |
+
with open('persona.yaml', 'r') as f:
|
34 |
+
personal_dict = yaml.load(f)
|
35 |
+
|
36 |
+
personas_text = personal_dict['persona']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
for i in range(len(personas_text)):
|
38 |
response = personas_text[i] + tokenizer.eos_token
|
39 |
personas.append(response)
|