Added multi process support
Browse files
app.py
CHANGED
@@ -114,7 +114,8 @@ data = pd.read_excel(UIDatasetURL)
|
|
114 |
columns = ['text', 'intent', 'process']
|
115 |
data.columns = columns
|
116 |
|
117 |
-
data = data[data["process"] == trainedProcess].drop(columns="process")
|
|
|
118 |
|
119 |
"""#### Category merging"""
|
120 |
|
@@ -398,25 +399,24 @@ def print_result(text: str, process) -> None:
|
|
398 |
else:
|
399 |
return(getP6String())
|
400 |
|
401 |
-
def chatbot(
|
402 |
""" By: Rafael Krstačić """
|
403 |
-
processName = trainedProcessJSON
|
404 |
currentProcess = None
|
405 |
|
406 |
for process in json:
|
407 |
-
if process["name"] ==
|
408 |
currentProcess = process
|
409 |
break
|
410 |
else:
|
411 |
raise KeyError("Process does not exist in json")
|
412 |
|
413 |
-
return print_result(
|
414 |
-
|
415 |
"""## Gradio app"""
|
416 |
|
417 |
iface = gr.Interface(
|
418 |
fn=chatbot,
|
419 |
-
inputs="text",
|
420 |
outputs=["text"],
|
421 |
title="Software module for answering questions on processes"
|
422 |
)
|
|
|
114 |
columns = ['text', 'intent', 'process']
|
115 |
data.columns = columns
|
116 |
|
117 |
+
# data = data[data["process"] == trainedProcess].drop(columns="process")
|
118 |
+
data = data.drop(columns="process")
|
119 |
|
120 |
"""#### Category merging"""
|
121 |
|
|
|
399 |
else:
|
400 |
return(getP6String())
|
401 |
|
402 |
+
def chatbot(Question, Process="Default") -> None:
|
403 |
""" By: Rafael Krstačić """
|
|
|
404 |
currentProcess = None
|
405 |
|
406 |
for process in json:
|
407 |
+
if process["name"] == Process:
|
408 |
currentProcess = process
|
409 |
break
|
410 |
else:
|
411 |
raise KeyError("Process does not exist in json")
|
412 |
|
413 |
+
return print_result(Question, currentProcess)
|
414 |
+
|
415 |
"""## Gradio app"""
|
416 |
|
417 |
iface = gr.Interface(
|
418 |
fn=chatbot,
|
419 |
+
inputs=["text", gr.inputs.Dropdown(["Praksa", "Izrada završnog rada"])],
|
420 |
outputs=["text"],
|
421 |
title="Software module for answering questions on processes"
|
422 |
)
|