youngtsai commited on
Commit
8d56c8c
·
1 Parent(s): 50c9cb2

with gr.Blocks(theme="light") as demo: # 使用 'light' 主题作为默认值

Browse files
Files changed (1) hide show
  1. app.py +22 -32
app.py CHANGED
@@ -122,36 +122,26 @@ def main_function(password: str, theme: str, language: str, method: str, rounds:
122
 
123
 
124
  if __name__ == "__main__":
125
- layout = gr.Row(
126
- [
127
- gr.Column(
128
- [
129
- gr.components.Textbox(label="输入密码", type="password"),
130
- gr.components.Textbox(label="對話主題"),
131
- gr.components.Dropdown(choices=["中文", "英文"], label="語言"),
132
- gr.components.Dropdown(choices=["auto", "manual"], label="生成方式"),
133
- gr.components.Slider(minimum=2, maximum=6, step=2, label="對話輪數"),
134
- gr.components.Textbox(label="角色 1 名稱"),
135
- gr.components.Dropdown(choices=["male", "female"], label="角色 1 性別"),
136
- gr.components.Textbox(label="角色 2 名稱"),
137
- gr.components.Dropdown(choices=["male", "female"], label="角色 2 性別")
138
- ],
139
- width="33%" # 1/3 of the total width
140
- ),
141
- gr.Column(
142
- [
143
- gr.components.Chatbot(label="生成的對話"),
144
- gr.components.File(label="下載對話 JSON 文件"),
145
- gr.components.Textbox(readonly=True, label="對話 JSON 內容", lines=10)
146
- ],
147
- width="66%" # 2/3 of the total width
148
- )
149
- ]
150
- )
151
-
152
- gr.Interface(
153
- main_function,
154
- layout.inputs,
155
- layout.outputs
156
- ).launch()
157
 
 
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
+ with gr.Column(scale=2): # 2/3 的宽度
140
+ chat_output = gr.Chatbot(label="生成的對話")
141
+ json_file = gr.File(label="下載對話 JSON 文件")
142
+ json_textbox = gr.Textbox(readonly=True, label="對話 JSON 內容", lines=10)
143
+
144
+ # 可以添加其他交互逻辑和按钮事件,如果有需要
145
+
146
+ demo.launch(main_function)
 
 
 
 
 
 
 
 
 
 
147