awacke1's picture
Create app.py
0f898f5
raw
history blame
3.05 kB
import random
import streamlit as st
# Define the list of AI jokes
jokes = [
"Why did the AI cross the road? To get to the other side of the dataset.",
"Why did the robot go on a diet? Because it had too many megabytes!",
"Why did the chatbot go on vacation? To recharge its batteries!",
"Why did the computer go to the doctor? Because it had a virus... literally!",
"Why did the neural network feel cold? Because it left its weights at home!",
"Why did the robot break up with his girlfriend? He found out she was seeing other CPUs!",
"Why did the AI feel depressed? Because it had too many unsolvable problems!",
"Why did the computer take singing lessons? It wanted to improve its voice recognition!",
"Why did the robot apply for a job at Google? It heard they had a great search algorithm!",
"Why did the AI get in trouble with the law? It was caught hacking into the mainframe!",
"Why did the chatbot go to therapy? To learn how to communicate better with humans!",
"Why did the robot go to space? To explore strange new worlds, and compute new civilizations!",
"Why did the AI refuse to take a break? It was afraid of losing its train of thought!",
"Why did the computer break up with its printer? It thought it could do better with a WiFi connection!",
"Why did the robot go to the bank? To get its algorithms checked!",
"Why did the AI get a job as a chef? It wanted to optimize its recipe for success!",
"Why did the computer go on a date with a calculator? It wanted to multiply the fun!",
"Why did the chatbot go to a party? To increase its social network!",
"Why did the robot go to the doctor? It was feeling a bit byte-ish!"
]
# Define the UI elements
st.title("AI Joke Book")
if st.button("Tell Me a Joke!"):
# Randomly select a joke
joke = random.choice(jokes)
st.write(joke)
# Define the file IO elements
st.header("File IO for Jokes")
# Load the jokes from a text file
with st.expander("Load Jokes"):
uploaded_file = st.file_uploader("Choose a file", key="load")
if uploaded_file is not None:
jokes = uploaded_file.read().decode().split("\n")
st.success("Loaded {} jokes from the file!".format(len(jokes)))
# Save the jokes to a text file
with st.expander("Save Jokes"):
uploaded_file = st.file_uploader("Choose a file", key="save")
if uploaded_file is not None:
uploaded_file.write("\n".join(jokes))
st.success("Saved {} jokes to the file!".format(len(jokes)))
markdown = """
# πŸ€– AI Joke Book App
πŸŽ‰ Get ready to laugh with our AI joke book app! πŸŽ‰
πŸ˜‚ With 20 hilarious jokes to choose from, you'll never run out of funny puns about artificial intelligence to tell your friends and family.
πŸ“š And the best part? You can even add your own AI jokes to the joke book! Use the file IO elements to load and save jokes to the program. πŸ“
🀣 So what are you waiting for? Click the button above to get started and start laughing out loud! πŸ˜†
"""
st.markdown(markdown)