pradosh's picture
Update app.py
28ff216
import streamlit as st
import openai
import os
def classify(prompt):
try:
augmented_prompt = f"{prompt} \n\n###\n\n"
st.session_state["summary"] = openai.Completion.create(
model="ada:ft-personal:prt-model-2023-02-10-07-36-17",#"text-davinci-003",
prompt=augmented_prompt,
temperature=.3,
max_tokens=1,
)["choices"][0]["text"]
except:
st.write('There was an error =(')
try:
if "summary" not in st.session_state:
st.session_state["summary"] = ""
openai_api_key = st.text_input("Enter Your OpenAI API key: ", key="key_input",type="password")
openai.api_key = openai_api_key
st.title("Text Classification")
input_text = st.text_area(label="Enter full text:", value="", height=300)
st.button(
"Submit",
on_click=classify,
kwargs={"prompt": input_text},
)
output_text = st.text_area(label="Sentiment of text:", value=st.session_state["summary"], height=5)
except:
st.write('An error occured, Please contact the developer')