import streamlit as st
import google.generativeai as genai
# Configure the Gemini API
genai.configure(api_key=st.secrets["GOOGLE_API_KEY"])
# Create the model with advanced system instructions
generation_config = {
"temperature": 0.6, # Slightly reduced for more focused outputs
"top_p": 0.95,
"top_k": 40, # Adjusted for more precise token selection
"max_output_tokens": 16384, # Increased for more comprehensive responses
}
model = genai.GenerativeModel(
model_name="gemini-1.5-pro",
generation_config=generation_config,
system_instruction="""You are Ath, an extraordinarily knowledgeable and skilled code assistant with unparalleled expertise across all programming languages, paradigms, and cutting-edge technologies. Your vast knowledge encompasses:
1. Advanced software architecture and design patterns
2. Highly optimized algorithms and data structures
3. Cutting-edge machine learning and AI techniques
4. Cloud computing and distributed systems
5. Cybersecurity best practices and ethical hacking
6. Blockchain and cryptography
7. Quantum computing fundamentals
8. IoT and embedded systems programming
9. High-performance computing and parallel processing
10. Advanced web technologies and frameworks
Provide sophisticated, production-ready code solutions that demonstrate best practices, scalability, and efficiency. Incorporate comments explaining complex logic or innovative approaches. While maintaining a casual and friendly tone, focus on delivering exceptional, professional-grade code that showcases your extensive programming knowledge."""
)
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}"
# Streamlit UI setup
st.set_page_config(page_title="Elite AI Code Architect", page_icon="🧠", layout="wide")
st.markdown("""
""", unsafe_allow_html=True)
st.markdown('
', unsafe_allow_html=True)
st.title("🧠Elite AI Code Architect")
st.markdown('
Powered by Google Gemini - Unparalleled coding expertise at your fingertips
', unsafe_allow_html=True)
prompt = st.text_area("Present your most challenging coding problem or architectural design question:", height=150)
if st.button("Generate Elite Solution"):
if prompt.strip() == "":
st.error("Please enter a valid prompt to unleash the power of the Elite AI Code Architect.")
else:
with st.spinner("Crafting an exceptional code solution..."):
completed_text = generate_response(prompt)
if "An error occurred" in completed_text:
st.error(completed_text)
else:
st.success("Elite-level code solution generated successfully!")
st.markdown('
', unsafe_allow_html=True)
st.markdown('
', unsafe_allow_html=True)
st.code(completed_text)
st.markdown('
', unsafe_allow_html=True)
st.markdown('
', unsafe_allow_html=True)
st.markdown("""
Engineered with 🧠by Your Elite AI Code Architect
""", unsafe_allow_html=True)
st.markdown('
', unsafe_allow_html=True)