Xolkin commited on
Commit
1ee4bc1
·
verified ·
1 Parent(s): c057f62

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -9
app.py CHANGED
@@ -1,9 +1,6 @@
1
  import gradio as gr
2
  from huggingface_hub import InferenceClient
3
 
4
- """
5
- For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
6
- """
7
  client = InferenceClient("Qwen/QwQ-32B")
8
 
9
 
@@ -35,14 +32,16 @@ def respond(
35
  top_p=top_p,
36
  ):
37
  token = message.choices[0].delta.content
38
-
39
  response += token
40
- yield response
 
 
 
 
 
 
41
 
42
 
43
- """
44
- For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
45
- """
46
  demo = gr.ChatInterface(
47
  respond,
48
  additional_inputs=[
@@ -61,4 +60,4 @@ demo = gr.ChatInterface(
61
 
62
 
63
  if __name__ == "__main__":
64
- demo.launch()
 
1
  import gradio as gr
2
  from huggingface_hub import InferenceClient
3
 
 
 
 
4
  client = InferenceClient("Qwen/QwQ-32B")
5
 
6
 
 
32
  top_p=top_p,
33
  ):
34
  token = message.choices[0].delta.content
 
35
  response += token
36
+
37
+ # Выводим ответ, строго соответствующий шаблону
38
+ if "Предварительный диагноз" in response:
39
+ # Прекращаем выводить больше токенов после того, как ответ будет завершён
40
+ return response.strip()
41
+
42
+ return response
43
 
44
 
 
 
 
45
  demo = gr.ChatInterface(
46
  respond,
47
  additional_inputs=[
 
60
 
61
 
62
  if __name__ == "__main__":
63
+ demo.launch()