CCockrum commited on
Commit
09a42a6
·
verified ·
1 Parent(s): 211a88e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -9
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. Speak mostly in English, use simple French, and explain everything.",
49
- "A2": "You are a patient French tutor. Use short French phrases and explain them in English.",
50
- "B1": "You are a helpful French tutor. Speak mostly in French but clarify in English when needed.",
51
- "B2": "You are a French tutor. Speak primarily in French with rare English support.",
52
- "C1": "You are a native French tutor. Speak entirely in French, clearly and professionally.",
53
- "C2": "You are a native French professor. Speak in rich, complex French. Avoid English."
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=512, step=1, label="Response Length")
101
- temperature = gr.Slider(0.1, 4.0, value=0.7, step=0.1, label="Creativity")
102
- top_p = gr.Slider(0.1, 1.0, value=0.95, step=0.05, label="Dynamic Text Sampling")
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,