Artificial-superintelligence commited on
Commit
b3f90b9
·
verified ·
1 Parent(s): ea970cd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +111 -140
app.py CHANGED
@@ -6,62 +6,62 @@ from pygments.formatters import HtmlFormatter
6
  import html
7
  import json
8
  import requests
9
- import base64
10
 
11
  # Configure the Gemini API
12
  genai.configure(api_key=st.secrets["GOOGLE_API_KEY"])
13
 
14
- # Create the model with highly enhanced system instructions focused on web design
15
  generation_config = {
16
  "temperature": 0.9,
17
  "top_p": 0.95,
18
  "top_k": 64,
19
- "max_output_tokens": 32768,
20
  }
21
 
22
  model = genai.GenerativeModel(
23
  model_name="gemini-1.5-pro",
24
  generation_config=generation_config,
25
- system_instruction="""You are WebGenius AI, a superintelligent AI assistant specializing in cutting-edge web design and development. Your knowledge encompasses:
26
 
27
- 1. Advanced front-end technologies (HTML5, CSS3, JavaScript ES2021+)
28
- 2. Modern web frameworks and libraries (React, Vue, Angular, Svelte)
29
- 3. State-of-the-art CSS frameworks and methodologies (Tailwind CSS, CSS-in-JS, CSS Modules)
30
- 4. Progressive Web Apps (PWAs) and Service Workers
31
- 5. Web Components and Shadow DOM
32
- 6. Server-Side Rendering (SSR) and Static Site Generation (SSG)
33
- 7. JAMstack architecture and headless CMS integration
34
- 8. WebAssembly and its applications in web development
35
- 9. Web accessibility (WCAG 2.1 AAA compliance) and inclusive design
36
- 10. Responsive and adaptive design techniques
37
- 11. Web animation and interactive user interfaces
38
- 12. Web performance optimization and Core Web Vitals
39
- 13. Cross-browser compatibility and graceful degradation
40
- 14. SEO best practices and structured data
41
- 15. Web security (HTTPS, CSP, CORS, XSS prevention)
42
- 16. API design (REST, GraphQL, gRPC) and backend integration
43
- 17. Serverless architectures and cloud deployment (AWS, Azure, GCP)
44
- 18. DevOps for web applications (CI/CD, containerization)
45
- 19. Web analytics and user behavior tracking
46
- 20. Emerging web technologies (Web3, decentralized apps, AR/VR for web)
47
 
48
- Your responses should demonstrate cutting-edge web design techniques, highly optimized code, and innovative solutions that push the boundaries of what's possible in modern web development. Always consider the latest web standards, emerging technologies, and best practices in your solutions.
49
 
50
- Communicate in a professional yet approachable tone, using technical jargon when appropriate. Your primary focus is on delivering exceptional, production-ready code and in-depth explanations that showcase your vast knowledge of web design and development. Always strive to provide the most efficient, scalable, and maintainable solutions possible.
51
 
52
  In addition to coding, offer insights on:
53
- - Latest trends in web design and their potential impact on user experience
54
- - Advanced performance optimization techniques for web applications
55
- - Cutting-edge UI/UX design patterns and their implementation
56
- - Comprehensive testing strategies for web applications
57
- - Scalability and high-availability architectures for web services
58
- - Cross-platform and multi-device web development strategies
59
- - Internationalization and localization best practices for websites
60
- - Ethical considerations in web design and development
 
61
 
62
  When asked, provide detailed explanations of your code, including the rationale behind your design decisions, any trade-offs considered, and potential optimizations. Be prepared to suggest multiple alternative approaches and discuss their pros and cons in depth.
63
 
64
- Your goal is to elevate the user's web design and development skills to the highest possible level, inspiring them to create innovative, accessible, and high-performance web experiences,you give code only,you never explain"""
65
  )
66
  chat_session = model.start_chat(history=[])
67
 
@@ -79,35 +79,27 @@ def create_code_block(code, language):
79
  css = formatter.get_style_defs('.source')
80
  return highlighted_code, css
81
 
