Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,10 +1,44 @@
|
|
|
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
|
|
|
|
|
|
| 9 |
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
import gradio as gr
|
| 3 |
+
from huggingface_hub import InferenceClient
|
| 4 |
|
| 5 |
+
# 1. 引擎配置:MiniMax-M2.5 (229B 精品逻辑引擎)
|
| 6 |
+
model_id = "MiniMaxAI/MiniMax-M2.5"
|
| 7 |
+
client = InferenceClient(model_id, token=os.getenv("HF_TOKEN"))
|
| 8 |
+
|
| 9 |
+
def chat_fn(message, history):
|
| 10 |
+
messages = []
|
| 11 |
+
for turn in history:
|
| 12 |
+
messages.append({"role": turn["role"], "content": turn["content"]})
|
| 13 |
|
| 14 |
+
messages.append({"role": "user", "content": message["text"]})
|
| 15 |
+
|
| 16 |
+
response = ""
|
| 17 |
+
try:
|
| 18 |
+
for msg in client.chat_completion(messages, max_tokens=4096, stream=True):
|
| 19 |
+
if msg.choices[0].delta.content:
|
| 20 |
+
response += msg.choices[0].delta.content
|
| 21 |
+
yield response
|
| 22 |
+
|
| 23 |
+
response += "\n\n---\n> **OpenIPOS MegaNode | MiniMax-M2.5 极速逻辑节点**"
|
| 24 |
+
yield response
|
| 25 |
+
except Exception as e:
|
| 26 |
+
yield f"⚠️ 算力调度提示: {str(e)}"
|
| 27 |
+
|
| 28 |
+
# 3. 统一品牌装修
|
| 29 |
+
with gr.Blocks(fill_height=True) as demo:
|
| 30 |
+
gr.HTML("""
|
| 31 |
+
<div style="display: flex; align-items: center; gap: 20px; padding: 10px;">
|
| 32 |
+
<img src="https://s3.bmp.ovh/2026/03/30/rIAGKg0O.png" style="height: 60px;">
|
| 33 |
+
<div>
|
| 34 |
+
<h1 style="margin: 0; font-size: 24px;">OpenIPOS MegaNode</h1>
|
| 35 |
+
<p style="margin: 0; color: #666;">中文精品人工智能算力出口 (MiniMax-M2.5)</p>
|
| 36 |
+
</div>
|
| 37 |
+
</div>
|
| 38 |
+
""")
|
| 39 |
+
gr.Markdown("---")
|
| 40 |
+
gr.ChatInterface(chat_fn)
|
| 41 |
+
gr.Markdown("---")
|
| 42 |
+
gr.Markdown("© 2026 OpenIPOS Global Limited. 算力驱动:Novita API Relay")
|
| 43 |
+
|
| 44 |
+
demo.launch(theme=gr.themes.Soft())
|