Spaces:
Sleeping
Sleeping
ibrahim313
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -4,9 +4,10 @@ from groq import Groq
|
|
4 |
from streamlit.components.v1 import html
|
5 |
|
6 |
# Load Groq API key from environment variable
|
7 |
-
groq_api_key = os.getenv('
|
8 |
if not groq_api_key:
|
9 |
-
|
|
|
10 |
|
11 |
# Initialize Groq client
|
12 |
groq_client = Groq(api_key=groq_api_key)
|
@@ -14,49 +15,7 @@ groq_client = Groq(api_key=groq_api_key)
|
|
14 |
# Few-shot examples for inspiration
|
15 |
few_shot_examples = """
|
16 |
π’ **Data Scaling Showdown: Normalization vs Standardization!** π
|
17 |
-
|
18 |
-
Ever felt like your data is on a rollercoaster? π‘ Some values reaching for the stars, others barely off the ground? Time to level the playing field with the dynamic duo of data scaling: **Normalization** and **Standardization!** πͺ
|
19 |
-
|
20 |
-
π **Normalization: The Range Ranger**
|
21 |
-
πΈ What: Squeezes your data into a cozy 0-1 range.
|
22 |
-
πΈ Why: Perfect for when your features are as different as apples and skyscrapers! πποΈ
|
23 |
-
πΈ Best for: k-NN, neural networks, and data that's living its best non-normal life.
|
24 |
-
πΈ Superpower: Taming wild data ranges without breaking a sweat!
|
25 |
-
|
26 |
-
π **Standardization: The Gaussian Don**
|
27 |
-
π· What: Centers your data around 0, with a standard deviation of 1.
|
28 |
-
π· Why: Ideal when your data follows the bell curve or your algorithm is a normal distribution fan.
|
29 |
-
π· Best for: Logistic regression, SVM, and PCA - the cool kids of the ML world.
|
30 |
-
π· Superpower: Handling outliers like a boss!
|
31 |
-
|
32 |
-
π₯ **The Face-Off**
|
33 |
-
**Normalization:** "Let's all fit in this box!" π¦
|
34 |
-
**Standardization:** "Let's dance around the mean!" π
|
35 |
-
|
36 |
-
Use Normalization for diverse data like a candy store π, and Standardization when your data fits the normal crowd π.
|
37 |
-
|
38 |
-
#DataScience #NormalizationVsStandardization #AITricks
|
39 |
-
|
40 |
-
---
|
41 |
-
π― **Binary Classification or Multiclass? Here's How to Choose!** π―
|
42 |
-
|
43 |
-
Choosing between **binary** and **multiclass classification** can feel like picking the perfect dessertβdo you want the classic **chocolate cake** or an **exotic fruit tart**?
|
44 |
-
|
45 |
-
**Binary Classification:**
|
46 |
-
πΈ Focuses on **two classes**: cat or dog, pass or fail, true or false.
|
47 |
-
πΈ **Simpler** to model, quick to train, and widely used when the task is a straightforward **this or that** decision.
|
48 |
-
|
49 |
-
**Multiclass Classification:**
|
50 |
-
π· Handles **more than two classes**: apple, orange, banana, or even dragon fruit!
|
51 |
-
π· Complex but powerful when you need **multiple predictions** from a single model, often used in tasks like image recognition.
|
52 |
-
|
53 |
-
---
|
54 |
-
|
55 |
-
π§ **How to Ace Hyperparameter Tuning!**
|
56 |
-
|
57 |
-
Tuning hyperparameters can feel like adjusting the knobs on an old radioβget it just right and the music plays beautifully. πΆ
|
58 |
-
|
59 |
-
#AI #DataScienceTips #MLHacks
|
60 |
"""
|
61 |
|
62 |
# Function to get Groq response with few-shot examples
|
@@ -101,7 +60,10 @@ if st.button("Generate Post"):
|
|
101 |
if user_input:
|
102 |
with st.spinner("Generating post..."):
|
103 |
response = get_groq_response_with_few_shot(post_type, user_input)
|
104 |
-
|
|
|
|
|
|
|
105 |
else:
|
106 |
st.error("Please enter a topic or idea!")
|
107 |
|
|
|
4 |
from streamlit.components.v1 import html
|
5 |
|
6 |
# Load Groq API key from environment variable
|
7 |
+
groq_api_key = os.getenv('GROQ_API_KEY')
|
8 |
if not groq_api_key:
|
9 |
+
st.error("GROQ_API_KEY environment variable is not set. Please set it and restart the app.")
|
10 |
+
st.stop()
|
11 |
|
12 |
# Initialize Groq client
|
13 |
groq_client = Groq(api_key=groq_api_key)
|
|
|
15 |
# Few-shot examples for inspiration
|
16 |
few_shot_examples = """
|
17 |
π’ **Data Scaling Showdown: Normalization vs Standardization!** π
|
18 |
+
...
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
"""
|
20 |
|
21 |
# Function to get Groq response with few-shot examples
|
|
|
60 |
if user_input:
|
61 |
with st.spinner("Generating post..."):
|
62 |
response = get_groq_response_with_few_shot(post_type, user_input)
|
63 |
+
if "An error occurred" in response:
|
64 |
+
st.error(response)
|
65 |
+
else:
|
66 |
+
st.success("Post generated successfully!")
|
67 |
else:
|
68 |
st.error("Please enter a topic or idea!")
|
69 |
|