DIPLOMOVA_PRACA/Streamlit/aplication.py

37 lines
952 B
Python
Raw Permalink Normal View History

import requests
import json
import streamlit as st
import os
from dotenv import load_dotenv
load_dotenv()
def predict(context,question):
url = os.getenv("URL")
#url = 'http://localhost:8090/predict'
data = {'context': context,'question': question}
json_data = json.dumps(data)
headers = {'Content-type': 'application/json'}
response = requests.post(url, data=json_data, headers=headers)
result = response.json()
return result
def main():
st.title("T5 model inference")
# Vytvoríme polia pre zadanie hodnôt
context = st.text_input("context:")
question = st.text_input("question:")
prediction = predict(context,question)
# Vytvoríme tlačidlo pre vykonanie akcie
if st.button("Execute"):
st.json({
'context': context,
'question': question,
'prediciton':prediction
})
if __name__ == "__main__":
main()