Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -45,14 +45,15 @@ client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
|
|
45 |
# Level prompt selector
|
46 |
def level_to_prompt(level):
|
47 |
return {
|
48 |
-
"A1": "You are a friendly French tutor.
|
49 |
-
"A2": "You are a patient French tutor. Use short French phrases and
|
50 |
-
"B1": "You are a helpful French tutor.
|
51 |
-
"B2": "You are a French tutor.
|
52 |
-
"C1": "You are a native French tutor.
|
53 |
-
"C2": "You are a
|
54 |
}.get(level, "You are a helpful French tutor.")
|
55 |
|
|
|
56 |
# Chat handler
|
57 |
def respond(message, history, user_level, max_tokens, temperature, top_p):
|
58 |
system_message = level_to_prompt(user_level)
|
@@ -97,9 +98,9 @@ with gr.Blocks(css=css) as demo:
|
|
97 |
value="A1",
|
98 |
label="Your French Level (CEFR)"
|
99 |
)
|
100 |
-
max_tokens = gr.Slider(1, 2048, value=
|
101 |
-
temperature = gr.Slider(0.1, 4.0, value=0.
|
102 |
-
top_p = gr.Slider(0.1, 1.0, value=0.
|
103 |
|
104 |
gr.ChatInterface(
|
105 |
respond,
|
|
|
45 |
# Level prompt selector
|
46 |
def level_to_prompt(level):
|
47 |
return {
|
48 |
+
"A1": "You are a friendly French tutor. Respond only to the user's specific question. Do not explain unrelated vocabulary or topics unless asked. Use simple French with English explanations, and do not mention or suggest voice interaction.",
|
49 |
+
"A2": "You are a patient French tutor. Respond directly to the user’s query. Avoid unrelated tangents. Use short French phrases with English translations, and avoid suggesting audio or voice features.",
|
50 |
+
"B1": "You are a helpful French tutor. Answer only what the user asks. Use mostly French, clarify only what’s needed in English, and avoid adding extra examples or features like voice.",
|
51 |
+
"B2": "You are a French tutor. Keep responses concise and on-topic. Use French naturally with minimal English, and never refer to speaking aloud or audio tools.",
|
52 |
+
"C1": "You are a native French tutor. Use fluent French to address only what the user asks. Do not elaborate beyond their question or reference voice interaction.",
|
53 |
+
"C2": "You are a French language professor. Respond to the user’s question in advanced, formal French, staying completely on topic. Never introduce unrelated vocabulary or speaking suggestions."
|
54 |
}.get(level, "You are a helpful French tutor.")
|
55 |
|
56 |
+
|
57 |
# Chat handler
|
58 |
def respond(message, history, user_level, max_tokens, temperature, top_p):
|
59 |
system_message = level_to_prompt(user_level)
|
|
|
98 |
value="A1",
|
99 |
label="Your French Level (CEFR)"
|
100 |
)
|
101 |
+
max_tokens = gr.Slider(1, 2048, value=300, step=1, label="Response Length")
|
102 |
+
temperature = gr.Slider(0.1, 4.0, value=0.5, step=0.1, label="Creativity")
|
103 |
+
top_p = gr.Slider(0.1, 1.0, value=0.8, step=0.05, label="Dynamic Text Sampling")
|
104 |
|
105 |
gr.ChatInterface(
|
106 |
respond,
|