tbdavid2019 commited on
Commit
3bb3dde
·
verified ·
1 Parent(s): a240bb5

不應該帶value

Browse files
Files changed (1) hide show
  1. app.py +29 -3
app.py CHANGED
@@ -131,6 +131,12 @@ def generate_questions(files, question_types, num_questions, lang, llm_key, base
131
  # 修改提示詞,要求 LLM 直接產出結構化的題目和答案
132
  prompt_map = {
133
  "繁體中文": """你是一位專業的出題者,請根據以下內容,設計 {n} 題以下類型的題目:{types}。
 
 
 
 
 
 
134
  請嚴格按照以下格式輸出每個題目和答案:
135
 
136
  題目1:[題目內容]
@@ -144,6 +150,12 @@ def generate_questions(files, question_types, num_questions, lang, llm_key, base
144
  請確保題號和答案號一一對應,不要使用其他格式。內容如下:
145
  {text}""",
146
  "簡體中文": """你是一位专业的出题者,请根据以下内容,设计 {n} 题以下类型的题目:{types}。
 
 
 
 
 
 
147
  请严格按照以下格式输出每个题目和答案:
148
 
149
  题目1:[题目内容]
@@ -157,6 +169,13 @@ def generate_questions(files, question_types, num_questions, lang, llm_key, base
157
  请确保题号和答案号一一对应,不要使用其他格式。内容如下:
158
  {text}""",
159
  "English": """You are a professional exam writer. Based on the following content, generate {n} questions of types: {types}.
 
 
 
 
 
 
 
160
  Please strictly follow this format for each question and answer:
161
 
162
  Question1: [question content]
@@ -170,6 +189,13 @@ Answer2: [answer content]
170
  Ensure that question numbers and answer numbers correspond exactly. Do not use any other format. Content:
171
  {text}""",
172
  "日本語": """あなたはプロの出題者です。以下の内容に基づいて、{types}を含む{n}問の問題を作成してください。
 
 
 
 
 
 
 
173
  以下の形式で各問題と回答を出力してください:
174
 
175
  問題1:[問題内容]
@@ -405,9 +431,9 @@ def build_gradio_blocks():
405
  label="選擇題型(可複選)",
406
  value=["單選選擇題"])
407
  num_questions = gr.Slider(1, 20, value=10, step=1, label="題目數量")
408
- llm_key = gr.Textbox(label="LLM Key (不會儲存)", type="password", placeholder="請輸入你的 LLM API Key")
409
- baseurl = gr.Textbox(label="Base URL (如 https://api.groq.com/openai/v1 )",value="https://api.openai.com/v1", placeholder="請輸入 API Base URL")
410
- model_box = gr.Textbox(label="Model 名稱", value="gpt-4.1", placeholder="如 gpt-4.1, qwen-qwq-32b, ...")
411
  generate_btn = gr.Button("✏️ 開始出題 quiz")
412
 
413
  with gr.Column():
 
131
  # 修改提示詞,要求 LLM 直接產出結構化的題目和答案
132
  prompt_map = {
133
  "繁體中文": """你是一位專業的出題者,請根據以下內容,設計 {n} 題以下類型的題目:{types}。
134
+
135
+ 請注意:你必須嚴格遵循指定的題型,如果要求是「單選選擇題」,就必須生成單選題,每題有四個選項(A,B,C,D),而且只有一個正確答案。
136
+ 如果要求是「多選選擇題」,就必須生成多選題,每題有四到五個選項,可以有多個正確答案。
137
+ 如果要求是「問答題」,就必須生成簡答題,需要簡短的文字回答。
138
+ 如果要求是「申論題」,就必須生成需要較長篇幅回答的開放式問題。
139
+
140
  請嚴格按照以下格式輸出每個題目和答案:
141
 
142
  題目1:[題目內容]
 
150
  請確保題號和答案號一一對應,不要使用其他格式。內容如下:
151
  {text}""",
152
  "簡體中文": """你是一位专业的出题者,请根据以下内容,设计 {n} 题以下类型的题目:{types}。
153
+
154
+ 请注意:你必须严格遵循指定的题型,如果要求是「单选选择题」,就必须生成单选题,每题有四个选项(A,B,C,D),而且只有一个正确答案。
155
+ 如果要求是「多选选择题」,就必须生成多选题,每题有四到五个选项,可以有多个正确答案。
156
+ 如果要求是「问答题」,就必须生成简答题,需要简短的文字回答。
157
+ 如果要求是「申论题」,就必须生成需要较长篇幅回答的开放式问题。
158
+
159
  请严格按照以下格式输出每个题目和答案:
160
 
161
  题目1:[题目内容]
 
169
  请确保题号和答案号一一对应,不要使用其他格式。内容如下:
170
  {text}""",
171
  "English": """You are a professional exam writer. Based on the following content, generate {n} questions of types: {types}.
172
+
173
+ IMPORTANT: You must strictly follow the specified question types:
174
+ - If "single choice question" is requested, create multiple choice questions with four options (A,B,C,D) and only ONE correct answer.
175
+ - If "multiple choice question" is requested, create questions with 4-5 options where MORE THAN ONE option can be correct.
176
+ - If "short answer" is requested, create questions requiring brief text responses.
177
+ - If "essay question" is requested, create open-ended questions requiring longer responses.
178
+
179
  Please strictly follow this format for each question and answer:
180
 
181
  Question1: [question content]
 
189
  Ensure that question numbers and answer numbers correspond exactly. Do not use any other format. Content:
190
  {text}""",
191
  "日本語": """あなたはプロの出題者です。以下の内容に基づいて、{types}を含む{n}問の問題を作成してください。
192
+
193
+ 重要:指定された問題タイプを厳守してください:
194
+ - 「四択問題」が要求された場合、4つの選択肢(A,B,C,D)があり、正解が1つだけの選択問題を作成してください。
195
+ - 「複数選択問題」が要求された場合、4〜5つの選択肢があり、複数の正解がある問題を作成してください。
196
+ - 「短答式問題」が要求された場合、簡潔な文章での回答が必要な問題を作成してください。
197
+ - 「記述式問題」が要求された場合、より長い回答が必要な開放型の問題を作成してください。
198
+
199
  以下の形式で各問題と回答を出力してください:
200
 
201
  問題1:[問題内容]
 
431
  label="選擇題型(可複選)",
432
  value=["單選選擇題"])
433
  num_questions = gr.Slider(1, 20, value=10, step=1, label="題目數量")
434
+ llm_key = gr.Textbox(label="LLM Key (不會儲存)", type="password", placeholder="請輸入你的 LLM API Key,留空則使用 .env 設定")
435
+ baseurl = gr.Textbox(label="Base URL (如 https://api.groq.com/openai/v1 )", placeholder="請輸入 API Base URL,留空則使用 .env 設定")
436
+ model_box = gr.Textbox(label="Model 名稱", placeholder="如 gpt-4.1, qwen-qwq-32b, ...,留空則使用 .env 設定")
437
  generate_btn = gr.Button("✏️ 開始出題 quiz")
438
 
439
  with gr.Column():