Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| from transformers import pipeline | |
| # 1. Model Logic - Mapping personas to specialized coding models | |
| MODELS = { | |
| "ZewAI 3 (Core)": "microsoft/phi-2", | |
| "ZewAI 3 (Python Pro)": "Salesforce/codet5p-220m", | |
| "ZewAI 3 (Web Master)": "bigcode/starcoder2-3b", | |
| "ZewAI 3 (The AI itself)": "Zakomako4567/ZewAI_3.9_Code" # FIXED Syntax Error here | |
| } | |
| def chat_engine(message, history, model_choice): | |
| # Added trust_remote_code=True for custom model compatibility | |
| pipe = pipeline("text-generation", model=MODELS[model_choice], trust_remote_code=True) | |
| prompt = f"System: You are {model_choice}, the flagship AI of Zakomako4567. Use clean code and detailed logic.\n" | |
| for turn in history: | |
| role = turn['role'] | |
| content = turn['content'] | |
| if role == 'user': | |
| prompt += f"User: {content}\n" | |
| else: | |
| prompt += f"AI: {content}\n" | |
| prompt += f"User: {message}\nAI:" | |
| res = pipe(prompt, max_new_tokens=512, do_sample=True, temperature=0.7)[0]['generated_text'] | |
| return res.split("AI:")[-1].strip() | |
| # Advanced CSS for the ZewAI "Premium" look | |
| custom_css = """ | |
| footer {visibility: hidden} | |
| .gradio-container { background: #050505 !important; color: white !important; } | |
| #title-header { text-align: center; padding: 20px; border-bottom: 2px solid #1e293b; } | |
| .app-card { | |
| background: #111827; | |
| padding: 15px; | |
| border-radius: 12px; | |
| text-align: center; | |
| border: 1px solid #374151; | |
| transition: 0.3s; | |
| } | |
| .app-card:hover { border-color: #3b82f6; transform: translateY(-3px); } | |
| """ | |
| # 2. Building the Workspace | |
| with gr.Blocks() as demo: | |
| with gr.Column(elem_id="title-header"): | |
| gr.Markdown(f"# π ZewAI 3 by @Zakomako4567") | |
| gr.Markdown("The flagship coding AI for the ZewpolOS ecosystem.") | |
| with gr.Row(): | |
| with gr.Column(scale=1, variant="panel"): | |
| gr.Markdown("### π€ User Account") | |
| gr.LoginButton() | |
| gr.Markdown("---") | |
| gr.Markdown("### π§ Neural Presets") | |
| model_dropdown = gr.Dropdown( | |
| choices=list(MODELS.keys()), | |
| value="ZewAI 3 (Core)", | |
| label="Active Brain" | |
| ) | |
| gr.Markdown("---") | |
| gr.Markdown("### π Zewpol Ecosystem") | |
| with gr.Row(): | |
| gr.HTML('<div class="app-card"><a href="https://huggingface.co/Zakomako4567" target="_blank" style="text-decoration:none; color:white;">π Profile</a></div>') | |
| gr.HTML('<div class="app-card"><a href="#" style="text-decoration:none; color:white;">π Projects</a></div>') | |
| with gr.Column(scale=4): | |
| gr.ChatInterface( | |
| fn=chat_engine, | |
| additional_inputs=[model_dropdown], | |
| examples=[ | |
| ["Build a Python web scraper", "ZewAI 3 (Core)"], | |
| ["Explain ZewML logic", "ZewAI 3 (Core)"], | |
| ["Write a C kernel loop for ZewpolOS", "ZewAI 3 (Python Pro)"] | |
| ], | |
| ) | |
| if __name__ == "__main__": | |
| demo.launch( | |
| css=custom_css, | |
| theme=gr.themes.Default(primary_hue="blue", secondary_hue="slate") | |
| ) | |