indiapuig commited on
Commit
1e94153
Β·
verified Β·
1 Parent(s): 63120d8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -4
app.py CHANGED
@@ -1,9 +1,11 @@
1
  import gradio as gr
2
  from huggingface_hub import InferenceClient
 
 
3
 
4
  client = InferenceClient("microsoft/phi-4")
5
 
6
- # Topics
7
  BIO_TOPICS = [
8
  "Cell Biology",
9
  "Organisation",
@@ -21,14 +23,14 @@ def set_topic(topic):
21
  chosen_topic = topic
22
  return f"βœ… Great! You've chosen **{topic}**. Let's start your study session."
23
 
 
 
24
  def respond(message, history):
25
  global chosen_topic
26
- if not chosen_topic:
27
- return "⚠️ Please choose a topic before starting."
28
 
29
  messages = [{
30
  "role": "system",
31
- "content": f"You are a friendly GCSE Biology tutor focusing on **{chosen_topic}**."
32
  }]
33
 
34
  if history:
@@ -42,6 +44,8 @@ def respond(message, history):
42
  )
43
  return response['choices'][0]['message']['content'].strip()
44
 
 
 
45
  # Create the Gradio interface
46
  with gr.Blocks() as demo:
47
  gr.Markdown("# ACE it! πŸ“š β€” GCSE Biology Tutor")
@@ -56,5 +60,7 @@ with gr.Blocks() as demo:
56
 
57
  topic_button.click(set_topic, inputs=topic_dropdown, outputs=topic_output)
58
 
 
 
59
  demo.launch()
60
 
 
1
  import gradio as gr
2
  from huggingface_hub import InferenceClient
3
+ import torch
4
+ from sentance-transformers import SentanceTransformer
5
 
6
  client = InferenceClient("microsoft/phi-4")
7
 
8
+ # Topic list
9
  BIO_TOPICS = [
10
  "Cell Biology",
11
  "Organisation",
 
23
  chosen_topic = topic
24
  return f"βœ… Great! You've chosen **{topic}**. Let's start your study session."
25
 
26
+
27
+
28
  def respond(message, history):
29
  global chosen_topic
 
 
30
 
31
  messages = [{
32
  "role": "system",
33
+ "content": f"You are a friendly GCSE Biology tutor focusing on **{chosen_topic}**." # Add full on prompt
34
  }]
35
 
36
  if history:
 
44
  )
45
  return response['choices'][0]['message']['content'].strip()
46
 
47
+
48
+
49
  # Create the Gradio interface
50
  with gr.Blocks() as demo:
51
  gr.Markdown("# ACE it! πŸ“š β€” GCSE Biology Tutor")
 
60
 
61
  topic_button.click(set_topic, inputs=topic_dropdown, outputs=topic_output)
62
 
63
+
64
+
65
  demo.launch()
66