Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,7 +2,7 @@ import zipfile
|
|
| 2 |
import gradio as gr
|
| 3 |
from PIL import Image
|
| 4 |
from chatharuhi import ChatHaruhi
|
| 5 |
-
import
|
| 6 |
import os
|
| 7 |
import openai
|
| 8 |
import copy
|
|
@@ -36,7 +36,13 @@ for ai_role_en in NAME_DICT.values():
|
|
| 36 |
pass
|
| 37 |
if f"{ai_role_en}.zip" not in os.listdir(f"characters_zip"):
|
| 38 |
destination_file = f"characters_zip/{ai_role_en}.zip"
|
| 39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
destination_folder = f"characters/{ai_role_en}"
|
| 41 |
with zipfile.ZipFile(destination_file, 'r') as zip_ref:
|
| 42 |
zip_ref.extractall(destination_folder)
|
|
|
|
| 2 |
import gradio as gr
|
| 3 |
from PIL import Image
|
| 4 |
from chatharuhi import ChatHaruhi
|
| 5 |
+
import requests
|
| 6 |
import os
|
| 7 |
import openai
|
| 8 |
import copy
|
|
|
|
| 36 |
pass
|
| 37 |
if f"{ai_role_en}.zip" not in os.listdir(f"characters_zip"):
|
| 38 |
destination_file = f"characters_zip/{ai_role_en}.zip"
|
| 39 |
+
response = requests.get(url)
|
| 40 |
+
if response.status_code = 200:
|
| 41 |
+
with open(destination_file, "wb") as file:
|
| 42 |
+
file.write(response.content)
|
| 43 |
+
else:
|
| 44 |
+
print("download error")
|
| 45 |
+
# wget.download(file_url, destination_file) # 503
|
| 46 |
destination_folder = f"characters/{ai_role_en}"
|
| 47 |
with zipfile.ZipFile(destination_file, 'r') as zip_ref:
|
| 48 |
zip_ref.extractall(destination_folder)
|