Streamlit application available here.
Gradio application available here.
Made by Rafael Krstačić within the course Web aplikacije on the Faculty of Informatics in Pula.
Built applications ware developed with the goal of answering question around business processes in the form of a chatbot. The project is based on a machine learning module (built by Rafael Krstačić) was built with Gradio and Streamlit frameworks and is hosted on Hugging Face Spaces.
Mentor: doc. dr. sc. Nikola Tanković
One and only feature of this chatbot is to give an answer to the user query. A user query consists of a question and the process to which the question refers.
The implementation includes 2 separated applications that communicate with each other to achieve the goal. When the user submits a query on the Streamlit applicaiton, the application sends a HTTP POST request to the Gradio application that then feeds the query to the machine learning module. Module output is then returned and Gradio applicaiton sends a response with the answer in the body of the response.
These 2 apps communicate via Hugging Face Spaces (Gradio based) API https://hf.space/embed/rkrstacic/Software-module-for-answering-questions-on-processes/+/api/predict
. It is a HTTP POST
endpoint that accepts input payload: "data": [question, process]
and returns object with data
attribute with the list of 1 element, being the answer itself.
The request is being handled as following:
import requests
import json
url = 'https://hf.space/embed/rkrstacic/Software-module-for-answering-questions-on-processes/+/api/predict'
def _query(payload):
data = json.dumps(payload)
response = requests.request("POST", url, data=data)
return json.loads(response.content.decode("utf-8"))
def get_answer(question, process):
return _query({"data": [question, process]})["data"][0]
Download the Python script, open it in the editor (PyCharm, VS Code), install all of the necessary dependecies (pip install <module_name>
) and run the script.
Download the repository, open it in the editor (PyCharm, VS Code), install Streamlit (pip install streamlit
) and run the script with the Streamlit command (streamlit run .../<path>/app.py
).