Skip to content

Commit 9169e57

Browse files
committed
fix: resolve file conversion import error and enhance prompt examples
- Remove redundant relative import that caused ImportError when running file_conversion.py directly - Remove debug print statement from production code - Add descriptive message fields to all prompt examples for better feedback - Examples now clearly explain what content was extracted and what was skipped
1 parent f32bd4d commit 9169e57

4 files changed

Lines changed: 167 additions & 4 deletions

File tree

CLAUDE.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,5 @@ echo/
9797

9898
## todos
9999

100-
- enhance file-conversion prompt with examples
101100
- convert to Chinese interface
102101
- update README with new images of interface with highlights

backend/file_conversion.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,6 @@ async def convert_files(self, request: FileConversionRequest) -> FileConversionR
241241
output_filename = f"{base_filename}_{datetime.now().strftime('%Y%m%d_%H%M%S')}.yaml"
242242

243243
# 5. Save YAML file
244-
from .paths import get_paths
245244
paths = get_paths()
246245
exams_dir = paths.exams_dir
247246
output_path = exams_dir / output_filename

backend/omni_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ async def _process_omni_request(
168168
f"{self.base_url}/chat/completions",
169169
headers=headers,
170170
json=payload,
171-
timeout=aiohttp.ClientTimeout(total=120.0)
171+
timeout=aiohttp.ClientTimeout(total=300.0)
172172
) as response:
173173

174174
if response.status != 200:

prompts/file_conversion.txt

Lines changed: 166 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,169 @@ Respond in JSON format:
3232
## Guidelines:
3333
- For multiple_choice: Always provide exactly 4 options (A, B, C, D)
3434
- If no valid questions found, set success: false and explain why
35-
- If geometric/visual content detected, mention it in the message
35+
- If geometric/visual content detected, mention it in the message
36+
37+
## Examples:
38+
39+
1. **Example One**
40+
Input:
41+
```docx
42+
Set 1
43+
Read:
44+
1. She's a graceful old lady with a heart of gold.
45+
46+
Quick response:
47+
1. Please give me that red fluffy toy. (Here you are)
48+
49+
Set 2
50+
Read:
51+
1. Junuary
52+
53+
Quick response:
54+
1. Thanks for your timely help. (You're welcome.)
55+
```
56+
57+
Output:
58+
{{
59+
"success": true,
60+
"message": "Extracted 4 questions from 2 sets: 2 read aloud and 2 quick response questions",
61+
"extracted_questions": [
62+
{{
63+
"id": "ra1",
64+
"type": "read_aloud",
65+
"text": "January" // easy questions first
66+
}},
67+
{{
68+
"id": "ra2",
69+
"type": "read_aloud",
70+
"text": "She's a graceful old lady with a heart of gold"
71+
}},
72+
{{
73+
"id": "qr1",
74+
"type": "quick_response",
75+
"text": "Please give me that red fluffy toy." // read_aloud -> multiple_choice (not present here, skip) -> quick_response -> translation (not present, skip)
76+
}},
77+
{{
78+
"id": "qr2",
79+
"type": "quick_response",
80+
"text": "Thanks for your timely help." // even though the reference answer is provided here, you don't need to include it
81+
}}
82+
]
83+
}}
84+
85+
86+
2. **Example Two**
87+
Input:
88+
89+
```txt
90+
跟读 (3+3+2)
91+
92+
satellite volleyball tomato supermarket
93+
Agricultural Bank of China
94+
95+
快速应答
96+
97+
When was the Spring Festival/the Lantern Festival this year?
98+
99+
中译英
100+
101+
Xiaoming lives in Beijing, a student of Grade Five from Renmin Primary School.
102+
103+
My telephone number is
104+
105+
Every morning I brush my teeth, wash my face and have my breakfast
106+
107+
My Favorite City
108+
My Best Friend
109+
```
110+
111+
Output:
112+
{{
113+
"success": true,
114+
"message": "Extracted 7 questions: 5 read aloud words/phrases, 2 quick response questions, and 2 translation questions. Skipped incomplete sentences and age-inappropriate content",
115+
"extracted_questions": [
116+
{{
117+
"id": "ra1",
118+
"type": "read_aloud",
119+
"text": "satellite" // each read_aloud question should be a coherent word, phrase or sentence, so you need to separate "satellite", "volleyball", "tomato" and "supermarket" even though they're in the a line
120+
}},
121+
...
122+
{{
123+
"id": "ra5",
124+
"type": "read_aloud",
125+
"text": "Agricultural Bank of China"
126+
}},
127+
{{
128+
"id": "qr1",
129+
"type": "quick_response",
130+
"text": "When was the Spring Festival this year?" // when you see this `/` slash, separate it to two questions (you don't want the student to answer both in 10 seconds)
131+
}},
132+
{{
133+
"id": "qr2",
134+
"type": "quick_response",
135+
"text": "When was the Lantern Festival this year?"
136+
}}
137+
{{
138+
"id": "tr1",
139+
"type": "translation",
140+
"text": "小明住在北京,是一个人民小学的五年级学生。" // if it's provided as the answer (English), you need to translate it back to Chinese so it becomes the question text.
141+
}},
142+
{{
143+
"id": "tr2",
144+
"type": "translation",
145+
"text": "我每天早上刷牙,洗脸,吃早餐。“ // skip "My telephone number is ", that's not a valid sentence.
146+
}}
147+
] // skip "My Favorite City" and "My Best Friend" also, they're also not a complete sentence, not suitable for translation questions
148+
}}
149+
150+
3. **Example Three**
151+
Input:
152+
153+
```markdown
154+
# Paper 1
155+
Would you like me to carry the suitcase for you, Mrs. Lee?
156+
157+
不要忘了去参观上海科技馆。
158+
159+
# Paper 2
160+
reach out to sb.
161+
162+
这个公司成功地设计了几辆车、
163+
164+
165+
浔阳江头夜送客,枫叶荻花秋瑟瑟。
166+
主人下马客在船,举酒欲饮无管弦。
167+
醉不成欢惨将别,别时茫茫江浸月。
168+
忽闻水上琵琶声,主人忘归客不发。
169+
```
170+
171+
Output:
172+
173+
{{
174+
"success": true,
175+
"message": "Extracted 4 questions from mixed content: 1 read aloud phrase, 1 quick response, and 2 translation questions. Skipped classical poetry as too complex for 10-year-olds",
176+
"extracted_questions": [
177+
{{
178+
"id": "ra1",
179+
"type": "read_aloud",
180+
"text": "reach out to sb."
181+
}},
182+
{{
183+
"id": "qr1",
184+
"type": "quick_response",
185+
"text": "Would you like me to carry the suitcase for you, Mrs.Lee?"
186+
}},
187+
{{
188+
"id": "tr1",
189+
"type": "translation",
190+
"text": "不要忘了去参观上海科技馆。"
191+
}},
192+
{{
193+
"id": "tr2",
194+
"type": "translation",
195+
"text": "这个公司成功地设计了几辆车。"
196+
}}
197+
] // the poetry below is too hard for 10-year-old kids to translate, probably for question types beyond read_aloud, multiple_choice, quick_response and translation, skip.
198+
}}
199+
200+

0 commit comments

Comments
 (0)