Spaces:
Runtime error
Runtime error
File size: 1,534 Bytes
92f8cd3 0837f80 92f8cd3 66c6cef 92f8cd3 6358421 92f8cd3 |
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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
import streamlit as st
import openai
#streamlit run main.py
# import os
# os.environ.getattribute("openai.api_key")
header = st.container()
about = st.container()
model_output = st.container()
with header:
st.title('RHYME THYME')
#st.text('This this bot-bop-shop uses Artificail Ingredients \
#(AI) to produce natural flavors.')
with model_output:
st.header('Half-baked Takes:')
sel_col, disp_col = st.columns(2)
sel_col.subheader('Input ideas')
#input_poem = sel_col.selectbox('What type of poem do you want to write?', options=['limerick', 'haiku', 'sonnet', 'acrostic', 'villanelle', 'ode', 'elegy', 'ballad', 'couplet', 'tercet', 'quatrain', 'cinquan', 'sestet'])
input_word1 = sel_col.text_input('Input a word to use in the poem:')
input_word2 = sel_col.text_input('Input another word to use in the poem:')
# This is the NLP model
def generate_poem(input_word1, input_word2):
# Use GPT-3 to generate a limerick based on the user's input word
prompt = f"Write a limerick in AABBA rhyme scheme about {input_word1} and '{input_word2}':"
completions = openai.Completion.create(
engine="text-davinci-002",
prompt=prompt,
max_tokens=1024,
n=1,
stop=None,
temperature=0.5,
)
# Return the generated limerick
return completions.choices[0].text
limerick = generate_poem(input_word1.lower(), input_word2.lower())
# This is where the results are displayed on the app
disp_col.subheader('Limerick output')
disp_col.write(limerick)
|