Spaces:
Sleeping
Sleeping
jonathanjordan21
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -38,7 +38,7 @@ codes = """001 - Vehicle Registration (New)
|
|
38 |
031 - Tax Exemption Application (for special cases)
|
39 |
032 - Deceased Owner’s Vehicle Ownership Transfer""".split("\n")
|
40 |
|
41 |
-
|
42 |
|
43 |
|
44 |
model = SentenceTransformer('sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2')
|
@@ -50,11 +50,14 @@ def respond(
|
|
50 |
threshold
|
51 |
):
|
52 |
global codes_emb
|
|
|
|
|
|
|
53 |
|
54 |
-
if history and history[-1][-1][21:24] ==
|
55 |
list_his = ""
|
56 |
for his in history[::-1]:
|
57 |
-
if his[-1][21:24] !=
|
58 |
break
|
59 |
list_his = his[0] + "\n" + list_his
|
60 |
|
@@ -74,7 +77,8 @@ def respond(
|
|
74 |
s_max = scores.argmax()
|
75 |
|
76 |
if scores[s_max] < threshold:
|
77 |
-
request_code = "033 - Other/Undetected"
|
|
|
78 |
else:
|
79 |
request_code = codes[scores.argmax()]
|
80 |
|
@@ -114,15 +118,15 @@ For information on how to customize the ChatInterface, peruse the gradio docs: h
|
|
114 |
with gr.Blocks() as demo:
|
115 |
# Add header title and description
|
116 |
gr.Markdown("# List of Request Numbers")
|
117 |
-
gr.Markdown("<br>".join(codes))
|
118 |
gr.Markdown("# Valid License Plate Number Criteria:")
|
119 |
-
gr.Markdown("(1-2
|
120 |
|
121 |
# Add chat interface
|
122 |
chat_interface = gr.ChatInterface(
|
123 |
respond,
|
124 |
additional_inputs=[
|
125 |
-
gr.Number(0.5, label="threshold
|
126 |
]
|
127 |
)
|
128 |
|
|
|
38 |
031 - Tax Exemption Application (for special cases)
|
39 |
032 - Deceased Owner’s Vehicle Ownership Transfer""".split("\n")
|
40 |
|
41 |
+
undetected = "099 - Other/Undetected"
|
42 |
|
43 |
|
44 |
model = SentenceTransformer('sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2')
|
|
|
50 |
threshold
|
51 |
):
|
52 |
global codes_emb
|
53 |
+
global undetected
|
54 |
+
|
55 |
+
undetected_code = undetected[:3]
|
56 |
|
57 |
+
if history and history[-1][-1][21:24] == undetected_code:
|
58 |
list_his = ""
|
59 |
for his in history[::-1]:
|
60 |
+
if his[-1][21:24] != undetected_code:
|
61 |
break
|
62 |
list_his = his[0] + "\n" + list_his
|
63 |
|
|
|
77 |
s_max = scores.argmax()
|
78 |
|
79 |
if scores[s_max] < threshold:
|
80 |
+
# request_code = "033 - Other/Undetected"
|
81 |
+
request_code = undetected
|
82 |
else:
|
83 |
request_code = codes[scores.argmax()]
|
84 |
|
|
|
118 |
with gr.Blocks() as demo:
|
119 |
# Add header title and description
|
120 |
gr.Markdown("# List of Request Numbers")
|
121 |
+
gr.Markdown("<br>".join(codes) + "<br>" + undetected)
|
122 |
gr.Markdown("# Valid License Plate Number Criteria:")
|
123 |
+
gr.Markdown("(1-2 letters) (4 numbers) (1-3 letters)")
|
124 |
|
125 |
# Add chat interface
|
126 |
chat_interface = gr.ChatInterface(
|
127 |
respond,
|
128 |
additional_inputs=[
|
129 |
+
gr.Number(0.5, label="confidence threshold", show_label=True, minimum=0., maximum=1.0, step=0.1)
|
130 |
]
|
131 |
)
|
132 |
|