File size: 2,147 Bytes
bd21ba5
3791867
33ff849
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3791867
33ff849
 
 
 
 
 
 
 
 
 
 
 
 
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
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()