-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdecoration_scraper.py
54 lines (42 loc) · 1.96 KB
/
decoration_scraper.py
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
import streamlit as st
import openai
import os
from streamlit_extras.stoggle import stoggle
openai_api_key = st.secrets["openai_key"]
# Set the OpenAI API key
openai.api_key = openai_api_key
def generate_response(prompt, user_input):
response = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=[
{"role": "system", "content": prompt},
{"role": "user", "content": user_input},
],
)
return response.choices[0].message['content']
def app():
st.title("The spoookiest time of the year!")
st.subheader("👻🎃💀")
st.markdown("## History of Halloween")
# Add a checkbox to show or hide the history section
stoggle(
"Show the History of Halloween!",
"""'<iframe src="https://blogs.loc.gov/headlinesandheroes/2021/10/the-origins-of-halloween-traditions/" width="100%" height="450"></iframe>', unsafe_allow_html=True)"""
)
st.markdown("---") # Add horizontal line for separation
st.markdown("## Halloween Recipe and Decoration Generator")
# Dropdown menu for user to select recipe or decoration
option = st.selectbox('What would you like help with?', ['Halloween Recipe', 'DIY Halloween Decoration'])
user_prompt = st.text_input('Enter more specifics (optional)')
if st.button('Get Ideas'):
if option == 'Halloween Recipe':
system_prompt = "You are an expert chef who specializes in creating fun and spooky Halloween recipes."
with st.spinner("Cooking up the recipe..."):
response = generate_response(system_prompt, user_prompt)
st.write(response)
else:
system_prompt = "You are a skilled craftsman with a knack for DIY Halloween decorations."
with st.spinner("Searching the craft box..."):
response = generate_response(system_prompt, user_prompt)
st.write(response)
app()