Switch to OpenAI client with Kimi-K3:fastest
Browse files- Use OpenAI router API (router.huggingface.co/v1)
- Drop InferenceClient + Together provider, model is 'moonshotai/Kimi-K3:fastest'
Co-Authored-By: Claude <noreply@anthropic.com>
app.py
CHANGED
|
@@ -5,10 +5,9 @@ import urllib.request
|
|
| 5 |
|
| 6 |
from fastapi.responses import HTMLResponse
|
| 7 |
from gradio import Server
|
| 8 |
-
from
|
| 9 |
|
| 10 |
-
MODEL = "moonshotai/Kimi-K3"
|
| 11 |
-
PROVIDER = "together"
|
| 12 |
|
| 13 |
SYSTEM_PROMPT = (
|
| 14 |
"You are Kimi K3, Moonshot AI's open-weight native multimodal agentic model. "
|
|
@@ -57,7 +56,11 @@ def chat(message: dict, history: list) -> dict:
|
|
| 57 |
yield {"role": "assistant", "content": "HF_TOKEN is not configured on this Space. Set it in the Space settings → Secrets."}
|
| 58 |
return
|
| 59 |
|
| 60 |
-
client =
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
|
| 62 |
messages = [{"role": "system", "content": SYSTEM_PROMPT}]
|
| 63 |
for msg in history:
|
|
|
|
| 5 |
|
| 6 |
from fastapi.responses import HTMLResponse
|
| 7 |
from gradio import Server
|
| 8 |
+
from openai import OpenAI
|
| 9 |
|
| 10 |
+
MODEL = "moonshotai/Kimi-K3:fastest"
|
|
|
|
| 11 |
|
| 12 |
SYSTEM_PROMPT = (
|
| 13 |
"You are Kimi K3, Moonshot AI's open-weight native multimodal agentic model. "
|
|
|
|
| 56 |
yield {"role": "assistant", "content": "HF_TOKEN is not configured on this Space. Set it in the Space settings → Secrets."}
|
| 57 |
return
|
| 58 |
|
| 59 |
+
client = OpenAI(
|
| 60 |
+
base_url="https://router.huggingface.co/v1",
|
| 61 |
+
api_key=token,
|
| 62 |
+
timeout=600,
|
| 63 |
+
)
|
| 64 |
|
| 65 |
messages = [{"role": "system", "content": SYSTEM_PROMPT}]
|
| 66 |
for msg in history:
|