youngtsai commited on
Commit
fe3dc6c
·
1 Parent(s): 8e3c243

generate_button3.click(

Browse files
Files changed (1) hide show
  1. app.py +28 -15
app.py CHANGED
@@ -54,7 +54,7 @@ def generate_new_article(lesson_words, original_article, original_word_count, ba
54
  prompt = f"""
55
  Please write a new and original Chinese article tailored for first-grade students. Here's a summary of the key points that you should follow:
56
 
57
- Use Traditional Chinese Characters: The article should be written in Traditional Chinese, not Simplified Chinese.
58
 
59
  Adherence to the Original Article: The new creation should closely follow the spirit, style, and rhythmic pattern of the provided original article. The number of words, excluding punctuation marks, should be similar to that of the original, approximately {original_word_count} words.
60
 
@@ -112,37 +112,50 @@ def load_csv(file):
112
  return "", "", 0, ""
113
 
114
  with gr.Blocks() as demo:
115
- with gr.Row():
116
- gr.Markdown("import CSV file to load data.")
117
- csv_file_input = gr.File(label="Upload CSV file (Columns: lesson_words, original_article, original_word_count, base_chars)")
118
- load_button = gr.Button("Load from CSV")
119
  with gr.Row():
120
  lesson_words_input = gr.Textbox(label="Lesson Words")
121
  original_article_input = gr.Textbox(label="Original Article")
122
  original_word_count_input = gr.Number(label="Original Word Count")
123
  base_chars_input = gr.Textbox(label="Base Characters")
124
 
125
- with gr.Row():
126
- model_1 = gr.Textbox(label="Model 1", value="gpt-4-0125-preview")
127
- generate_button1 = gr.Button("Generate Article - gpt-4-0125-preview")
128
- output_text1 = gr.Textbox(label="Generated Article - gpt-4-0125-preview")
129
-
130
- model_2 = gr.Textbox(label="Model 2", value="gpt-3.5-turbo")
131
- generate_button2 = gr.Button("Generate Article - gpt-3.5-turbo")
132
- output_text2 = gr.Textbox(label="Generated Article - gpt-3.5-turbo")
133
- # 為其他模型添加更多輸出文本框
 
 
 
 
 
 
 
 
 
134
 
135
  generate_button1.click(
136
  generate_new_article,
137
  inputs=[lesson_words_input, original_article_input, original_word_count_input, base_chars_input, model_1],
138
  outputs=output_text1
139
  )
140
-
141
  generate_button2.click(
142
  generate_new_article,
143
  inputs=[lesson_words_input, original_article_input, original_word_count_input, base_chars_input, model_2],
144
  outputs=output_text2
145
  )
 
 
 
 
 
146
 
147
  # 為其他模型添加點擊事件
148
  load_button.click(
 
54
  prompt = f"""
55
  Please write a new and original Chinese article tailored for first-grade students. Here's a summary of the key points that you should follow:
56
 
57
+ Use Traditional Chinese (ZH-TW) Characters: The article should be written in Traditional Chinese(ZH-TW), not Simplified Chinese.
58
 
59
  Adherence to the Original Article: The new creation should closely follow the spirit, style, and rhythmic pattern of the provided original article. The number of words, excluding punctuation marks, should be similar to that of the original, approximately {original_word_count} words.
60
 
 
112
  return "", "", 0, ""
113
 
114
  with gr.Blocks() as demo:
115
+ gr.Markdown("import CSV file to load data.")
116
+ csv_file_input = gr.File(label="Upload CSV file (Columns: lesson_words, original_article, original_word_count, base_chars)")
117
+ load_button = gr.Button("Load from CSV")
118
+
119
  with gr.Row():
120
  lesson_words_input = gr.Textbox(label="Lesson Words")
121
  original_article_input = gr.Textbox(label="Original Article")
122
  original_word_count_input = gr.Number(label="Original Word Count")
123
  base_chars_input = gr.Textbox(label="Base Characters")
124
 
125
+ with gr.Row():
126
+ with gr.Row():
127
+ model_1 = gr.Textbox(label="Model 1", value="gpt-4-0125-preview")
128
+ generate_button1 = gr.Button("Generate Article - gpt-4-0125-preview")
129
+ with gr.Row():
130
+ output_text1 = gr.Textbox(label="Generated Article - gpt-4-0125-preview")
131
+ with gr.Row():
132
+ with gr.Row():
133
+ model_2 = gr.Textbox(label="Model 2", value="gpt-3.5-turbo")
134
+ generate_button2 = gr.Button("Generate Article - gpt-3.5-turbo")
135
+ with gr.Row():
136
+ output_text2 = gr.Textbox(label="Generated Article - gpt-3.5-turbo")
137
+ with gr.Row():
138
+ with gr.Row():
139
+ model_3 = gr.Textbox(label="Model 3", value="gpt-4")
140
+ generate_button3 = gr.Button("Generate Article - gpt-4")
141
+ with gr.Row():
142
+ output_text3 = gr.Textbox(label="Generated Article - gpt-4")
143
 
144
  generate_button1.click(
145
  generate_new_article,
146
  inputs=[lesson_words_input, original_article_input, original_word_count_input, base_chars_input, model_1],
147
  outputs=output_text1
148
  )
 
149
  generate_button2.click(
150
  generate_new_article,
151
  inputs=[lesson_words_input, original_article_input, original_word_count_input, base_chars_input, model_2],
152
  outputs=output_text2
153
  )
154
+ generate_button3.click(
155
+ generate_new_article,
156
+ inputs=[lesson_words_input, original_article_input, original_word_count_input, base_chars_input, model_3],
157
+ outputs=output_text3
158
+ )
159
 
160
  # 為其他模型添加點擊事件
161
  load_button.click(