silk-road commited on
Commit
9adb044
1 Parent(s): e74a2eb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -13
app.py CHANGED
@@ -20,23 +20,31 @@ NAME_DICT = {'汤师爷': 'tangshiye', '慕容复': 'murongfu', '李云龙': 'li
20
  '乔峰': 'qiaofeng', '神里绫华': 'ayaka', '雷电将军': 'raidenShogun', '于谦': 'yuqian'}
21
 
22
 
23
- ai_roles_obj = {}
24
 
 
 
 
 
 
 
 
 
 
25
  for ai_role_en in NAME_DICT.values():
26
- zip_file_path = f"/content/Haruhi-2-Dev/data/character_in_zip/{ai_role_en}.zip"
27
- if not os.path.exists(zip_file_path):
28
- # os.remove(zip_file_path)
29
- print('unfound zip file ', zip_file_path)
30
- continue
31
-
 
 
32
  destination_folder = f"characters/{ai_role_en}"
33
-
34
- with zipfile.ZipFile(zip_file_path, 'r') as zip_ref:
35
  zip_ref.extractall(destination_folder)
36
-
37
- db_folder = f"./characters/{ai_role_en}/content/{ai_role_en}"
38
- system_prompt = f"./characters/{ai_role_en}/content/system_prompt.txt"
39
- ai_roles_obj[ai_role_en] = ChatHaruhi(system_prompt=system_prompt,
40
  llm="openai",
41
  story_db=db_folder,
42
  verbose=True)
 
20
  '乔峰': 'qiaofeng', '神里绫华': 'ayaka', '雷电将军': 'raidenShogun', '于谦': 'yuqian'}
21
 
22
 
 
23
 
24
+ try:
25
+ os.makedirs("characters_zip")
26
+ except:
27
+ pass
28
+ try:
29
+ os.makedirs("characters")
30
+ except:
31
+ pass
32
+ ai_roles_obj = {}
33
  for ai_role_en in NAME_DICT.values():
34
+ file_url = f"https://github.com/LC1332/Haruhi-2-Dev/raw/main/data/character_in_zip/{ai_role_en}.zip"
35
+ try:
36
+ os.makedirs(f"characters/{ai_role_en}")
37
+ except:
38
+ pass
39
+ if f"{ai_role_en}.zip" not in os.listdir(f"characters_zip"):
40
+ destination_file = f"characters_zip/{ai_role_en}.zip"
41
+ wget.download(file_url, destination_file)
42
  destination_folder = f"characters/{ai_role_en}"
43
+ with zipfile.ZipFile(destination_file, 'r') as zip_ref:
 
44
  zip_ref.extractall(destination_folder)
45
+ db_folder = f"./characters/{ai_role_en}/content/{ai_role_en}"
46
+ system_prompt = f"./characters/{ai_role_en}/content/system_prompt.txt"
47
+ ai_roles_obj[ai_role_en] = ChatHaruhi(system_prompt=system_prompt,
 
48
  llm="openai",
49
  story_db=db_folder,
50
  verbose=True)