File size: 5,593 Bytes
f8dbf90
 
 
 
 
 
09716ca
f8dbf90
09716ca
f8dbf90
09716ca
 
f8dbf90
 
 
e705807
f8dbf90
09716ca
 
 
 
 
 
 
 
 
 
 
 
 
 
f8dbf90
 
 
 
a7a2ad9
 
 
 
 
f8dbf90
 
09716ca
f8dbf90
 
 
a90f4c2
d35faf8
 
a90f4c2
 
 
f8dbf90
d35faf8
09716ca
d35faf8
 
b479e07
 
a90f4c2
 
b479e07
09716ca
d35faf8
 
09716ca
d35faf8
a90f4c2
b479e07
 
09716ca
b479e07
 
09716ca
d35faf8
a90f4c2
d35faf8
f8dbf90
d35faf8
a90f4c2
 
09716ca
 
a90f4c2
 
 
 
 
f8dbf90
 
a90f4c2
f8dbf90
d35faf8
a90f4c2
09716ca
d35faf8
09716ca
83ac817
a90f4c2
f8dbf90
 
a90f4c2
09716ca
 
f8dbf90
b479e07
a90f4c2
 
09716ca
b479e07
 
 
a90f4c2
 
b479e07
09716ca
a90f4c2
09716ca
d35faf8
a90f4c2
f8dbf90
d35faf8
a90f4c2
 
 
d35faf8
09716ca
d35faf8
 
a90f4c2
83ac817
f8dbf90
83ac817
 
b479e07
09716ca
 
b479e07
09716ca
b479e07
09716ca
d35faf8
09716ca
83ac817
09716ca
d35faf8
a7a2ad9
 
 
09716ca
a7a2ad9
 
 
 
 
 
83ac817
d35faf8
a90f4c2
09716ca
d35faf8
b479e07
 
 
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
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("""
<style>
    @import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;700&display=swap');
    
    body {
        font-family: 'Inter', sans-serif;
        background-color: #f0f4f8;
        color: #1a202c;
    }
    .stApp {
        max-width: 1200px;
        margin: 0 auto;
        padding: 2rem;
    }
    .main-container {
        background: #ffffff;
        border-radius: 16px;
        padding: 2rem;
        box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
    }
    h1 {
        font-size: 3rem;
        font-weight: 700;
        color: #2d3748;
        text-align: center;
        margin-bottom: 1rem;
        text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
    }
    .subtitle {
        font-size: 1.2rem;
        text-align: center;
        color: #4a5568;
        margin-bottom: 2rem;
    }
    .stTextArea textarea {
        border: 2px solid #e2e8f0;
        border-radius: 8px;
        font-size: 1.1rem;
        padding: 1rem;
        transition: all 0.3s ease;
    }
    .stTextArea textarea:focus {
        border-color: #4299e1;
        box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.5);
    }
    .stButton button {
        background-color: #4299e1;
        color: white;
        border: none;
        border-radius: 8px;
        font-size: 1.2rem;
        font-weight: 600;
        padding: 1rem 2rem;
        transition: all 0.3s ease;
        width: 100%;
    }
    .stButton button:hover {
        background-color: #3182ce;
        transform: translateY(-2px);
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    }
    .output-container {
        background: #f7fafc;
        border-radius: 8px;
        padding: 1.5rem;
        margin-top: 2rem;
    }
    .code-block {
        background-color: #2d3748;
        color: #e2e8f0;
        font-family: 'Fira Code', monospace;
        font-size: 1rem;
        border-radius: 8px;
        padding: 1.5rem;
        margin-top: 1rem;
        overflow-x: auto;
    }
    .stAlert {
        background-color: #ebf8ff;
        color: #2b6cb0;
        border-radius: 8px;
        border: none;
        padding: 1rem 1.5rem;
    }
    .stSpinner {
        color: #4299e1;
    }
</style>
""", unsafe_allow_html=True)

st.markdown('<div class="main-container">', unsafe_allow_html=True)
st.title("🧠 Elite AI Code Architect")
st.markdown('<p class="subtitle">Powered by Google Gemini - Unparalleled coding expertise at your fingertips</p>', 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('<div class="output-container">', unsafe_allow_html=True)
                st.markdown('<div class="code-block">', unsafe_allow_html=True)
                st.code(completed_text)
                st.markdown('</div>', unsafe_allow_html=True)
                st.markdown('</div>', unsafe_allow_html=True)

st.markdown("""
<div style='text-align: center; margin-top: 2rem; color: #4a5568;'>
    Engineered with 🧠 by Your Elite AI Code Architect
</div>
""", unsafe_allow_html=True)

st.markdown('</div>', unsafe_allow_html=True)