Spaces:
Sleeping
Sleeping
Step 5.寫出完整段落
Browse files
app.py
CHANGED
@@ -164,8 +164,12 @@ def generate_supporting_sentences(model, max_tokens, sys_content, scenario, eng_
|
|
164 |
|
165 |
response = OPEN_AI_CLIENT.chat.completions.create(**request_payload)
|
166 |
content = response.choices[0].message.content.strip()
|
|
|
167 |
|
168 |
-
return
|
|
|
|
|
|
|
169 |
|
170 |
def generate_conclusion_sentences(model, max_tokens, sys_content, scenario, eng_level, topic, points, topic_sentence, user_generate_conclusion_sentence_prompt):
|
171 |
"""
|
@@ -465,7 +469,7 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue=gr.themes.colors.blue, secondary
|
|
465 |
topic_sentence_input = gr.Textbox(label="Topic Sentences")
|
466 |
with gr.Column():
|
467 |
generate_topic_sentences_button = gr.Button("生成並在下面 3 個 JUTOR 產生的主題句中,選出一個最合適的", variant="primary")
|
468 |
-
topic_sentence_output = gr.Textbox(label="AI Generated Topic Sentences 主題句")
|
469 |
|
470 |
@gr.render(inputs=topic_sentence_output)
|
471 |
def render_topic_sentences(topic_sentences):
|
@@ -485,17 +489,25 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue=gr.themes.colors.blue, secondary
|
|
485 |
)
|
486 |
|
487 |
return topic_sentences_radio
|
|
|
488 |
with gr.Row():
|
489 |
with gr.Column():
|
490 |
with gr.Row() as supporting_sentences_params:
|
491 |
default_generate_supporting_sentences_prompt = """
|
492 |
I'm aiming to improve my writing. I have a topic sentence as topic_sentence_input.
|
493 |
Please assist me by "Developing supporting detials" based on the keyword: points to write three sentences as an example.
|
|
|
|
|
494 |
- Make sure any revised vocabulary aligns with the eng_level.
|
495 |
- Guidelines for Length and Complexity:
|
496 |
-
Please keep the example concise and straightforward,
|
497 |
-
|
498 |
-
|
|
|
|
|
|
|
|
|
|
|
499 |
"""
|
500 |
user_generate_supporting_sentences_prompt = gr.Textbox(label="Supporting Sentences Prompt", value=default_generate_supporting_sentences_prompt, visible=False)
|
501 |
|
@@ -528,9 +540,14 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue=gr.themes.colors.blue, secondary
|
|
528 |
gr.Markdown("### 寫出關於 focus 的支持句")
|
529 |
supporting_sentences_input = gr.Textbox(label="Supporting Sentences")
|
530 |
with gr.Column():
|
531 |
-
generate_supporting_sentences_button = gr.Button("
|
532 |
-
supporting_sentences_output = gr.
|
533 |
|
|
|
|
|
|
|
|
|
|
|
534 |
|
535 |
|
536 |
|
|
|
164 |
|
165 |
response = OPEN_AI_CLIENT.chat.completions.create(**request_payload)
|
166 |
content = response.choices[0].message.content.strip()
|
167 |
+
gr_update = gr.update(choices=[content])
|
168 |
|
169 |
+
return gr_update
|
170 |
+
|
171 |
+
def update_supporting_sentences_input(supporting_sentences_radio):
|
172 |
+
return supporting_sentences_radio
|
173 |
|
174 |
def generate_conclusion_sentences(model, max_tokens, sys_content, scenario, eng_level, topic, points, topic_sentence, user_generate_conclusion_sentence_prompt):
|
175 |
"""
|
|
|
469 |
topic_sentence_input = gr.Textbox(label="Topic Sentences")
|
470 |
with gr.Column():
|
471 |
generate_topic_sentences_button = gr.Button("生成並在下面 3 個 JUTOR 產生的主題句中,選出一個最合適的", variant="primary")
|
472 |
+
topic_sentence_output = gr.Textbox(label="AI Generated Topic Sentences 主題句", value=[])
|
473 |
|
474 |
@gr.render(inputs=topic_sentence_output)
|
475 |
def render_topic_sentences(topic_sentences):
|
|
|
489 |
)
|
490 |
|
491 |
return topic_sentences_radio
|
492 |
+
# Step 5.寫出完整段落
|
493 |
with gr.Row():
|
494 |
with gr.Column():
|
495 |
with gr.Row() as supporting_sentences_params:
|
496 |
default_generate_supporting_sentences_prompt = """
|
497 |
I'm aiming to improve my writing. I have a topic sentence as topic_sentence_input.
|
498 |
Please assist me by "Developing supporting detials" based on the keyword: points to write three sentences as an example.
|
499 |
+
|
500 |
+
Rules:
|
501 |
- Make sure any revised vocabulary aligns with the eng_level.
|
502 |
- Guidelines for Length and Complexity:
|
503 |
+
- Please keep the example concise and straightforward,
|
504 |
+
|
505 |
+
Restrictions:
|
506 |
+
- avoiding overly technical language.
|
507 |
+
- Total word-count is around 50. no more explanation either no more extra non-relation sentences.
|
508 |
+
|
509 |
+
EXAMPLE:
|
510 |
+
- Washing your hands often helps you stay healthy. It removes dirt and germs that can make you sick. Clean hands prevent the spread of diseases. You protect yourself and others by washing your hands regularly.
|
511 |
"""
|
512 |
user_generate_supporting_sentences_prompt = gr.Textbox(label="Supporting Sentences Prompt", value=default_generate_supporting_sentences_prompt, visible=False)
|
513 |
|
|
|
540 |
gr.Markdown("### 寫出關於 focus 的支持句")
|
541 |
supporting_sentences_input = gr.Textbox(label="Supporting Sentences")
|
542 |
with gr.Column():
|
543 |
+
generate_supporting_sentences_button = gr.Button("讓 JUTOR 產生例句,幫助你撰寫支持句。", variant="primary")
|
544 |
+
supporting_sentences_output = gr.Radio(choices=[],label="AI Generated Supporting Sentences 支持句", elem_id="supporting_sentences_button")
|
545 |
|
546 |
+
supporting_sentences_output.select(
|
547 |
+
fn=update_supporting_sentences_input,
|
548 |
+
inputs=[supporting_sentences_output],
|
549 |
+
outputs= [supporting_sentences_input]
|
550 |
+
)
|
551 |
|
552 |
|
553 |
|