Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -3,34 +3,33 @@ import openai
|
|
3 |
import os
|
4 |
|
5 |
|
6 |
-
def
|
7 |
try:
|
8 |
-
augmented_prompt = f"
|
9 |
st.session_state["summary"] = openai.Completion.create(
|
10 |
-
model=
|
11 |
prompt=augmented_prompt,
|
12 |
temperature=.3,
|
13 |
-
max_tokens=
|
14 |
)["choices"][0]["text"]
|
15 |
except:
|
16 |
st.write('There was an error =(')
|
17 |
|
18 |
-
# openai.api_key = os.getenv('OPENAI_KEY')
|
19 |
try:
|
20 |
if "summary" not in st.session_state:
|
21 |
st.session_state["summary"] = ""
|
22 |
openai_api_key = st.text_input("Enter Your OpenAI API key: ", key="key_input",type="password")
|
23 |
openai.api_key = openai_api_key
|
24 |
-
st.title("Text
|
25 |
|
26 |
-
input_text = st.text_area(label="Enter full text:", value="", height=
|
27 |
|
28 |
st.button(
|
29 |
"Submit",
|
30 |
-
on_click=
|
31 |
kwargs={"prompt": input_text},
|
32 |
)
|
33 |
|
34 |
-
output_text = st.text_area(label="
|
35 |
except:
|
36 |
st.write('An error occured, Please contact the developer')
|
|
|
3 |
import os
|
4 |
|
5 |
|
6 |
+
def classify(prompt):
|
7 |
try:
|
8 |
+
augmented_prompt = f"{prompt} \n\n###\n\n"
|
9 |
st.session_state["summary"] = openai.Completion.create(
|
10 |
+
model="ada:ft-personal:prt-model-2023-02-10-07-36-17",#"text-davinci-003",
|
11 |
prompt=augmented_prompt,
|
12 |
temperature=.3,
|
13 |
+
max_tokens=1,
|
14 |
)["choices"][0]["text"]
|
15 |
except:
|
16 |
st.write('There was an error =(')
|
17 |
|
|
|
18 |
try:
|
19 |
if "summary" not in st.session_state:
|
20 |
st.session_state["summary"] = ""
|
21 |
openai_api_key = st.text_input("Enter Your OpenAI API key: ", key="key_input",type="password")
|
22 |
openai.api_key = openai_api_key
|
23 |
+
st.title("Text Classification")
|
24 |
|
25 |
+
input_text = st.text_area(label="Enter full text:", value="", height=300)
|
26 |
|
27 |
st.button(
|
28 |
"Submit",
|
29 |
+
on_click=classify,
|
30 |
kwargs={"prompt": input_text},
|
31 |
)
|
32 |
|
33 |
+
output_text = st.text_area(label="Sentiment of text:", value=st.session_state["summary"], height=5)
|
34 |
except:
|
35 |
st.write('An error occured, Please contact the developer')
|