Spaces:
Runtime error
Runtime error
Create new file
Browse files
model.py
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from model import GeneralModel
|
3 |
+
|
4 |
+
|
5 |
+
def app():
|
6 |
+
|
7 |
+
# Creating an object of prediction service
|
8 |
+
pred = GeneralModel()
|
9 |
+
|
10 |
+
api_key = st.sidebar.text_input("APIkey", type="password")
|
11 |
+
# Using the streamlit cache
|
12 |
+
@st.cache
|
13 |
+
def process_prompt(input):
|
14 |
+
|
15 |
+
return pred.model_prediction(input=input.strip() , api_key=api_key)
|
16 |
+
|
17 |
+
if api_key:
|
18 |
+
|
19 |
+
# Setting up the Title
|
20 |
+
st.title("Escritor GPT-3")
|
21 |
+
|
22 |
+
# st.write("---")
|
23 |
+
|
24 |
+
s_example = "Escriba un ensayo argumentativo a favor de los vouchers escolares"
|
25 |
+
input = st.text_area(
|
26 |
+
"Use el ejemplo de abajo o escriba su propio texto en español",
|
27 |
+
value=s_example,
|
28 |
+
max_chars=1250,
|
29 |
+
height=50,
|
30 |
+
)
|
31 |
+
|
32 |
+
if st.button("Submit"):
|
33 |
+
with st.spinner(text="In progress"):
|
34 |
+
report_text = process_prompt(input)
|
35 |
+
st.markdown(report_text)
|
36 |
+
else:
|
37 |
+
st.error("🔑 Please enter API Key")
|