Waseem7711 commited on
Commit
24bd156
·
verified ·
1 Parent(s): 234bec3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -7
app.py CHANGED
@@ -3,9 +3,14 @@ from fpdf import FPDF
3
  from groq import Groq
4
  import os
5
 
6
- # Set the Groq API key from Hugging Face Secrets (ensure to add it in your Space's settings)
7
- api_key = os.getenv("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
8
- ")
 
 
 
 
 
9
  client = Groq(api_key=api_key)
10
 
11
  # Function to generate a timetable
@@ -55,12 +60,16 @@ st.title("Class Timetable Generator")
55
  st.write("Generate and manage class schedules effortlessly.")
56
 
57
  # Input fields
58
- teachers = st.text_input("Enter the names of teachers (comma-separated)").split(",")
59
- subjects = st.text_input("Enter the subjects (comma-separated)").split(",")
60
- slots = st.text_input("Enter the available slots (comma-separated)").split(",")
61
 
62
  if st.button("Generate Timetable"):
63
- if teachers and subjects and slots:
 
 
 
 
64
  st.info("Generating timetable...")
65
  timetable = generate_timetable(teachers, subjects, slots)
66
 
 
3
  from groq import Groq
4
  import os
5
 
6
+ # Retrieve the API key securely
7
+ # Ensure the "GROQ_API_KEY" is added in Hugging Face Secrets or as an environment variable
8
+ api_key = os.getenv("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")
9
+ if not api_key:
10
+ st.error("API Key not found. Please set the GROQ_API_KEY environment variable in your Space settings.")
11
+ st.stop()
12
+
13
+ # Initialize the Groq client
14
  client = Groq(api_key=api_key)
15
 
16
  # Function to generate a timetable
 
60
  st.write("Generate and manage class schedules effortlessly.")
61
 
62
  # Input fields
63
+ teachers_input = st.text_input("Enter the names of teachers (comma-separated)")
64
+ subjects_input = st.text_input("Enter the subjects (comma-separated)")
65
+ slots_input = st.text_input("Enter the available slots (comma-separated)")
66
 
67
  if st.button("Generate Timetable"):
68
+ if teachers_input and subjects_input and slots_input:
69
+ teachers = [t.strip() for t in teachers_input.split(",")]
70
+ subjects = [s.strip() for s in subjects_input.split(",")]
71
+ slots = [s.strip() for s in slots_input.split(",")]
72
+
73
  st.info("Generating timetable...")
74
  timetable = generate_timetable(teachers, subjects, slots)
75