dtometzki commited on
Commit
99f3f86
·
verified ·
1 Parent(s): 21bd66a

Create app_1.py

Browse files
Files changed (1) hide show
  1. app_1.py +24 -0
app_1.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # pip install -U gradio huggingface_hub
2
+
3
+ import os
4
+ import gradio as gr
5
+ from huggingface_hub import InferenceClient
6
+
7
+ MODEL_ID = "Qwen/Qwen3-Coder-Next"
8
+ client = InferenceClient(model=MODEL_ID, token=os.environ.get("HF_TOKEN"))
9
+
10
+ def chat(user_msg, history):
11
+ messages = []
12
+ for u, a in history:
13
+ messages += [{"role": "user", "content": u}, {"role": "assistant", "content": a}]
14
+ messages.append({"role": "user", "content": user_msg})
15
+
16
+ # Server-side Chat Completions (je nach Backend/Provider)
17
+ resp = client.chat.completions.create(
18
+ messages=messages,
19
+ max_tokens=512,
20
+ temperature=0.2,
21
+ )
22
+ return resp.choices[0].message["content"]
23
+
24
+ gr.ChatInterface(chat, title="Qwen3-Coder-Next (HF Inference API)").launch()