Spaces:
Runtime error
Runtime error
dev(hus): try save log to dataset repo
Browse files
app.py
CHANGED
@@ -7,6 +7,17 @@ import gradio as gr
|
|
7 |
from llmriddles.questions import QuestionExecutor
|
8 |
from llmriddles.questions import list_ordered_questions
|
9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
_QUESTION_SESSIONS = {}
|
11 |
count = 0
|
12 |
_QUESTIONS = list_ordered_questions()
|
@@ -21,6 +32,7 @@ if _DEBUG:
|
|
21 |
logging.getLogger().setLevel(logging.INFO)
|
22 |
else:
|
23 |
logging.getLogger().setLevel(logging.WARNING)
|
|
|
24 |
if _LANG == "cn":
|
25 |
title = "完蛋!我被 LLM 拿捏了"
|
26 |
requirement_ph = """
|
@@ -119,11 +131,23 @@ def _get_api_key_cfgs(api_key):
|
|
119 |
|
120 |
|
121 |
if __name__ == '__main__':
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
127 |
with gr.Blocks(title=title, theme='ParityError/Interstellar') as demo:
|
128 |
gr.Markdown(title_markdown)
|
129 |
|
|
|
7 |
from llmriddles.questions import QuestionExecutor
|
8 |
from llmriddles.questions import list_ordered_questions
|
9 |
|
10 |
+
###########
|
11 |
+
import json
|
12 |
+
from datetime import datetime
|
13 |
+
from pathlib import Path
|
14 |
+
from uuid import uuid4
|
15 |
+
|
16 |
+
import gradio as gr
|
17 |
+
|
18 |
+
from huggingface_hub import CommitScheduler
|
19 |
+
###########
|
20 |
+
|
21 |
_QUESTION_SESSIONS = {}
|
22 |
count = 0
|
23 |
_QUESTIONS = list_ordered_questions()
|
|
|
32 |
logging.getLogger().setLevel(logging.INFO)
|
33 |
else:
|
34 |
logging.getLogger().setLevel(logging.WARNING)
|
35 |
+
|
36 |
if _LANG == "cn":
|
37 |
title = "完蛋!我被 LLM 拿捏了"
|
38 |
requirement_ph = """
|
|
|
131 |
|
132 |
|
133 |
if __name__ == '__main__':
|
134 |
+
|
135 |
+
###########################
|
136 |
+
JSON_DATASET_DIR = Path("json_dataset")
|
137 |
+
JSON_DATASET_DIR.mkdir(parents=True, exist_ok=True)
|
138 |
+
JSON_DATASET_PATH = JSON_DATASET_DIR / f"train-{uuid4()}.json"
|
139 |
+
scheduler = CommitScheduler(
|
140 |
+
repo_id="container",
|
141 |
+
repo_type="dataset",
|
142 |
+
folder_path=JSON_DATASET_DIR,
|
143 |
+
path_in_repo="log",
|
144 |
+
)
|
145 |
+
with scheduler.lock:
|
146 |
+
with JSON_DATASET_PATH.open("a") as f:
|
147 |
+
json.dump(logging.getLogger().setLevel(logging.WARNING), f)
|
148 |
+
f.write("\n")
|
149 |
+
###########################
|
150 |
+
|
151 |
with gr.Blocks(title=title, theme='ParityError/Interstellar') as demo:
|
152 |
gr.Markdown(title_markdown)
|
153 |
|