CCockrum commited on
Commit
c1df208
·
verified ·
1 Parent(s): 656144e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -4,7 +4,7 @@ import os
4
 
5
  client = InferenceClient("HuggingFaceH4/zephyr-7b-beta", token=os.getenv("HF_TOKEN"))
6
 
7
- # 💡 Dynamic prompt builder based on CEFR level
8
  def level_to_prompt(level):
9
  return {
10
  "A1": "You are a friendly French tutor. Speak mostly in English, use simple French, and explain everything.",
@@ -15,7 +15,7 @@ def level_to_prompt(level):
15
  "C2": "You are a native French professor. Speak in rich, complex French. Avoid English."
16
  }.get(level, "You are a helpful French tutor.")
17
 
18
- # Custom background CSS
19
  css = """
20
  @import url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP&family=Playfair+Display&display=swap');
21
  body {
@@ -54,7 +54,7 @@ body {
54
  """
55
 
56
 
57
- # Chat logic
58
  def respond(message, history, level, max_tokens, temperature, top_p):
59
  system_message = level_to_prompt(level)
60
  messages = [{"role": "system", "content": system_message}]
@@ -88,7 +88,7 @@ def respond(message, history, level, max_tokens, temperature, top_p):
88
  print(f"Error in chat completion: {e}")
89
  yield f"Désolé! There was an error: {str(e)}"
90
 
91
- # UI layout
92
  with gr.Blocks(css=css) as demo:
93
  gr.Markdown("French Tutor", elem_id="custom-title")
94
  with gr.Column(elem_id="chat-panel"):
 
4
 
5
  client = InferenceClient("HuggingFaceH4/zephyr-7b-beta", token=os.getenv("HF_TOKEN"))
6
 
7
+ #Dynamic prompt builder based on CEFR level
8
  def level_to_prompt(level):
9
  return {
10
  "A1": "You are a friendly French tutor. Speak mostly in English, use simple French, and explain everything.",
 
15
  "C2": "You are a native French professor. Speak in rich, complex French. Avoid English."
16
  }.get(level, "You are a helpful French tutor.")
17
 
18
+ #Custom background CSS
19
  css = """
20
  @import url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP&family=Playfair+Display&display=swap');
21
  body {
 
54
  """
55
 
56
 
57
+ #Chat logic
58
  def respond(message, history, level, max_tokens, temperature, top_p):
59
  system_message = level_to_prompt(level)
60
  messages = [{"role": "system", "content": system_message}]
 
88
  print(f"Error in chat completion: {e}")
89
  yield f"Désolé! There was an error: {str(e)}"
90
 
91
+ #UI layout
92
  with gr.Blocks(css=css) as demo:
93
  gr.Markdown("French Tutor", elem_id="custom-title")
94
  with gr.Column(elem_id="chat-panel"):