MiniMind-API / app.py
fariasultana's picture
fix: Simplified stable Gradio 4.x app
33ff849 verified
import gradio as gr
def chat(message, history):
thinking = """<Thinking>
<step> Analyzing query...
<step> MoE routing (2/8 experts)
<step> Generating response
</Thinking>"""
response = f"**MiniMind Max2**: {message}\n\nProcessed with MoE (25% active params)."
return response, thinking
def calculate(expr):
try:
result = eval(expr, {"__builtins__": {}}, {})
return f"Result: {result}"
except:
return "Error: Invalid expression"
with gr.Blocks(title="MiniMind Max2") as demo:
gr.Markdown("# 🧠 MiniMind Max2 API\n*Efficient Edge AI with MoE Architecture*")
with gr.Tab("💬 Chat"):
chatbot = gr.Chatbot(type="messages", height=300)
msg = gr.Textbox(label="Message", placeholder="Ask anything...")
thinking_box = gr.Textbox(label="Thinking Trace", lines=5)
def respond(message, chat_history):
response, thinking = chat(message, chat_history)
chat_history.append({"role": "user", "content": message})
chat_history.append({"role": "assistant", "content": response})
return chat_history, "", thinking
msg.submit(respond, [msg, chatbot], [chatbot, msg, thinking_box])
gr.Button("Send", variant="primary").click(respond, [msg, chatbot], [chatbot, msg, thinking_box])
with gr.Tab("🔧 Tools"):
expr = gr.Textbox(label="Expression", value="2 + 2 * 3")
result = gr.Textbox(label="Result")
gr.Button("Calculate", variant="primary").click(calculate, expr, result)
with gr.Tab("ℹ️ Info"):
gr.Markdown("""
## MiniMind Max2 Architecture
- **MoE**: 8 experts, top-2 routing (25% activation)
- **GQA**: 16 Q-heads, 4 KV-heads
- **Capabilities**: Reasoning, Vision, Coding, Tools
## Docker
```bash
docker pull sultanafariabd/minimind-max2
docker run -p 8000:8000 sultanafariabd/minimind-max2
```
""")
gr.Markdown("---\n[Model](https://huggingface.co/fariasultana/MiniMind) | [Collection](https://huggingface.co/collections/fariasultana/minimind-max2-edge-ai-models-69321e758f98df18d4f4ec05)")
demo.launch()