Xolkin commited on
Commit
9d2ff11
·
verified ·
1 Parent(s): 0b56041

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -12
app.py CHANGED
@@ -2,10 +2,11 @@ import gradio as gr
2
  from huggingface_hub import InferenceClient
3
 
4
  """
5
- Для получения дополнительной информации об API Inference `huggingface_hub` ознакомьтесь с документацией: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
6
  """
7
  client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
8
 
 
9
  def respond(
10
  message,
11
  history: list[tuple[str, str]],
@@ -14,6 +15,9 @@ def respond(
14
  temperature,
15
  top_p,
16
  ):
 
 
 
17
  messages = [{"role": "system", "content": system_message}]
18
 
19
  for val in history:
@@ -34,34 +38,30 @@ def respond(
34
  top_p=top_p,
35
  ):
36
  token = message.choices[0].delta.content
 
37
  response += token
38
  yield response
39
 
40
- # Добавляем идентификационное сообщение к ответу
41
- final_response = f"{response}\n\nСоздано больницей EMS штата Alta"
42
- yield final_response
43
 
44
  """
45
- Для получения информации о том, как настроить интерфейс чата, ознакомьтесь с документацией Gradio: https://www.gradio.app/docs/chatinterface
46
  """
47
  demo = gr.ChatInterface(
48
  respond,
49
  additional_inputs=[
50
- gr.Textbox(
51
- value="Привет! Я помощник врача в больнице EMS штата Alta! Напиши внизу симптомы заболевания и я поставлю предварительный диагноз! И хирургическую операцию, если надо будет ее провести.",
52
- label="Системное сообщение"
53
- ),
54
- gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Максимальное количество новых токенов"),
55
- gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Температура"),
56
  gr.Slider(
57
  minimum=0.1,
58
  maximum=1.0,
59
  value=0.95,
60
  step=0.05,
61
- label="Top-p (ядерное семплирование)",
62
  ),
63
  ],
64
  )
65
 
 
66
  if __name__ == "__main__":
67
  demo.launch()
 
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("HuggingFaceH4/zephyr-7b-beta")
8
 
9
+
10
  def respond(
11
  message,
12
  history: list[tuple[str, str]],
 
15
  temperature,
16
  top_p,
17
  ):
18
+ # Установим приветственное сообщение для системы
19
+ system_message = "Привет! Я помощник врача в больнице EMS штата Alta! Напиши внизу симптомы заболевания и я поставлю предварительный диагноз! И хирургическую операцию, если надо будет ее провести."
20
+
21
  messages = [{"role": "system", "content": system_message}]
22
 
23
  for val in history:
 
38
  top_p=top_p,
39
  ):
40
  token = message.choices[0].delta.content
41
+
42
  response += token
43
  yield response
44
 
 
 
 
45
 
46
  """
47
+ For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
48
  """
49
  demo = gr.ChatInterface(
50
  respond,
51
  additional_inputs=[
52
+ gr.Textbox(value="You are a friendly Chatbot.", label="System message"),
53
+ gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
54
+ gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
 
 
 
55
  gr.Slider(
56
  minimum=0.1,
57
  maximum=1.0,
58
  value=0.95,
59
  step=0.05,
60
+ label="Top-p (nucleus sampling)",
61
  ),
62
  ],
63
  )
64
 
65
+
66
  if __name__ == "__main__":
67
  demo.launch()