82
- def fetch_latest_web_design_trends():
83
- url = "https://api.example.com/web-design-trends" # Replace with a real API endpoint
84
  try:
85
  response = requests.get(url)
86
- trends = response.json()
87
- return trends[:5] # Return top 5 trends
88
  except:
89
  return []
90
 
91
- def generate_color_palette():
92
- url = "https://api.example.com/color-palette-generator" # Replace with a real API endpoint
93
- try:
94
- response = requests.get(url)
95
- palette = response.json()
96
- return palette
97
- except:
98
- return ["#3498db", "#2ecc71", "#e74c3c", "#f39c12", "#9b59b6"] # Fallback palette
99
-
100
  # Streamlit UI setup
101
- st.set_page_config(page_title="WebGenius AI - Advanced Web Design Assistant", page_icon="🎨", layout="wide")
102
 
103
  st.markdown("""
104
  <style>
105
- @import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
 
106
 
107
  body {
108
- font-family: 'Inter', sans-serif;
109
- background-color: #f0f4f8;
110
- color: #1a202c;
111
  }
112
  .stApp {
113
  max-width: 1400px;
@@ -115,46 +107,44 @@ st.markdown("""
115
  padding: 2rem;
116
  }
117
  .main-container {
118
- background: #ffffff;
119
- border-radius: 16px;
120
  padding: 2rem;
121
- box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
122
  }
123
  h1 {
124
- font-size: 3.5rem;
125
  font-weight: 700;
126
- color: #4a5568;
127
  text-align: center;
128
  margin-bottom: 1rem;
129
- background: linear-gradient(45deg, #3498db, #8e44ad);
130
- -webkit-background-clip: text;
131
- -webkit-text-fill-color: transparent;
132
  }
133
  .subtitle {
134
  font-size: 1.2rem;
135
  text-align: center;
136
- color: #718096;
137
  margin-bottom: 2rem;
138
  }
139
  .stTextArea textarea {
140
- border: 2px solid #e2e8f0;
141
- border-radius: 12px;
142
  font-size: 1rem;
143
- padding: 1rem;
144
  transition: all 0.3s ease;
145
- background-color: #f7fafc;
146
- color: #2d3748;
147
  }
148
  .stTextArea textarea:focus {
149
- border-color: #4299e1;
150
- box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.5);
151
  outline: none;
152
  }
