Spaces:
Sleeping
Sleeping
def update_past_exam_evaluation_sys_content_prompt(past_exam_evaluation_sys_content_prompt, past_exam_question, past_exam_hint):
Browse files
app.py
CHANGED
@@ -716,6 +716,7 @@ def generate_paragraph_evaluate(model, max_tokens, sys_content, paragraph):
|
|
716 |
try:
|
717 |
# 準備請求內容
|
718 |
user_content = f"""
|
|
|
719 |
paragraph is: {paragraph}
|
720 |
---
|
721 |
{user_generate_paragraph_evaluate_prompt}
|
@@ -734,6 +735,9 @@ def generate_paragraph_evaluate(model, max_tokens, sys_content, paragraph):
|
|
734 |
print("====openai====")
|
735 |
provider = OpenAIProvider(OPEN_AI_CLIENT)
|
736 |
|
|
|
|
|
|
|
737 |
# 使用 LLMService 處理請求
|
738 |
llm_service = LLMService(provider)
|
739 |
content = llm_service.chat(
|
@@ -1374,6 +1378,17 @@ def update_exam_contents(selected_title):
|
|
1374 |
for exam in exams:
|
1375 |
if exam["title"] == selected_title:
|
1376 |
return exam["title"], exam["question"], exam["hint"], exam["image_url"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1377 |
|
1378 |
|
1379 |
# === Chinese ===
|
@@ -3423,13 +3438,6 @@ with gr.Blocks(theme=THEME, css=CSS) as demo:
|
|
3423 |
past_exam_hint = gr.Markdown()
|
3424 |
with gr.Column():
|
3425 |
past_exam_image = gr.Image(show_label=False)
|
3426 |
-
|
3427 |
-
past_exam_dropdown.select(
|
3428 |
-
fn=update_exam_contents,
|
3429 |
-
inputs=[past_exam_dropdown],
|
3430 |
-
outputs=[past_exam_title, past_exam_question, past_exam_hint, past_exam_image]
|
3431 |
-
)
|
3432 |
-
|
3433 |
# 評分
|
3434 |
with gr.Row():
|
3435 |
with gr.Column():
|
@@ -3442,6 +3450,25 @@ with gr.Blocks(theme=THEME, css=CSS) as demo:
|
|
3442 |
with gr.Row():
|
3443 |
past_exam_evaluation_output = gr.Dataframe(label="全文分析結果", wrap=True, column_widths=[20, 15, 65], interactive=False)
|
3444 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3445 |
# 修正錯字、語法
|
3446 |
with gr.Row():
|
3447 |
with gr.Column():
|
|
|
716 |
try:
|
717 |
# 準備請求內容
|
718 |
user_content = f"""
|
719 |
+
sys_content: {sys_content}
|
720 |
paragraph is: {paragraph}
|
721 |
---
|
722 |
{user_generate_paragraph_evaluate_prompt}
|
|
|
735 |
print("====openai====")
|
736 |
provider = OpenAIProvider(OPEN_AI_CLIENT)
|
737 |
|
738 |
+
print(f"====messages====")
|
739 |
+
print(messages)
|
740 |
+
|
741 |
# 使用 LLMService 處理請求
|
742 |
llm_service = LLMService(provider)
|
743 |
content = llm_service.chat(
|
|
|
1378 |
for exam in exams:
|
1379 |
if exam["title"] == selected_title:
|
1380 |
return exam["title"], exam["question"], exam["hint"], exam["image_url"]
|
1381 |
+
|
1382 |
+
def update_past_exam_evaluation_sys_content_prompt(past_exam_evaluation_sys_content_prompt, past_exam_question, past_exam_hint):
|
1383 |
+
update_past_exam_evaluation_sys_content_prompt = f"""
|
1384 |
+
{past_exam_evaluation_sys_content_prompt}
|
1385 |
+
question:{past_exam_question}
|
1386 |
+
hint:{past_exam_hint}
|
1387 |
+
|
1388 |
+
Please check if the text is on-topic and reference the question and hint.
|
1389 |
+
If the text is off-topic, please reply with the reason and provide new hints.
|
1390 |
+
"""
|
1391 |
+
return update_past_exam_evaluation_sys_content_prompt
|
1392 |
|
1393 |
|
1394 |
# === Chinese ===
|
|
|
3438 |
past_exam_hint = gr.Markdown()
|
3439 |
with gr.Column():
|
3440 |
past_exam_image = gr.Image(show_label=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3441 |
# 評分
|
3442 |
with gr.Row():
|
3443 |
with gr.Column():
|
|
|
3450 |
with gr.Row():
|
3451 |
past_exam_evaluation_output = gr.Dataframe(label="全文分析結果", wrap=True, column_widths=[20, 15, 65], interactive=False)
|
3452 |
|
3453 |
+
past_exam_dropdown.select(
|
3454 |
+
fn=update_exam_contents,
|
3455 |
+
inputs=[past_exam_dropdown],
|
3456 |
+
outputs=[
|
3457 |
+
past_exam_title,
|
3458 |
+
past_exam_question,
|
3459 |
+
past_exam_hint,
|
3460 |
+
past_exam_image
|
3461 |
+
]
|
3462 |
+
).then(
|
3463 |
+
fn=update_past_exam_evaluation_sys_content_prompt,
|
3464 |
+
inputs=[
|
3465 |
+
past_exam_evaluation_sys_content_prompt,
|
3466 |
+
past_exam_question,
|
3467 |
+
past_exam_hint
|
3468 |
+
],
|
3469 |
+
outputs=past_exam_evaluation_sys_content_prompt
|
3470 |
+
)
|
3471 |
+
|
3472 |
# 修正錯字、語法
|
3473 |
with gr.Row():
|
3474 |
with gr.Column():
|