youngtsai commited on
Commit
cc31c5b
·
1 Parent(s): eee5af3

json_textbox = gr.Textbox(readonly=True, label="對話 JSON 內容", lines=10)

Browse files
Files changed (1) hide show
  1. app.py +29 -15
app.py CHANGED
@@ -122,19 +122,35 @@ def main_function(password: str, theme: str, language: str, method: str, rounds:
122
 
123
 
124
  if __name__ == "__main__":
125
- with gr.Blocks(theme="light") as demo: # 使用 'light' 主题作为默认值
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
126
  # Header 或其他组件可以在这里添加,如果有需要
127
  with gr.Row():
128
  with gr.Column(scale=1): # 1/3 的宽度
129
- password = gr.Textbox(label="输入密码", type="password")
130
- theme = gr.Textbox(label="對話主題") # 加入 theme 的輸入框,設定預設值為 '購物'
131
- language = gr.Dropdown(choices=["中文", "英文"], label="語言")
132
- generation_mode = gr.Dropdown(choices=["auto", "manual"], label="生成方式")
133
- rounds = gr.Slider(minimum=2, maximum=6, step=2, label="對話輪數")
134
- char1_name = gr.Textbox(label="角色 1 名稱")
135
- char1_gender = gr.Dropdown(choices=["male", "female"], label="角色 1 性別")
136
- char2_name = gr.Textbox(label="角色 2 名稱")
137
- char2_gender = gr.Dropdown(choices=["male", "female"], label="角色 2 性別")
138
 
139
  # 在这里添加提交和清除按鈕
140
  submit_button = gr.Button("Submit")
@@ -142,12 +158,10 @@ if __name__ == "__main__":
142
  submit_button.click(main_function, [password, theme, language, generation_mode, rounds, char1_name, char1_gender, char2_name, char2_gender], [chat_output, json_file, json_textbox])
143
  clear_button.click(lambda: None, None, [chat_output, json_file, json_textbox], queue=False)
144
 
145
-
146
  with gr.Column(scale=2): # 2/3 的宽度
147
- chat_output = gr.Chatbot(label="生成的對話")
148
- json_file = gr.File(label="下載對話 JSON 文件")
149
- json_textbox = gr.Textbox(readonly=True, label="對話 JSON 內容", lines=10)
150
-
151
  # 可以添加其他交互逻辑和按钮事件,如果有需要
152
 
153
  demo.launch(inline=False, share=True)
 
122
 
123
 
124
  if __name__ == "__main__":
125
+
126
+ password = gr.Textbox(label="输入密码", type="password")
127
+ theme = gr.Textbox(label="對話主題") # 加入 theme 的輸入框,設定預設值為 '購物'
128
+ language = gr.Dropdown(choices=["中文", "英文"], label="語言")
129
+ generation_mode = gr.Dropdown(choices=["auto", "manual"], label="生成方式")
130
+ rounds = gr.Slider(minimum=2, maximum=6, step=2, label="對話輪數")
131
+ char1_name = gr.Textbox(label="角色 1 名稱")
132
+ char1_gender = gr.Dropdown(choices=["male", "female"], label="角色 1 性別")
133
+ char2_name = gr.Textbox(label="角色 2 名稱")
134
+ char2_gender = gr.Dropdown(choices=["male", "female"], label="角色 2 性別")
135
+
136
+
137
+ chat_output = gr.Chatbot(label="生成的對話")
138
+ json_file = gr.File(label="下載對話 JSON 文件")
139
+ json_textbox = gr.Textbox(readonly=True, label="對話 JSON 內容", lines=10)
140
+
141
+ with gr.Blocks() as demo: # 使用 'light' 主题作为默认值
142
  # Header 或其他组件可以在这里添加,如果有需要
143
  with gr.Row():
144
  with gr.Column(scale=1): # 1/3 的宽度
145
+ password
146
+ theme
147
+ language
148
+ generation_mode
149
+ rounds
150
+ char1_name
151
+ char1_gender
152
+ char2_name
153
+ char2_gender
154
 
155
  # 在这里添加提交和清除按鈕
156
  submit_button = gr.Button("Submit")
 
158
  submit_button.click(main_function, [password, theme, language, generation_mode, rounds, char1_name, char1_gender, char2_name, char2_gender], [chat_output, json_file, json_textbox])
159
  clear_button.click(lambda: None, None, [chat_output, json_file, json_textbox], queue=False)
160
 
 
161
  with gr.Column(scale=2): # 2/3 的宽度
162
+ chat_output
163
+ json_file
164
+ json_textbox
 
165
  # 可以添加其他交互逻辑和按钮事件,如果有需要
166
 
167
  demo.launch(inline=False, share=True)