sunbal7 commited on
Commit
a9f0287
ยท
verified ยท
1 Parent(s): 78dd0c7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +217 -52
app.py CHANGED
@@ -1,62 +1,227 @@
1
  # app.py
2
-
3
  import streamlit as st
 
 
 
 
4
 
5
- # Title of the App
6
- st.title("PAK ANGELS - ULEFUSA Gen AI Training Certificate Checker ๐Ÿ†")
7
-
8
- # Explanation of Criteria
9
- st.write("""
10
- ### Qualification Criteria:
11
- To qualify for the **Gen AI Training Success Certificate**, you must achieve a minimum of **50%** overall score.
12
- Your final score is calculated with the following weightage:
13
- - **Quiz 1:** 5%
14
- - **Quiz 2:** 5%
15
- - **Quiz 3:** 10%
16
- - **Quiz 4:** 15%
17
- - **Quiz 5:** 15%
18
- - **Grand Quiz (Final Exam):** 50%
19
-
20
- Enter your scores below to check if you qualify!
21
- """)
22
 
23
- # Input fields for quiz scores (out of 60)
24
- quiz1 = st.number_input("Enter Quiz 1 Score (out of 60):", min_value=0, max_value=60, step=1)
25
- quiz2 = st.number_input("Enter Quiz 2 Score (out of 60):", min_value=0, max_value=60, step=1)
26
- quiz3 = st.number_input("Enter Quiz 3 Score (out of 60):", min_value=0, max_value=60, step=1)
27
- quiz4 = st.number_input("Enter Quiz 4 Score (out of 60):", min_value=0, max_value=60, step=1)
28
- quiz5 = st.number_input("Enter Quiz 5 Score (out of 60):", min_value=0, max_value=60, step=1)
29
- grand_quiz = st.number_input("Enter Grand Quiz (Final Exam) Score (out of 60):", min_value=0, max_value=60, step=1)
30
-
31
- # Calculate Final Weighted Score
32
- if st.button("Check Qualification"):
33
- # Convert scores out of 60 to percentage
34
- weighted_score = (
35
- (quiz1 / 60) * 5 +
36
- (quiz2 / 60) * 5 +
37
- (quiz3 / 60) * 10 +
38
- (quiz4 / 60) * 15 +
39
- (quiz5 / 60) * 15 +
40
- (grand_quiz / 60) * 50
41
- )
42
 
43
- st.subheader("Your Results ๐Ÿ“Š")
44
- st.write(f"**Final Weighted Score:** {weighted_score:.2f}%")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
 
46
- # Qualification Criteria
47
- if weighted_score >= 50:
48
- st.success("โœ… Congratulations! You qualify for the **Gen AI Training Success Certificate** ๐ŸŽ‰")
 
49
 
50
- # Performance Categories
51
- if weighted_score >= 80:
52
- st.write("๐Ÿ† **Top Performer:** 80% or higher")
53
- elif weighted_score >= 65:
54
- st.write("โญ **Skilled Performer:** 65% or higher")
55
- else:
56
- st.write("๐Ÿ”ฐ **Promising Performer:** 50% or higher")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
  else:
59
- st.error("โŒ Unfortunately, you did not qualify for the certificate. Keep practicing and try again!")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
 
61
- # Final message
62
- st.write("\n\nI made this tool with โค๏ธ")
 
 
 
 
 
 
 
 
 
1
  # app.py
 
2
  import streamlit as st
3
+ import requests
4
+ import time
5
+ import os
6
+ from dotenv import load_dotenv
7
 
8
+ # Load environment variables
9
+ load_dotenv()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
 
11
+ # Set up the page
12
+ st.set_page_config(
13
+ page_title="CodeTales โœจ",
14
+ page_icon="๐Ÿš€",
15
+ layout="wide",
16
+ initial_sidebar_state="expanded"
17
+ )
 
 
 
 
 
 
 
 
 
 
 
 
18
 
