File size: 764 Bytes
dacf14a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import streamlit as st
import requests

API_URL = "http://localhost:8000"

st.title("BERT Fine Tuned Model on IMBD dataset")

st.header("try with reviews")
question = st.text_input("Review")

if st.button("Get Answer"):
    if question:
        print(f"{API_URL}/qa/")
        response = requests.post(f"{API_URL}/qa/", json={"command": question})
        if response.status_code == 200:
            answer = response.json()
            st.write(f"**Review**: {answer['review']}")
            st.write(f"**Sentiment**: {answer['sentiment']}")
            st.write(f"**Probs**: {answer['probs']}")
        else:
            st.error(f"Error: {response.json().get('detail', 'Unknown error')}")
    else:
        st.error("Please provide both context and question.")