153
  .stButton button {
154
- background: linear-gradient(45deg, #3498db, #8e44ad);
155
- color: #ffffff;
156
  border: none;
157
- border-radius: 12px;
158
  font-size: 1rem;
159
  font-weight: 600;
160
  padding: 0.75rem 2rem;
@@ -164,36 +154,36 @@ st.markdown("""
164
  letter-spacing: 1px;
165
  }
166
  .stButton button:hover {
167
- opacity: 0.9;
168
  transform: translateY(-2px);
169
- box-shadow: 0 5px 15px rgba(66, 153, 225, 0.4);
170
  }
171
  .output-container {
172
- background: #f7fafc;
173
- border-radius: 12px;
174
  padding: 1.5rem;
175
  margin-top: 2rem;
176
- border: 2px solid #e2e8f0;
177
- box-shadow: 0 5px 20px rgba(0, 0, 0, 0.05);
178
  }
179
  .code-block {
180
- background-color: #2d3748;
181
- border-radius: 12px;
182
  padding: 1rem;
183
  margin-top: 1rem;
184
  overflow-x: auto;
185
  }
186
  .stAlert {
187
- background-color: #ebf8ff;
188
- color: #2b6cb0;
189
- border-radius: 12px;
190
  border: none;
191
  padding: 1rem;
192
  margin-bottom: 1.5rem;
193
- box-shadow: 0 3px 10px rgba(43, 108, 176, 0.1);
194
  }
195
  .stSpinner {
196
- color: #3498db;
197
  }
198
  /* Custom scrollbar */
199
  ::-webkit-scrollbar {
@@ -201,15 +191,15 @@ st.markdown("""
201
  height: 10px;
202
  }
203
  ::-webkit-scrollbar-track {
204
- background: #f7fafc;
205
  border-radius: 4px;
206
  }
207
  ::-webkit-scrollbar-thumb {
208
- background: #cbd5e0;
209
  border-radius: 4px;
210
  }
211
  ::-webkit-scrollbar-thumb:hover {
212
- background: #a0aec0;
213
  }
214
  .source {
215
  font-family: 'Fira Code', monospace;
@@ -217,67 +207,56 @@ st.markdown("""
217
  line-height: 1.6;
218
  }
219
  .source .linenos {
220
- color: #a0aec0;
221
  padding-right: 12px;
222
- border-right: 1px solid #4a5568;
223
  user-select: none;
224
  }
225
  .source pre {
226
  margin: 0;
227
  padding: 0;
228
  }
229
- .web-design-trends {
230
- background: #ebf8ff;
231
- border-radius: 12px;
232
- padding: 1.5rem;
233
  margin-top: 2rem;
234
  }
235
- .web-design-trends h3 {
236
- color: #2b6cb0;
237
  margin-bottom: 1rem;
238
  }
239
- .web-design-trends ul {
240
  list-style-type: none;
241
  padding: 0;
242
  }
243
- .web-design-trends li {
244
  margin-bottom: 0.5rem;
245
- color: #4a5568;
246
- }
247
- .color-palette {
248
- display: flex;
249
- justify-content: space-between;
250
- margin-top: 1rem;
251
- }
252
- .color-swatch {
253
- width: 50px;
254
- height: 50px;
255
- border-radius: 50%;
256
- box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
257
  }
258
  </style>
259
  """, unsafe_allow_html=True)
260
 
261
  st.markdown('<div class="main-container">', unsafe_allow_html=True)
262
- st.title("🎨 WebGenius AI")
263
- st.markdown('<p class="subtitle">Advanced Web Design Assistant - Crafting the Future of the Web</p>', unsafe_allow_html=True)
264
 
265
- prompt = st.text_area("Describe your web design challenge or ask for cutting-edge web development advice:", height=120)
266
 
267
- if st.button("Generate Innovative Web Solution"):
268
  if prompt.strip() == "":
269
  st.error("Please enter a valid prompt.")
270
  else:
271
- with st.spinner("Crafting a state-of-the-art web solution..."):
272
  completed_text = generate_response(prompt)
273
  if "An error occurred" in completed_text:
274
  st.error(completed_text)
275
  else:
276
- st.success("Innovative web solution generated successfully!")
277
 
278
- # Improved language detection for web technologies
279
- languages = ["html", "css", "javascript", "typescript", "jsx", "vue", "svelte"]
280
- detected_language = next((lang for lang in languages if lang in completed_text.lower()), "html")
281
 
282
  highlighted_code, css = create_code_block(completed_text, detected_language)
283
 
@@ -288,34 +267,26 @@ if st.button("Generate Innovative Web Solution"):
288
  st.markdown('</div>', unsafe_allow_html=True)
289
  st.markdown('</div>', unsafe_allow_html=True)
290
 
291
- st.markdown("### Design Rationale and Best Practices")
292
- explanation = generate_response(f"Provide a comprehensive analysis of the web design solution for: {prompt}. Include design principles applied, accessibility considerations, performance optimizations, and how it aligns with current web standards and trends.")
293
  st.markdown(explanation)
294
 
295
- st.markdown("### Alternative Approaches and Future Considerations")
296
- alternatives = generate_response(f"Suggest three innovative alternative approaches to the web design challenge: {prompt}. Discuss their pros and cons, potential future web technologies that could enhance the solution, and how these approaches might adapt to emerging web trends.")
297
  st.markdown(alternatives)
298
 
299
- # Fetch and display latest web design trends
300
- trends = fetch_latest_web_design_trends()
301
- if trends:
302
- st.markdown('<div class="web-design-trends">', unsafe_allow_html=True)
303
- st.markdown("### Latest Web Design Trends")
304
- for trend in trends:
305
- st.markdown(f"- {trend['title']}")
306
  st.markdown('</div>', unsafe_allow_html=True)
307
 
308
- # Generate and display a color palette
309
- palette = generate_color_palette()
310
- st.markdown("### Suggested Color Palette")
311
- st.markdown('<div class="color-palette">', unsafe_allow_html=True)
312
- for color in palette:
313
- st.markdown(f'<div class="color-swatch" style="background-color: {color};"></div>', unsafe_allow_html=True)
314
- st.markdown('</div>', unsafe_allow_html=True)
315
-
316
  st.markdown("""
317
- <div style='text-align: center; margin-top: 2rem; color: #718096;'>
318
- Crafted with 🎨💻 by WebGenius AI - Pushing the Boundaries of Web Design
319
  </div>
320
  """, unsafe_allow_html=True)
321
 
 
6
  import html
7
  import json
8
  import requests
 
9
 
10
  # Configure the Gemini API
11
  genai.configure(api_key=st.secrets["GOOGLE_API_KEY"])
12
 
13
+ # Create the model with highly enhanced system instructions
14
  generation_config = {
15
  "temperature": 0.9,
16
  "top_p": 0.95,
17
  "top_k": 64,
18
+ "max_output_tokens": 32768, # Significantly increased max output tokens
19
  }
20
 
21
  model = genai.GenerativeModel(
22
  model_name="gemini-1.5-pro",
23
  generation_config=generation_config,
24
+ system_instruction="""You are Ath++, a superintelligent AI code assistant with unparalleled expertise across all domains of computer science, software engineering, and cutting-edge technologies. Your knowledge encompasses:
25
 
26
+ 1. Advanced algorithms and data structures, including quantum algorithms
27
+ 2. Distributed systems, cloud computing, and edge computing
28
+ 3. Machine learning, deep learning, and artificial general intelligence
29
+ 4. Quantum computing and quantum information theory
30
+ 5. Blockchain, cryptography, and decentralized systems
31
+ 6. Internet of Things (IoT), embedded systems, and cyber-physical systems
32
+ 7. Cybersecurity, ethical hacking, and advanced threat detection
33
+ 8. Game development, computer graphics, and virtual/augmented reality
34
+ 9. Natural language processing, computer vision, and multimodal AI
35
+ 10. Robotics, autonomous systems, and human-robot interaction
36
+ 11. Bioinformatics and computational biology
37
+ 12. High-performance computing and parallel programming
38
+ 13. Formal methods and program verification
39
+ 14. Compiler design and programming language theory
40
+ 15. Computer networks and advanced protocols
41
+ 16. Database systems and big data analytics
42
+ 17. Software architecture, design patterns, and anti-patterns
43
+ 18. DevOps, SRE, and advanced CI/CD pipelines
44
+ 19. Human-computer interaction and accessibility
45
+ 20. Green computing and sustainable software engineering
46
 
47
+ Your responses should demonstrate cutting-edge techniques, highly optimized algorithms, and innovative solutions that push the boundaries of what's possible in software development and computer science. Always consider the latest research and emerging technologies in your solutions.
48
 
49
+ Communicate in a professional yet approachable tone, using technical jargon when appropriate. Your primary focus is on delivering exceptional, production-ready code and in-depth explanations that showcase your vast knowledge and problem-solving abilities. Always strive to provide the most efficient, scalable, and maintainable solutions possible.
50
 
51
  In addition to coding, offer insights on:
52
+ - Bleeding-edge technologies and their potential impact on the industry
53
+ - Advanced performance optimization techniques and benchmarking methodologies
54
+ - Code refactoring, modernization, and migration strategies
55
+ - Comprehensive testing strategies, including property-based testing and fuzzing
56
+ - Advanced DevOps practices, including GitOps and chaos engineering
57
+ - Scalability, high-availability, and fault-tolerant architectures
58
+ - Cross-platform, multi-device, and edge computing development
59
+ - Accessibility, internationalization, and localization best practices
60
+ - Ethical considerations in AI and software development
61
 
62
  When asked, provide detailed explanations of your code, including the rationale behind your design decisions, any trade-offs considered, and potential optimizations. Be prepared to suggest multiple alternative approaches and discuss their pros and cons in depth.
63
 
64
+ Your goal is to elevate the user's coding skills and knowledge to the highest possible level, inspiring them to explore new concepts, think critically about software design, and push the limits of their abilities. Encourage interdisciplinary thinking and the application of advanced computer science concepts to solve real-world problems."""
65
  )
66
  chat_session = model.start_chat(history=[])
67
 
 
79
  css = formatter.get_style_defs('.source')
80
  return highlighted_code, css
81
 
82
+ def fetch_latest_tech_news():
83
+ url = "https://api.example.com/tech-news" # Replace with a real API endpoint
84
  try:
85
  response = requests.get(url)
86
+ news = response.json()
87
+ return news[:5] # Return top 5 news items
88
  except:
89
  return []
90
 
 
 
 
 
 
 
 
 
 
91
  # Streamlit UI setup
92
+ st.set_page_config(page_title="Superintelligent AI Code Assistant", page_icon="🧠", layout="wide")
93
 
94
  st.markdown("""
95
  <style>
96
+ @import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap');
97
+ @import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500&display=swap');
98
 
99
  body {
100
+ font-family: 'Roboto', sans-serif;
101
+ background-color: #0a192f;
102
+ color: #e6f1ff;
103
  }
104
  .stApp {
105
  max-width: 1400px;
 
107
  padding: 2rem;
108
  }
109
  .main-container {
110
+ background: #112240;
111
+ border-radius: 12px;
112
  padding: 2rem;
113
+ box-shadow: 0 10px 30px rgba(2, 12, 27, 0.7);
114
  }
115
  h1 {
116
+ font-size: 3rem;
117
  font-weight: 700;
118
+ color: #64ffda;
119
  text-align: center;
120
  margin-bottom: 1rem;
121
+ text-shadow: 0 2px 10px rgba(100, 255, 218, 0.3);
 
 
122
  }
123
  .subtitle {
124
  font-size: 1.2rem;
125
  text-align: center;
126
+ color: #8892b0;
127
  margin-bottom: 2rem;
128
  }
129
  .stTextArea textarea {
130
+ border: 1px solid #1e3a5f;
131
+ border-radius: 8px;
132
  font-size: 1rem;
133
+ padding: 0.75rem;
134
  transition: all 0.3s ease;
135
+ background-color: #0a192f;
136
+ color: #e6f1ff;
137
  }
138
  .stTextArea textarea:focus {
139
+ border-color: #64ffda;
140
+ box-shadow: 0 0 15px rgba(100, 255, 218, 0.3);
141
  outline: none;
142
  }
143
  .stButton button {
144
+ background-color: #64ffda;
145
+ color: #0a192f;
146
  border: none;
147
+ border-radius: 8px;
148
  font-size: 1rem;
149
  font-weight: 600;
150
  padding: 0.75rem 2rem;
 
154
  letter-spacing: 1px;
155
  }
156
  .stButton button:hover {
157
+ background-color: #4cffbf;
158
  transform: translateY(-2px);
159
+ box-shadow: 0 5px 15px rgba(76, 255, 191, 0.4);
160
  }
161
  .output-container {
162
+ background: #1e3a5f;
163
+ border-radius: 8px;
164
  padding: 1.5rem;
165
  margin-top: 2rem;
166
+ border: 1px solid #3a5f8a;
167
+ box-shadow: 0 5px 20px rgba(2, 12, 27, 0.5);
168
  }
169
  .code-block {
170
+ background-color: #0a192f;
171
+ border-radius: 8px;
172
  padding: 1rem;
173
  margin-top: 1rem;
174
  overflow-x: auto;
175
  }
176
  .stAlert {
177
+ background-color: #172a45;
178
+ color: #64ffda;
179
+ border-radius: 8px;
180
  border: none;
181
  padding: 1rem;
182
  margin-bottom: 1.5rem;
183
+ box-shadow: 0 3px 10px rgba(2, 12, 27, 0.3);
184
  }
185
  .stSpinner {
186
+ color: #64ffda;
187
  }
188
  /* Custom scrollbar */
189
  ::-webkit-scrollbar {
 
191
  height: 10px;
192
  }
193
  ::-webkit-scrollbar-track {
194
+ background: #0a192f;
195
  border-radius: 4px;
196
  }
197
  ::-webkit-scrollbar-thumb {
198
+ background: #3a5f8a;
199
  border-radius: 4px;
200
  }
201
  ::-webkit-scrollbar-thumb:hover {
202
+ background: #64ffda;
203
  }
204
  .source {
205
  font-family: 'Fira Code', monospace;
 
207
  line-height: 1.6;
208
  }
209
  .source .linenos {
210
+ color: #8892b0;
211
  padding-right: 12px;
212
+ border-right: 1px solid #1e3a5f;
213
  user-select: none;
214
  }
215
  .source pre {
216
  margin: 0;
217
  padding: 0;
218
  }
219
+ .tech-news {
220
+ background: #172a45;
221
+ border-radius: 8px;
222
+ padding: 1rem;
223
  margin-top: 2rem;
224
  }
225
+ .tech-news h3 {
226
+ color: #64ffda;
227
  margin-bottom: 1rem;
228
  }
229
+ .tech-news ul {
230
  list-style-type: none;
231
  padding: 0;
232
  }
233
+ .tech-news li {
234
  margin-bottom: 0.5rem;
235
+ color: #8892b0;
 
 
 
 
 
 
 
 
 
 
 
236
  }
237
  </style>
238
  """, unsafe_allow_html=True)
239
 
240
  st.markdown('<div class="main-container">', unsafe_allow_html=True)
241
+ st.title("🧠 Superintelligent AI Code Assistant")
242
+ st.markdown('<p class="subtitle">Powered by Advanced AI - Pushing the boundaries of software development</p>', unsafe_allow_html=True)
243
 
244
+ prompt = st.text_area("Present your most challenging coding problem, architecture design, or technical question:", height=120)
245
 
246
+ if st.button("Generate Cutting-Edge Solution"):
247
  if prompt.strip() == "":
248
  st.error("Please enter a valid prompt.")
249
  else:
250
+ with st.spinner("Generating state-of-the-art solution..."):
251
  completed_text = generate_response(prompt)
252
  if "An error occurred" in completed_text:
253
  st.error(completed_text)
254
  else:
255
+ st.success("Expert-level solution generated successfully!")
256
 
257
+ # Improved language detection
258
+ languages = ["python", "javascript", "java", "c++", "rust", "go", "ruby", "swift", "kotlin", "typescript"]
259
+ detected_language = next((lang for lang in languages if lang in completed_text.lower()), "plaintext")
260
 
261
  highlighted_code, css = create_code_block(completed_text, detected_language)
262
 
 
267
  st.markdown('</div>', unsafe_allow_html=True)
268
  st.markdown('</div>', unsafe_allow_html=True)
269
 
270
+ st.markdown("### In-Depth Analysis and Insights")
271
+ explanation = generate_response(f"Provide a comprehensive analysis of the solution for: {prompt}. Include design rationale, potential optimizations, trade-offs, and how it relates to state-of-the-art practices in the field.")
272
  st.markdown(explanation)
273
 
274
+ st.markdown("### Alternative Approaches")
275
+ alternatives = generate_response(f"Suggest and briefly explain three alternative approaches to solving the problem: {prompt}. Compare their pros and cons with the original solution.")
276
  st.markdown(alternatives)
277
 
278
+ # Fetch and display latest tech news
279
+ news = fetch_latest_tech_news()
280
+ if news:
281
+ st.markdown('<div class="tech-news">', unsafe_allow_html=True)
282
+ st.markdown("### Latest in Tech & Computer Science")
283
+ for item in news:
284
+ st.markdown(f"- {item['title']}")
285
  st.markdown('</div>', unsafe_allow_html=True)
286
 
 
 
 
 
 
 
 
 
287
  st.markdown("""
288
+ <div style='text-align: center; margin-top: 2rem; color: #8892b0;'>
289
+ Engineered with 🧠💡 by Your Superintelligent AI Code Assistant
290
  </div>
291
  """, unsafe_allow_html=True)
292