Spaces:
Sleeping
Sleeping
MikaelYu-I
commited on
Commit
•
b082513
1
Parent(s):
b5cbb5f
Update app.py
Browse files
app.py
CHANGED
@@ -1,12 +1,7 @@
|
|
1 |
import os
|
2 |
-
|
3 |
import openai
|
4 |
import streamlit as st
|
5 |
|
6 |
-
# Set the OpenAI API key
|
7 |
-
os.environ["OPENAI_API_KEY"] = "sk-proj-yCa8xuZojVBCMM0r7q3hT3BlbkFJwjPh2CN3opBzjby3hg2J"
|
8 |
-
openai.api_key = os.getenv("OPENAI_API_KEY")
|
9 |
-
|
10 |
# Define the prompt template
|
11 |
def generate_poem(theme):
|
12 |
response = openai.ChatCompletion.create(
|
@@ -27,7 +22,16 @@ def chain_prompts(initial_theme):
|
|
27 |
refined_output = generate_poem(refined_prompt)
|
28 |
return refined_output
|
29 |
|
30 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
st.title("Poetry Generator")
|
32 |
theme = st.text_input("Enter a theme or prompt for your poem:")
|
33 |
|
|
|
1 |
import os
|
|
|
2 |
import openai
|
3 |
import streamlit as st
|
4 |
|
|
|
|
|
|
|
|
|
5 |
# Define the prompt template
|
6 |
def generate_poem(theme):
|
7 |
response = openai.ChatCompletion.create(
|
|
|
22 |
refined_output = generate_poem(refined_prompt)
|
23 |
return refined_output
|
24 |
|
25 |
+
# Initialize the sidebar for API key entry
|
26 |
+
st.sidebar.title("Settings")
|
27 |
+
api_key = st.sidebar.text_input("Enter OpenAI API Key", type="password")
|
28 |
+
os.environ["OPENAI_API_KEY"] = api_key
|
29 |
+
openai.api_key = os.getenv("OPENAI_API_KEY")
|
30 |
+
|
31 |
+
# Additional sidebar options
|
32 |
+
# Here you can add more inputs or settings that are relevant to your application
|
33 |
+
|
34 |
+
# Streamlit app main area
|
35 |
st.title("Poetry Generator")
|
36 |
theme = st.text_input("Enter a theme or prompt for your poem:")
|
37 |
|