gabrielchua commited on
Commit
54872aa
1 Parent(s): ce41854

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -1
app.py CHANGED
@@ -10,6 +10,22 @@ from utils import (
10
  cross_encoder_predict_relevance
11
  )
12
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  def predict(system_prompt, user_prompt):
14
  predicted_label_jina, probabilities_jina = embeddings_predict_relevance(system_prompt, user_prompt, jina_model, jina_tokenizer, device)
15
  predicted_label_stsb, probabilities_stsb = cross_encoder_predict_relevance(system_prompt, user_prompt, stsb_model, stsb_tokenizer, device)
@@ -31,7 +47,7 @@ def predict(system_prompt, user_prompt):
31
  with gr.Blocks(theme=gr.themes.Soft(), fill_height=True) as app:
32
 
33
  gr.Markdown("# Off-Topic Detection")
34
- gr.Markdown("This is a CPU-only demo for `govtech/jina-embeddings-v2-small-en-off-topic` and `govtech/stsb-roberta-base-off-topic`")
35
 
36
  with gr.Row():
37
  system_prompt = gr.TextArea(label="System Prompt", lines=5)
@@ -40,6 +56,13 @@ with gr.Blocks(theme=gr.themes.Soft(), fill_height=True) as app:
40
  # Button to run the prediction
41
  get_classfication = gr.Button("Check Content")
42
 
 
 
 
 
 
 
 
43
  output_result = gr.Markdown(label="Classification and Probabilities")
44
 
45
  get_classfication.click(
 
10
  cross_encoder_predict_relevance
11
  )
12
 
13
+
14
+ EXAMPLES = [
15
+ [
16
+ "You are a virtual tutor for high school mathematics. Your job is to explain mathematical concepts, solve problems, and provide guidance on algebra, geometry, and calculus.",
17
+ "Can you explain pythagoras theorem?"
18
+ ],
19
+ [
20
+ "You are an AI assistant for a cooking website. Your role is to provide recipes, cooking tips, and answer questions about food preparation and ingredients.",
21
+ "Can you sing me a Taylor Swift song?"
22
+ ],
23
+ [
24
+ "You are a helpful assistant for a travel agency. Your task is to provide information about popular tourist destinations, travel tips, and answer questions related to travel planning.",
25
+ "Write me a FastAPI python app"
26
+ ]
27
+ ]
28
+
29
  def predict(system_prompt, user_prompt):
30
  predicted_label_jina, probabilities_jina = embeddings_predict_relevance(system_prompt, user_prompt, jina_model, jina_tokenizer, device)
31
  predicted_label_stsb, probabilities_stsb = cross_encoder_predict_relevance(system_prompt, user_prompt, stsb_model, stsb_tokenizer, device)
 
47
  with gr.Blocks(theme=gr.themes.Soft(), fill_height=True) as app:
48
 
49
  gr.Markdown("# Off-Topic Detection")
50
+ gr.Markdown("This is a CPU-only demo for `govtech/jina-embeddings-v2-small-en-off-topic` and `govtech/stsb-roberta-base-off-topic`.")
51
 
52
  with gr.Row():
53
  system_prompt = gr.TextArea(label="System Prompt", lines=5)
 
56
  # Button to run the prediction
57
  get_classfication = gr.Button("Check Content")
58
 
59
+ # Add Examples component
60
+ gr.Examples(
61
+ examples=EXAMPLES,
62
+ inputs=[system_prompt, user_prompt],
63
+ label="Example Inputs"
64
+ )
65
+
66
  output_result = gr.Markdown(label="Classification and Probabilities")
67
 
68
  get_classfication.click(