dodd869 commited on
Commit
c4b8136
·
verified ·
1 Parent(s): 4e35316

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -5
app.py CHANGED
@@ -4,12 +4,10 @@ from huggingface_hub import InferenceClient
4
  import requests
5
 
6
  url = "https://huggingface.co/models-json?num_parameters=min%3A128B&inference_provider=cerebras%2Cnebius%2Cfireworks-ai%2Ctogether%2Csambanova%2Cnovita%2Cgroq%2Cnscale%2Chyperbolic%2Cfeatherless-ai%2Cfal-ai%2Ccohere%2Creplicate%2Chf-inference&sort=trending&withCount=true"
7
-
8
  res = requests.get(url).json()
9
  model_ids = [m['id'] for m in res.get('models', [])]
10
 
11
  client = InferenceClient(provider="novita", api_key=os.environ["HF_TOKEN"])
12
- #models = ["deepseek-ai/DeepSeek-V3.1","zai-org/GLM-4.5","Qwen/Qwen3-Coder-480B-A35B-Instruct", "Qwen/Qwen3-Coder-480B-A35B-Instruct-FP8","deepseek-ai/DeepSeek-R1","deepseek-ai/DeepSeek-R1-0528","Qwen/Qwen3-Next-80B-A3B-Thinking"]
13
 
14
  def respond(message, history, model):
15
  history.append((message, ""))
@@ -20,8 +18,9 @@ def respond(message, history, model):
20
  messages=[{"role": "user", "content": message}],
21
  stream=True
22
  ):
23
- if hasattr(chunk.choices[0].delta, 'content') and chunk.choices[0].delta.content:
24
- full_reply += chunk.choices[0].delta.content
 
25
  history[-1] = (message, full_reply)
26
  yield "", history
27
 
@@ -29,7 +28,7 @@ with gr.Blocks() as demo:
29
  gr.Markdown("## AI")
30
  chatbot = gr.Chatbot(height=400)
31
  msg = gr.Textbox(label="Ask me smth")
32
- model_dd = gr.Dropdown(model_ids, label="Model", value=models[0])
33
  with gr.Row():
34
  submit_btn = gr.Button("Send")
35
  clear = gr.Button("Clear")
 
4
  import requests
5
 
6
  url = "https://huggingface.co/models-json?num_parameters=min%3A128B&inference_provider=cerebras%2Cnebius%2Cfireworks-ai%2Ctogether%2Csambanova%2Cnovita%2Cgroq%2Cnscale%2Chyperbolic%2Cfeatherless-ai%2Cfal-ai%2Ccohere%2Creplicate%2Chf-inference&sort=trending&withCount=true"
 
7
  res = requests.get(url).json()
8
  model_ids = [m['id'] for m in res.get('models', [])]
9
 
10
  client = InferenceClient(provider="novita", api_key=os.environ["HF_TOKEN"])
 
11
 
12
  def respond(message, history, model):
13
  history.append((message, ""))
 
18
  messages=[{"role": "user", "content": message}],
19
  stream=True
20
  ):
21
+ content = chunk.choices[0].delta.content
22
+ if content:
23
+ full_reply += content
24
  history[-1] = (message, full_reply)
25
  yield "", history
26
 
 
28
  gr.Markdown("## AI")
29
  chatbot = gr.Chatbot(height=400)
30
  msg = gr.Textbox(label="Ask me smth")
31
+ model_dd = gr.Dropdown(model_ids, label="Model", value=model_ids[0] if model_ids else "")
32
  with gr.Row():
33
  submit_btn = gr.Button("Send")
34
  clear = gr.Button("Clear")