Xolkin commited on
Commit
334df3e
·
verified ·
1 Parent(s): 5a324d7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -11
app.py CHANGED
@@ -1,6 +1,9 @@
1
  import gradio as gr
2
  from huggingface_hub import InferenceClient
3
 
 
 
 
4
  client = InferenceClient("Qwen/QwQ-32B")
5
 
6
 
@@ -32,23 +35,18 @@ def respond(
32
  top_p=top_p,
33
  ):
34
  token = message.choices[0].delta.content
35
- response += token
36
-
37
- # Как только получаем информацию о диагнозе и операции, мы ограничиваем ответ
38
- if "Предварительный диагноз" in response:
39
- # Обрабатываем ответ в нужном формате
40
- formatted_response = response.strip().split("\n")
41
- if len(formatted_response) >= 3:
42
- # Применяем формат
43
- return "\n".join(formatted_response[:3])
44
 
45
- return response
 
46
 
47
 
 
 
 
48
  demo = gr.ChatInterface(
49
  respond,
50
  additional_inputs=[
51
- gr.Textbox(value="Здравствуйте. Отвечай кратко и сразу пиши начинай с этого ответ: Предварительный диагноз:(диагноз), Операция: (Если требуется, только название), Лечение: (Кратко, очень). Не пиши воду. Только по факту на 3 пункта отвечай. Не отходи от этого шаблона", label="System message"),
52
  gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
53
  gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
54
  gr.Slider(
 
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
  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=[
49
+ gr.Textbox(value="Здравствуйте. Отвечай кратко(не пиши вступление, умозаключения итп) и сразу пиши начинай с этого ответ: Предварительный диагноз:(диагноз), Операция: (Если требуется, только название), Лечение: (Кратко, очень). Не пиши воду. Только по факту на 3 пункта отвечай. Не отходи от этого шаблона", label="System message"),
50
  gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
51
  gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
52
  gr.Slider(