msamogh
commited on
Commit
•
b74bd43
0
Parent(s):
Add files
Browse files- app.py +46 -0
- requirements.txt +0 -0
- woz_nlu_agent/models/nlu/checkpoint +3 -0
- woz_nlu_agent/models/nlu/component_1_RegexFeaturizer.patterns.pkl +3 -0
- woz_nlu_agent/models/nlu/component_2_LexicalSyntacticFeaturizer.feature_to_idx_dict.pkl +3 -0
- woz_nlu_agent/models/nlu/component_3_CountVectorsFeaturizer.pkl +3 -0
- woz_nlu_agent/models/nlu/component_4_CountVectorsFeaturizer.pkl +3 -0
- woz_nlu_agent/models/nlu/component_5_DIETClassifier.data_example.pkl +3 -0
- woz_nlu_agent/models/nlu/component_5_DIETClassifier.entity_tag_specs.json +3 -0
- woz_nlu_agent/models/nlu/component_5_DIETClassifier.index_label_id_mapping.json +3 -0
- woz_nlu_agent/models/nlu/component_5_DIETClassifier.label_data.pkl +3 -0
- woz_nlu_agent/models/nlu/component_5_DIETClassifier.sparse_feature_sizes.pkl +3 -0
- woz_nlu_agent/models/nlu/component_5_DIETClassifier.tf_model.data-00000-of-00001 +3 -0
- woz_nlu_agent/models/nlu/component_5_DIETClassifier.tf_model.index +3 -0
- woz_nlu_agent/models/nlu/component_6_EntitySynonymMapper.json +3 -0
- woz_nlu_agent/models/nlu/metadata.json +3 -0
app.py
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from pprint import pprint, pformat
|
2 |
+
import gradio as gr
|
3 |
+
import click
|
4 |
+
from rasa.nlu.model import Interpreter
|
5 |
+
|
6 |
+
|
7 |
+
MODEL_PATH = "woz_nlu_agent/models/nlu"
|
8 |
+
interpreter = None
|
9 |
+
|
10 |
+
def predict(input):
|
11 |
+
|
12 |
+
def rasa_output(text):
|
13 |
+
message = str(text).strip()
|
14 |
+
result = interpreter.parse(message)
|
15 |
+
return result
|
16 |
+
|
17 |
+
response = rasa_output(input)
|
18 |
+
|
19 |
+
del response["response_selector"]
|
20 |
+
response["intent_ranking"] = response["intent_ranking"][:3]
|
21 |
+
if "id" in ressponse["intent"]:
|
22 |
+
del response["intent"]["id"]
|
23 |
+
for i in response["intent_ranking"]:
|
24 |
+
if "id" in i:
|
25 |
+
del i["id"]
|
26 |
+
for e in response["entities"]:
|
27 |
+
if "extractor" in e:
|
28 |
+
del e["extractor"]
|
29 |
+
if "start" in e and "end" in e:
|
30 |
+
del e["start"]
|
31 |
+
del e["end"]
|
32 |
+
|
33 |
+
return pformat(response, indent=4)
|
34 |
+
|
35 |
+
|
36 |
+
def main():
|
37 |
+
global interpreter
|
38 |
+
print("Loading model...")
|
39 |
+
interpreter = Interpreter.load(MODEL_PATH)
|
40 |
+
print("Model loaded.")
|
41 |
+
iface = gr.Interface(fn=predict, inputs="text", outputs="text")
|
42 |
+
iface.launch()
|
43 |
+
|
44 |
+
|
45 |
+
if __name__ == "__main__":
|
46 |
+
main()
|
requirements.txt
ADDED
File without changes
|
woz_nlu_agent/models/nlu/checkpoint
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:51184b9b42276c21a0c873977421ce911fda1af8422b3ae4ac48ff294d1d7c6a
|
3 |
+
size 127
|
woz_nlu_agent/models/nlu/component_1_RegexFeaturizer.patterns.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:4f53cda18c2baa0c0354bb5f9a3ecbe5ed12ab4d8e11ba873c2f11161202b945
|
3 |
+
size 2
|
woz_nlu_agent/models/nlu/component_2_LexicalSyntacticFeaturizer.feature_to_idx_dict.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:3175e5b86a6400d2019e6cdd2546d0d32b268012450d4b2e28caabfee5765733
|
3 |
+
size 439
|
woz_nlu_agent/models/nlu/component_3_CountVectorsFeaturizer.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:88321e53813b860ed7600331a1385171d817159277638d22c6d8a877dc6c3126
|
3 |
+
size 5395
|
woz_nlu_agent/models/nlu/component_4_CountVectorsFeaturizer.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:d0d9298ac63db6f1b6954698e817e83aca1cdb4da3c74ea3174c0ac665b74ec1
|
3 |
+
size 33141
|
woz_nlu_agent/models/nlu/component_5_DIETClassifier.data_example.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:2222633792ce60ae5f706c0ddf34f14a5f5063b959a8b50b6c9a0485f96c31ec
|
3 |
+
size 3799
|
woz_nlu_agent/models/nlu/component_5_DIETClassifier.entity_tag_specs.json
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:79834ea9e2ab8e329737fdd2dabeb1543d678630244feb38128b5ddc7b98aece
|
3 |
+
size 3882
|
woz_nlu_agent/models/nlu/component_5_DIETClassifier.index_label_id_mapping.json
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:6a54d290bfbc685d23cddfd914c61a19e0f32d171abb7e583b12842d5984bb38
|
3 |
+
size 234
|
woz_nlu_agent/models/nlu/component_5_DIETClassifier.label_data.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:7b484f3e590845431687e460af46c79167ddd059d6831572d5c205401438676c
|
3 |
+
size 2528
|
woz_nlu_agent/models/nlu/component_5_DIETClassifier.sparse_feature_sizes.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e45402e2f6129b6f4f77e009896a8d642ea3fea1a99b5018c3348432c93c82c4
|
3 |
+
size 70
|
woz_nlu_agent/models/nlu/component_5_DIETClassifier.tf_model.data-00000-of-00001
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:36b1e5d94add489a6c505182f8aa7eecfd04d7eab26a40b597f5d8fd5e1453d0
|
3 |
+
size 35237395
|
woz_nlu_agent/models/nlu/component_5_DIETClassifier.tf_model.index
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:4b19406dc2b338a2504653dc2bf57e86f94fa91a0a3fcc39196a407b01f6c712
|
3 |
+
size 12482
|
woz_nlu_agent/models/nlu/component_6_EntitySynonymMapper.json
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:3b0cbfce5b0e714a7d63de0e9aff31d7b5cbae8f4ace7166153cf872fe7b9545
|
3 |
+
size 280
|
woz_nlu_agent/models/nlu/metadata.json
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:cd54b1af5dbf35c2691c0d220805b9250d1527771fadcea72be337bffbd928db
|
3 |
+
size 8768
|