hfariborzi commited on
Commit
0aa905c
ยท
verified ยท
1 Parent(s): 7f3512d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +43 -38
app.py CHANGED
@@ -1,41 +1,46 @@
1
  import streamlit as st
2
- import pandas as pd
3
- import matplotlib.pyplot as plt
4
- import seaborn as sns
5
- import numpy as np
6
-
7
-
8
-
9
-
10
- # App Title
11
- st.title("๐Ÿ“Š Streamlit Data Analysis Tool")
12
-
13
- # Upload CSV File
14
- uploaded_file = st.file_uploader("Upload a CSV file", type=["csv"])
15
-
16
- if uploaded_file:
17
- df = pd.read_csv(uploaded_file)
18
- st.write("### Preview of Uploaded Data")
19
- st.dataframe(df.head())
20
-
21
- # Dropdown for column selection
22
- numeric_cols = df.select_dtypes(include=['number']).columns.tolist()
23
- if numeric_cols:
24
- col_to_analyze = st.selectbox("Select a column to analyze", numeric_cols)
25
-
26
- # Summary statistics
27
- st.write("### Summary Statistics")
28
- st.write(df[col_to_analyze].describe())
29
-
30
- # Histogram Slider
31
- bins = st.slider("Number of bins for histogram", min_value=5, max_value=50, value=20)
32
-
33
- # Plot Histogram
34
- fig, ax = plt.subplots()
35
- sns.histplot(df[col_to_analyze], bins=bins, kde=True, ax=ax)
36
- st.pyplot(fig)
 
 
 
 
 
 
 
37
  else:
38
- st.warning("No numeric columns found in the dataset.")
39
 
40
- else:
41
- st.info("Please upload a CSV file to get started.")
 
1
  import streamlit as st
2
+ import google.generativeai as genai
3
+
4
+ # Configure Gemini API (Replace with your own API key)
5
+ GOOGLE_API_KEY = "YOUR_GOOGLE_API_KEY"
6
+ genai.configure(api_key=GOOGLE_API_KEY)
7
+
8
+ # Function to generate a funny story
9
+ def get_funny_story(query, style, length):
10
+ prompt = (
11
+ f"Write a funny short story based on this query: '{query}'. "
12
+ f"Make it {length} sentences long and style it as {style}. "
13
+ "The story should be humorous and entertaining."
14
+ )
15
+
16
+ try:
17
+ model = genai.GenerativeModel("gemini-pro")
18
+ response = model.generate_content(prompt)
19
+ return response.text
20
+ except Exception as e:
21
+ return f"Error generating story: {e}"
22
+
23
+ # Streamlit UI
24
+ st.title("๐Ÿ˜‚ Funny Story Generator")
25
+
26
+ # User Input: Query
27
+ query = st.text_input("Enter a topic or query for your funny story:")
28
+
29
+ # User Input: Story Style (Dropdown)
30
+ style = st.selectbox(
31
+ "Select a storytelling style:",
32
+ ["Witty and Sarcastic", "Goofy and Childish", "Epic and Dramatic", "Absurd and Nonsensical"]
33
+ )
34
+
35
+ # User Input: Story Length (Slider)
36
+ length = st.slider("Select story length (in sentences)", min_value=3, max_value=15, value=7)
37
+
38
+ # Generate Story Button
39
+ if st.button("Generate Funny Story"):
40
+ if query.strip():
41
+ story = get_funny_story(query, style, length)
42
+ st.subheader("๐Ÿ“– Your Funny Story:")
43
+ st.write(story)
44
  else:
45
+ st.warning("Please enter a query for your story.")
46