ibrahim313 commited on
Commit
1630005
β€’
1 Parent(s): f85b832

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -46
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('api_key')
8
  if not groq_api_key:
9
- raise ValueError("GROQ_API_KEY environment variable is not set.")
 
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
- st.success("Post generated successfully!")
 
 
 
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