19
+ # Custom CSS
20
+ st.markdown("""
21
+ <style>
22
+ @import url('https://fonts.googleapis.com/css2?family=Comic+Neue:wght@700&display=swap');
23
+
24
+ .stApp {
25
+ background: linear-gradient(135deg, #6e8efb, #a777e3);
26
+ }
27
+
28
+ .header {
29
+ font-family: 'Comic Neue', cursive;
30
+ color: white;
31
+ text-align: center;
32
+ font-size: 3.5rem;
33
+ text-shadow: 3px 3px 0 #000;
34
+ padding: 1rem;
35
+ }
36
+
37
+ .subheader {
38
+ font-family: 'Comic Neue', cursive;
39
+ color: #ffeb3b;
40
+ text-align: center;
41
+ font-size: 1.8rem;
42
+ margin-bottom: 2rem;
43
+ }
44
+
45
+ .story-box {
46
+ background-color: rgba(255, 255, 255, 0.9);
47
+ border-radius: 20px;
48
+ padding: 2rem;
49
+ box-shadow: 0 8px 16px rgba(0,0,0,0.2);
50
+ margin-bottom: 2rem;
51
+ }
52
+
53
+ .robot-speech {
54
+ background-color: #4caf50;
55
+ color: white;
56
+ border-radius: 20px;
57
+ padding: 1.5rem;
58
+ font-size: 1.2rem;
59
+ position: relative;
60
+ margin-top: 2rem;
61
+ }
62
+
63
+ .robot-speech:after {
64
+ content: '';
65
+ position: absolute;
66
+ top: -20px;
67
+ left: 50px;
68
+ border: 10px solid transparent;
69
+ border-bottom-color: #4caf50;
70
+ }
71
+
72
+ .generate-btn {
73
+ background: #ff5722 !important;
74
+ color: white !important;
75
+ font-weight: bold !important;
76
+ font-size: 1.2rem !important;
77
+ padding: 0.7rem 2rem !important;
78
+ border-radius: 50px !important;
79
+ border: none !important;
80
+ box-shadow: 0 4px 8px rgba(0,0,0,0.3) !important;
81
+ transition: all 0.3s !important;
82
+ margin-top: 1rem;
83
+ }
84
+
85
+ .generate-btn:hover {
86
+ transform: scale(1.05) !important;
87
+ box-shadow: 0 6px 12px rgba(0,0,0,0.4) !important;
88
+ }
89
+
90
+ .code-block {
91
+ background: #2d2d2d;
92
+ color: #f8f8f2;
93
+ padding: 1rem;
94
+ border-radius: 10px;
95
+ font-family: monospace;
96
+ font-size: 1.1rem;
97
+ margin: 1rem 0;
98
+ overflow-x: auto;
99
+ }
100
+ </style>
101
+ """, unsafe_allow_html=True)
102
 
103
+ # Header section
104
+ st.markdown('<div class="header">CodeTales โœจ</div>', unsafe_allow_html=True)
105
+ st.markdown('<div class="subheader">Storytime + Coding Magic</div>', unsafe_allow_html=True)
106
+ st.markdown('<div style="text-align:center; color:white; font-size:1.2rem; margin-bottom:2rem;">Turn wild stories into playable games with AI magic!</div>', unsafe_allow_html=True)
107
 
108
+ # How it works section
109
+ with st.expander("โœจ How It Works (Like Baking a Cake) ๐ŸŽ‚"):
110
+ st.markdown("""
111
+ **1. Kids Write a Story (The Recipe)**
112
+ Example: *"The spaceship zooms past aliens and shoots lasers!"*
113
+
114
+ **2. AI is the Magic Oven ๐Ÿ”ฎ**
115
+ We turn words into code (like translating English to Computer)
116
+
117
+ **3. Animation Pops Out (The Cake!) ๐ŸŽฎ**
118
+ See your spaceship flying and shooting instantly!
119
+
120
+ **4. Robot Teacher Explains ๐Ÿค–**
121
+ Tavus shows: *"See? 'spaceship.move_right()' makes it fly! That's coding!"*
122
+ """)
123
+
124
+ # Main content
125
+ col1, col2 = st.columns([1, 1])
126
+
127
+ with col1:
128
+ st.markdown('<div class="story-box">', unsafe_allow_html=True)
129
+ st.markdown("### ๐Ÿ“– Write Your Story Here:")
130
+ story_text = st.text_area(
131
+ "Tell your adventure story...",
132
+ height=200,
133
+ placeholder="Once upon a time, a brave spaceship zoomed through space, shooting lasers at alien spaceships...",
134
+ label_visibility="collapsed"
135
+ )
136
+
137
+ # Generate button with animation
138
+ if st.button("โœจ Generate Animation!", use_container_width=True, key="generate", type="primary"):
139
+ st.session_state.generate_clicked = True
140
+ st.markdown('</div>', unsafe_allow_html=True)
141
 
