Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -296,40 +296,48 @@ with gr.Blocks(css=custom_css) as iface:
|
|
296 |
)
|
297 |
|
298 |
with gr.Tab("設定"):
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
upload_output = gr.Textbox(label="アップロード状態")
|
322 |
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
)
|
327 |
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
333 |
|
334 |
# Gradioアプリの起動
|
335 |
if __name__ == "__main__":
|
|
|
296 |
)
|
297 |
|
298 |
with gr.Tab("設定"):
|
299 |
+
gr.Markdown("## キャラクター設定")
|
300 |
+
name_input = gr.Textbox(label="名前", value=character_maker.settings["name"])
|
301 |
+
gender_input = gr.Textbox(label="性別", value=character_maker.settings["gender"])
|
302 |
+
situation_input = gr.Textbox(label="状況設定", value="\n".join(character_maker.settings["situation"]), lines=5)
|
303 |
+
orders_input = gr.Textbox(label="指示", value="\n".join(character_maker.settings["orders"]), lines=5)
|
304 |
+
talk_input = gr.Textbox(label="語彙リスト", value="\n".join(character_maker.settings["talk_list"]), lines=5)
|
305 |
+
example_qa_input = gr.Textbox(label="例文", value="\n".join(character_maker.settings["example_qa"]), lines=5)
|
306 |
+
|
307 |
+
update_button = gr.Button("設定を更新")
|
308 |
+
update_output = gr.Textbox(label="更新状態")
|
309 |
|
310 |
+
update_button.click(
|
311 |
+
update_settings,
|
312 |
+
inputs=[name_input, gender_input, situation_input, orders_input, talk_input, example_qa_input],
|
313 |
+
outputs=[update_output]
|
314 |
+
)
|
315 |
|
316 |
+
gr.Markdown("## INIファイルの操作")
|
317 |
+
|
318 |
+
# INIファイルをローカルに保存するボタン
|
319 |
+
save_ini_button = gr.Button("INIファイルをローカルに保存")
|
320 |
+
save_ini_output = gr.File(label="保存されたINIファイル")
|
|
|
321 |
|
322 |
+
# INIファイルをアップロードして読み込むボタン
|
323 |
+
upload_ini_button = gr.File(label="INIファイルをアップロード")
|
324 |
+
upload_ini_output = gr.Textbox(label="アップロード状態")
|
|
|
325 |
|
326 |
+
# INIファイルをローカルに保存する関数
|
327 |
+
def save_ini_local():
|
328 |
+
ini_content = download_ini()
|
329 |
+
return {"name": "character_settings.ini", "data": ini_content.encode()}
|
330 |
+
|
331 |
+
save_ini_button.click(
|
332 |
+
save_ini_local,
|
333 |
+
outputs=[save_ini_output]
|
334 |
+
)
|
335 |
+
|
336 |
+
upload_ini_button.change(
|
337 |
+
upload_ini,
|
338 |
+
inputs=[upload_ini_button],
|
339 |
+
outputs=[upload_ini_output]
|
340 |
+
)
|
341 |
|
342 |
# Gradioアプリの起動
|
343 |
if __name__ == "__main__":
|