aicodingfun commited on
Commit
cd42151
·
verified ·
1 Parent(s): f6abac4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -1,3 +1,5 @@
 
 
1
  import json
2
  import os
3
  import random
@@ -15,8 +17,6 @@ output_dir = "./question_bank"
15
  # 載入題庫字典(question_bank_dict),格式為 { "年級_學期": [題庫檔名列表] }
16
  question_bank_dict = json.load(open(f"{output_dir}/question_bank_dict.json", "r"))
17
 
18
- print(question_bank_dict)
19
-
20
  def random_questions_with_limit(data, limit=20000):
21
  """
22
  隨機從 data 中挑選題目,並將總字串長度限制在 limit 字元數內(至少不小於 5000)。
@@ -68,7 +68,7 @@ def generate_math_questions(grade, term, qtype="Unspecified", num_questions=10):
68
  if os.path.exists(f"{output_dir}/md/{doc_path.replace('.pdf', '.md')}")
69
  ]
70
 
71
- print(raw_questions)
72
 
73
  # 隨機選取並限制字串長度的題庫內容
74
  input_question_bank = random_questions_with_limit(raw_questions, 20000)
@@ -108,7 +108,7 @@ def generate_math_questions(grade, term, qtype="Unspecified", num_questions=10):
108
 
109
  Requirements for the generated questions:
110
  - Number of new questions: {num_questions}
111
- - Include the following types: [{qtype}]
112
 
113
  Example Output Format:
114
  1. Question: [New Question 1]
@@ -125,7 +125,7 @@ def generate_math_questions(grade, term, qtype="Unspecified", num_questions=10):
125
 
126
  # 使用 InferenceClient 呼叫 API 模型產生新題目
127
  completion = client.chat.completions.create(
128
- model="mistralai/Mistral-Nemo-Instruct-2407",
129
  messages=messages,
130
  max_tokens=num_questions * 200
131
  )
 
1
+ # -*- coding: utf-8 -*-
2
+
3
  import json
4
  import os
5
  import random
 
17
  # 載入題庫字典(question_bank_dict),格式為 { "年級_學期": [題庫檔名列表] }
18
  question_bank_dict = json.load(open(f"{output_dir}/question_bank_dict.json", "r"))
19
 
 
 
20
  def random_questions_with_limit(data, limit=20000):
21
  """
22
  隨機從 data 中挑選題目,並將總字串長度限制在 limit 字元數內(至少不小於 5000)。
 
68
  if os.path.exists(f"{output_dir}/md/{doc_path.replace('.pdf', '.md')}")
69
  ]
70
 
71
+ print(f"Retrieved {len(raw_questions)} document(s)")
72
 
73
  # 隨機選取並限制字串長度的題庫內容
74
  input_question_bank = random_questions_with_limit(raw_questions, 20000)
 
108
 
109
  Requirements for the generated questions:
110
  - Number of new questions: {num_questions}
111
+ - Include the following types: {qtype}
112
 
113
  Example Output Format:
114
  1. Question: [New Question 1]
 
125
 
126
  # 使用 InferenceClient 呼叫 API 模型產生新題目
127
  completion = client.chat.completions.create(
128
+ model="mistralai/Mistral-7B-Instruct-v0.3",
129
  messages=messages,
130
  max_tokens=num_questions * 200
131
  )