injection10 commited on
Commit
3b98de0
·
verified ·
1 Parent(s): c387b44

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -6
app.py CHANGED
@@ -2,19 +2,22 @@ import gradio as gr
2
  from huggingface_hub import InferenceClient
3
  import os
4
 
5
- client = InferenceClient("HuggingFaceH4/zephyr-7b-beta", token=os.getenv("SecretToken"))
6
 
7
  def chat_fn(message, history):
8
  try:
9
  response = ""
10
-
11
- for msg in client.text_generation(message, max_new_tokens=512, stream=True):
12
- response += msg
13
- yield response
 
 
 
14
  except Exception as e:
15
  yield f"❌ Erreur Technique: {str(e)}"
16
 
17
- demo = gr.ChatInterface(fn=chat_fn, title="Test Connection")
18
 
19
  if __name__ == "__main__":
20
  demo.launch()
 
2
  from huggingface_hub import InferenceClient
3
  import os
4
 
5
+ client = InferenceClient("Qwen/Qwen2.5-7B-Instruct", token=os.getenv("SecretToken"))
6
 
7
  def chat_fn(message, history):
8
  try:
9
  response = ""
10
+ messages = [{"role": "user", "content": message}]
11
+
12
+ for msg in client.chat_completion(messages, max_tokens=512, stream=True):
13
+ token = msg.choices[0].delta.content
14
+ if token:
15
+ response += token
16
+ yield response
17
  except Exception as e:
18
  yield f"❌ Erreur Technique: {str(e)}"
19
 
20
+ demo = gr.ChatInterface(fn=chat_fn, title="Test Connection - Qwen 2.5")
21
 
22
  if __name__ == "__main__":
23
  demo.launch()