msamogh commited on
Commit
c2e2c3b
1 Parent(s): df7fa67

Add dropdown for model type

Browse files
Files changed (1) hide show
  1. app.py +18 -3
app.py CHANGED
@@ -6,10 +6,25 @@ import click
6
  from rasa.nlu.model import Interpreter
7
 
8
 
9
- MODEL_PATH = "woz_nlu_agent/models/nlu"
10
  interpreter = None
11
 
12
- def predict(input):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
 
14
  def rasa_output(text):
15
  message = str(text).strip()
@@ -45,7 +60,7 @@ def main():
45
 
46
  interpreter = Interpreter.load(MODEL_PATH)
47
  print("Model loaded.")
48
- iface = gr.Interface(fn=predict, inputs="text", outputs="text")
49
  iface.launch()
50
 
51
 
 
6
  from rasa.nlu.model import Interpreter
7
 
8
 
9
+ RASA_MODEL_PATH = "woz_nlu_agent/models/nlu"
10
  interpreter = None
11
 
12
+ MODEL_TYPES = {
13
+ "Out-of-scope classifier": "oos",
14
+ "Intent classifier": "intent_transformer",
15
+ "Intent and Entity extractor": "rasa_intent_entity"
16
+ }
17
+
18
+ def predict(model_type, input):
19
+ if MODEL_TYPES[model_type] == "rasa_intent_entity":
20
+ return rasa_predict(input)
21
+ elif MODEL_TYPES[model_tyoe] == "oos":
22
+ return "TODO: out of scope"
23
+ elif MODEL_TYPES[model_type] == "intent_transformer":
24
+ return "TODO:: intent_transformer"
25
+
26
+
27
+ def rasa_predict(input):
28
 
29
  def rasa_output(text):
30
  message = str(text).strip()
 
60
 
61
  interpreter = Interpreter.load(MODEL_PATH)
62
  print("Model loaded.")
63
+ iface = gr.Interface(fn=predict, inputs=[gr.Dropdown(MODEL_TYPES.keys()), "text"], outputs="text")
64
  iface.launch()
65
 
66