142
+ with col2:
143
+ st.markdown('<div class="story-box">', unsafe_allow_html=True)
144
+ st.markdown("### ๐ŸŽฎ Your Game Animation")
145
+
146
+ if 'generate_clicked' in st.session_state and story_text:
147
+ with st.spinner("๐Ÿง™โ€โ™‚๏ธ Cooking your story in the magic oven..."):
148
+ # Simulate processing time
149
+ time.sleep(3)
150
+
151
+ # Generate animation (would use actual API call in production)
152
+ st.session_state.animation_generated = True
153
+ st.session_state.story_text = story_text
154
+
155
+ # Display animation placeholder
156
+ st.video("https://cdn.pixabay.com/video/2023/01/20/155564-810349295_large.mp4")
157
+
158
+ st.success("๐ŸŽ‰ Your animation is ready! Tavus will explain the magic now!")
159
+ elif 'animation_generated' in st.session_state:
160
+ st.video("https://cdn.pixabay.com/video/2023/01/20/155564-810349295_large.mp4")
161
  else:
162
+ st.image("https://img.freepik.com/free-vector/hand-drawn-colorful-space-background_23-2148821798.jpg", use_column_width=True)
163
+ st.info("๐Ÿ‘† Write your story and click Generate to see the magic!")
164
+
165
+ st.markdown('</div>', unsafe_allow_html=True)
166
+
167
+ # Tavus explanation section
168
+ if 'animation_generated' in st.session_state and 'story_text' in st.session_state:
169
+ st.markdown('<div class="robot-speech">', unsafe_allow_html=True)
170
+ st.markdown("### ๐Ÿค– Tavus the Robot Teacher says:")
171
+
172
+ # Extract action words from story
173
+ action_words = ["zoom", "shoot", "fly", "move", "jump", "run", "attack"]
174
+ found_actions = [word for word in action_words if word in st.session_state.story_text.lower()]
175
+
176
+ if found_actions:
177
+ action = found_actions[0]
178
+ explanation = {
179
+ "zoom": "makes your spaceship move super fast!",
180
+ "shoot": "creates laser beams to defeat enemies!",
181
+ "fly": "keeps your character moving through the air!",
182
+ "move": "changes position on the screen!",
183
+ "jump": "makes your character leap upwards!",
184
+ "run": "makes your character move faster!",
185
+ "attack": "lets your hero fight the bad guys!"
186
+ }
187
+
188
+ code_snippet = {
189
+ "zoom": "spaceship.accelerate(speed=10)",
190
+ "shoot": "laser = spaceship.fire_weapon()",
191
+ "fly": "character.apply_gravity(False)",
192
+ "move": "player.move(direction='right')",
193
+ "jump": "hero.jump(height=100)",
194
+ "run": "player.speed = player.speed * 2",
195
+ "attack": "sword.swing(damage=15)"
196
+ }
197
+
198
+ st.markdown(f"See how your story became real code? When you said **'{action}'**, we used:")
199
+ st.markdown(f'<div class="code-block">{code_snippet[action]}</div>', unsafe_allow_html=True)
200
+ st.markdown(f"This code {explanation[action]} That's the magic of coding - turning words into actions!")
201
+ else:
202
+ st.markdown("I see you created an awesome story! Every word you write can become game code. Try adding action words like 'jump', 'run', or 'shoot' next time!")
203
+
204
+ st.markdown("</div>", unsafe_allow_html=True)
205
+
206
+ # Benefits section
207
+ st.markdown("""
208
+ ## โค Why Everyone Will Love CodeTales
209
+
210
+ | For Kids ๐Ÿ‘ง๐Ÿ‘ฆ | For Parents & Teachers ๐Ÿ‘ช๐Ÿ‘ฉโ€๐Ÿซ |
211
+ |--------------|----------------------------|
212
+ | โœจ Feels like playing, not learning | ๐Ÿง  Secretly teaches programming concepts |
213
+ | ๐Ÿš€ Brings imagination to life | ๐Ÿ” Develops logical thinking skills |
214
+ | ๐ŸŽฎ Creates personal video games | โž— Reinforces math fundamentals |
215
+ | ๐Ÿ˜„ Makes learning fun and exciting | ๐Ÿงฉ Encourages problem-solving abilities |
216
+ """)
217
 
218
+ # Footer
219
+ st.markdown("---")
220
+ st.markdown("""
221
+ <center>
222
+ <p style="color:white; font-size:1.1rem;">
223
+ โœจ Made with magic by CodeTales Team โœจ<br>
224
+ Transforming stories into games since 2023
225
+ </p>
226
+ </center>
227
+ """, unsafe_allow_html=True)