34 lines
867 B
Python
34 lines
867 B
Python
import requests
|
|
import json
|
|
import streamlit as st
|
|
|
|
def predict(context,question):
|
|
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()
|