Sakalti commited on
Commit
ad3d9cd
1 Parent(s): 1375820

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -11
app.py CHANGED
@@ -1,11 +1,8 @@
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("Sakalti/Saba1.5-Pro-3B")
8
- #応答部分
9
 
10
  def respond(
11
  message,
@@ -14,7 +11,11 @@ def respond(
14
  max_tokens,
15
  temperature,
16
  top_p,
 
17
  ):
 
 
 
18
  messages = [{"role": "system", "content": system_message}]
19
 
20
  for val in history:
@@ -39,14 +40,11 @@ def respond(
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
- #インターフェース
47
  demo = gr.ChatInterface(
48
  respond,
49
  additional_inputs=[
 
50
  gr.Textbox(value="ユーザーの応答と依頼に答えてください。ポジティブに", label="システムメッセージ"),
51
  gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="新規トークン最大"),
52
  gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="温度"),
@@ -61,6 +59,5 @@ demo = gr.ChatInterface(
61
  concurrency_limit=30 # 例: 同時に4つのリクエストを処理
62
  )
63
 
64
-
65
  if __name__ == "__main__":
66
  demo.launch()
 
1
  import gradio as gr
2
  from huggingface_hub import InferenceClient
3
 
4
+ # 使用可能なモデルのリスト
5
+ models = ["Sakalti/Saba1.5-Pro", "Sakalti/Saba2-Preview", "Sakalti/Saba2.1-Preview"]
 
 
 
6
 
7
  def respond(
8
  message,
 
11
  max_tokens,
12
  temperature,
13
  top_p,
14
+ selected_model
15
  ):
16
+ # 選択したモデルに基づいてInferenceClientを初期化
17
+ client = InferenceClient(selected_model)
18
+
19
  messages = [{"role": "system", "content": system_message}]
20
 
21
  for val in history:
 
40
  response += token
41
  yield response
42
 
43
+ # インターフェース
 
 
 
 
44
  demo = gr.ChatInterface(
45
  respond,
46
  additional_inputs=[
47
+ gr.Dropdown(choices=models, value=models[0], label="モデル"),
48
  gr.Textbox(value="ユーザーの応答と依頼に答えてください。ポジティブに", label="システムメッセージ"),
49
  gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="新規トークン最大"),
50
  gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="温度"),
 
59
  concurrency_limit=30 # 例: 同時に4つのリクエストを処理
60
  )
61
 
 
62
  if __name__ == "__main__":
63
  demo.launch()