Spaces:
Runtime error
Runtime error
app.py
CHANGED
@@ -1,6 +1,10 @@
|
|
1 |
import gradio as gr
|
2 |
from gtts import gTTS
|
3 |
import json
|
|
|
|
|
|
|
|
|
4 |
|
5 |
def generate_dialogue(rounds, method, role1, role2):
|
6 |
if method == "auto":
|
@@ -10,8 +14,12 @@ def generate_dialogue(rounds, method, role1, role2):
|
|
10 |
return dialogue
|
11 |
|
12 |
def main_function(rounds: int, method: str, role1: str, role2: str):
|
|
|
|
|
|
|
13 |
structured_dialogue = generate_dialogue(rounds, method, role1, role2)
|
14 |
|
|
|
15 |
# Convert structured dialogue for Chatbot component to show "role1: content1" and "role2: content2" side by side
|
16 |
chatbot_dialogue = []
|
17 |
for i in range(0, len(structured_dialogue), 2): # We iterate with a step of 2 to take pairs
|
|
|
1 |
import gradio as gr
|
2 |
from gtts import gTTS
|
3 |
import json
|
4 |
+
import os
|
5 |
+
|
6 |
+
PASSWORD = os.environ['PASSWORD']
|
7 |
+
OPEN_AI_KEY = os.environ['OPEN_AI_KEY']
|
8 |
|
9 |
def generate_dialogue(rounds, method, role1, role2):
|
10 |
if method == "auto":
|
|
|
14 |
return dialogue
|
15 |
|
16 |
def main_function(rounds: int, method: str, role1: str, role2: str):
|
17 |
+
if password != os.environ.get("PASSWORD", ""):
|
18 |
+
return "错误的密码,请重新输入。", "", ""
|
19 |
+
|
20 |
structured_dialogue = generate_dialogue(rounds, method, role1, role2)
|
21 |
|
22 |
+
|
23 |
# Convert structured dialogue for Chatbot component to show "role1: content1" and "role2: content2" side by side
|
24 |
chatbot_dialogue = []
|
25 |
for i in range(0, len(structured_dialogue), 2): # We iterate with a step of 2 to take pairs
|