File size: 1,078 Bytes
20f5920
 
 
 
 
28ff216
20f5920
28ff216
20f5920
28ff216
20f5920
 
28ff216
20f5920
 
 
 
 
 
 
 
 
28ff216
20f5920
28ff216
20f5920
 
 
28ff216
20f5920
 
 
28ff216
20f5920
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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')