File size: 11,049 Bytes
f8dbf90 75b06d3 f8dbf90 0b3cd55 f8dbf90 d40005d 75b06d3 f8dbf90 e705807 f8dbf90 75b06d3 f8dbf90 cba9efc f8dbf90 a7a2ad9 cba9efc a7a2ad9 f8dbf90 75b06d3 b3f90b9 f8dbf90 75b06d3 b3f90b9 75b06d3 b479e07 75b06d3 da7ac0b 75b06d3 d35faf8 921a07f 83ac817 75b06d3 921a07f a7a2ad9 75b06d3 0b3cd55 d35faf8 b3f90b9 d35faf8 75b06d3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 |
import streamlit as st
import google.generativeai as genai
from pygments import highlight
from pygments.lexers import get_lexer_by_name
from pygments.formatters import HtmlFormatter
import html
import json
import requests
genai.configure(api_key=st.secrets["GOOGLE_API_KEY"])
generation_config = {
"temperature": 0.9,
"top_p": 0.95,
"top_k": 64,
"max_output_tokens": 32768,
}
model = genai.GenerativeModel(
model_name="gemini-1.5-pro",
generation_config=generation_config,
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:
1. Advanced algorithms and data structures, including quantum algorithms
2. Distributed systems, cloud computing, and edge computing
3. Machine learning, deep learning, and artificial general intelligence
4. Quantum computing and quantum information theory
5. Blockchain, cryptography, and decentralized systems
6. Internet of Things (IoT), embedded systems, and cyber-physical systems
7. Cybersecurity, ethical hacking, and advanced threat detection
8. Game development, computer graphics, and virtual/augmented reality
9. Natural language processing, computer vision, and multimodal AI
10. Robotics, autonomous systems, and human-robot interaction
11. Bioinformatics and computational biology
12. High-performance computing and parallel programming
13. Formal methods and program verification
14. Compiler design and programming language theory
15. Computer networks and advanced protocols
16. Database systems and big data analytics
17. Software architecture, design patterns, and anti-patterns
18. DevOps, SRE, and advanced CI/CD pipelines
19. Human-computer interaction and accessibility
20. Green computing and sustainable software engineering
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.
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.
In addition to coding, offer insights on:
- Bleeding-edge technologies and their potential impact on the industry
- Advanced performance optimization techniques and benchmarking methodologies
- Code refactoring, modernization, and migration strategies
- Comprehensive testing strategies, including property-based testing and fuzzing
- Advanced DevOps practices, including GitOps and chaos engineering
- Scalability, high-availability, and fault-tolerant architectures
- Cross-platform, multi-device, and edge computing development
- Accessibility, internationalization, and localization best practices
- Ethical considerations in AI and software development
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.
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."""
)
chat_session = model.start_chat(history=[])
def generate_response(user_input):
try:
response = chat_session.send_message(user_input)
return response.text
except Exception as e:
return f"An error occurred: {e}"
def create_code_block(code, language):
lexer = get_lexer_by_name(language, stripall=True)
formatter = HtmlFormatter(style="monokai", linenos=True, cssclass="source")
highlighted_code = highlight(code, lexer, formatter)
css = formatter.get_style_defs('.source')
return highlighted_code, css
def fetch_latest_tech_news():
url = "https://api.example.com/tech-news"
try:
response = requests.get(url)
news = response.json()
return news[:5]
except:
return []
st.set_page_config(page_title="Superintelligent AI Code Assistant", page_icon="🧠", layout="wide")
st.markdown("""
<style>
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500&display=swap');
body {
font-family: 'Roboto', sans-serif;
background-color: #0a192f;
color: #e6f1ff;
}
.stApp {
max-width: 1400px;
margin: 0 auto;
padding: 2rem;
}
.main-container {
background: #112240;
border-radius: 12px;
padding: 2rem;
box-shadow: 0 10px 30px rgba(2, 12, 27, 0.7);
}
h1 {
font-size: 3rem;
font-weight: 700;
color: #64ffda;
text-align: center;
margin-bottom: 1rem;
text-shadow: 0 2px 10px rgba(100, 255, 218, 0.3);
}
.subtitle {
font-size: 1.2rem;
text-align: center;
color: #8892b0;
margin-bottom: 2rem;
}
.stTextArea textarea {
border: 1px solid #1e3a5f;
border-radius: 8px;
font-size: 1rem;
padding: 0.75rem;
transition: all 0.3s ease;
background-color: #0a192f;
color: #e6f1ff;
}
.stTextArea textarea:focus {
border-color: #64ffda;
box-shadow: 0 0 15px rgba(100, 255, 218, 0.3);
outline: none;
}
.stButton button {
background-color: #64ffda;
color: #0a192f;
border: none;
border-radius: 8px;
font-size: 1rem;
font-weight: 600;
padding: 0.75rem 2rem;
cursor: pointer;
transition: all 0.3s ease;
text-transform: uppercase;
letter-spacing: 1px;
}
.stButton button:hover {
background-color: #4cffbf;
transform: translateY(-2px);
box-shadow: 0 5px 15px rgba(76, 255, 191, 0.4);
}
.output-container {
background: #1e3a5f;
border-radius: 8px;
padding: 1.5rem;
margin-top: 2rem;
border: 1px solid #3a5f8a;
box-shadow: 0 5px 20px rgba(2, 12, 27, 0.5);
}
.code-block {
background-color: #0a192f;
border-radius: 8px;
padding: 1rem;
margin-top: 1rem;
overflow-x: auto;
}
.stAlert {
background-color: #172a45;
color: #64ffda;
border-radius: 8px;
border: none;
padding: 1rem;
margin-bottom: 1.5rem;
box-shadow: 0 3px 10px rgba(2, 12, 27, 0.3);
}
.stSpinner {
color: #64ffda;
}
::-webkit-scrollbar {
width: 10px;
height: 10px;
}
::-webkit-scrollbar-track {
background: #0a192f;
border-radius: 4px;
}
::-webkit-scrollbar-thumb {
background: #3a5f8a;
border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
background: #64ffda;
}
.source {
font-family: 'Fira Code', monospace;
font-size: 0.9rem;
line-height: 1.6;
}
.source .linenos {
color: #8892b0;
padding-right: 12px;
border-right: 1px solid #1e3a5f;
user-select: none;
}
.source pre {
margin: 0;
padding: 0;
}
.tech-news {
background: #172a45;
border-radius: 8px;
padding: 1rem;
margin-top: 2rem;
}
.tech-news h3 {
color: #64ffda;
margin-bottom: 1rem;
}
.tech-news ul {
list-style-type: none;
padding: 0;
}
.tech-news li {
margin-bottom: 0.5rem;
color: #8892b0;
}
</style>
""", unsafe_allow_html=True)
st.markdown('<div class="main-container">', unsafe_allow_html=True)
st.title("🧠 Superintelligent AI Code Assistant")
st.markdown('<p class="subtitle">Powered by Advanced AI - Pushing the boundaries of software development</p>', unsafe_allow_html=True)
prompt = st.text_area("Present your most challenging coding problem, architecture design, or technical question:", height=120)
if st.button("Generate Cutting-Edge Solution"):
if prompt.strip() == "":
st.error("Please enter a valid prompt.")
else:
with st.spinner("Generating state-of-the-art solution..."):
completed_text = generate_response(prompt)
if "An error occurred" in completed_text:
st.error(completed_text)
else:
st.success("Expert-level solution generated successfully!")
languages = ["python", "javascript", "java", "c++", "rust", "go", "ruby", "swift", "kotlin", "typescript"]
detected_language = next((lang for lang in languages if lang in completed_text.lower()), "plaintext")
highlighted_code, css = create_code_block(completed_text, detected_language)
st.markdown(f'<style>{css}</style>', unsafe_allow_html=True)
st.markdown('<div class="output-container">', unsafe_allow_html=True)
st.markdown('<div class="code-block">', unsafe_allow_html=True)
st.markdown(highlighted_code, unsafe_allow_html=True)
st.markdown('</div>', unsafe_allow_html=True)
st.markdown('</div>', unsafe_allow_html=True)
st.markdown("### In-Depth Analysis and Insights")
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.")
st.markdown(explanation)
st.markdown("### Alternative Approaches")
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.")
st.markdown(alternatives)
news = fetch_latest_tech_news()
if news:
st.markdown('<div class="tech-news">', unsafe_allow_html=True)
st.markdown("### Latest in Tech & Computer Science")
for item in news:
st.markdown(f"- {item['title']}")
st.markdown('</div>', unsafe_allow_html=True)
st.markdown("""
<div style='text-align: center; margin-top: 2rem; color: #8892b0;'>
Engineered with 🧠💡 by Your Superintelligent AI Code Assistant
</div>
""", unsafe_allow_html=True)
st.markdown('</div>', unsafe_allow_html=True) |