Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,11 +1,13 @@
|
|
1 |
import gradio as gr
|
2 |
from modelscope.pipelines import pipeline
|
3 |
from modelscope.utils.constant import Tasks
|
4 |
-
import swift.llm # swift.llm パッケージを直接インポート
|
5 |
|
6 |
# 使用可能なモデルのリスト
|
7 |
models = ["Qwen/Qwen2.5-7B-Instruct", "Qwen/Qwen2.5-14B-Instruct", "Qwen/Qwen2.5-32B-Instruct"]
|
8 |
|
|
|
|
|
|
|
9 |
def respond(
|
10 |
message,
|
11 |
history: list[tuple[str, str]],
|
@@ -15,11 +17,8 @@ def respond(
|
|
15 |
top_p,
|
16 |
selected_model
|
17 |
):
|
18 |
-
#
|
19 |
-
|
20 |
-
|
21 |
-
# 選択したモデルに基づいてPipelineを初期化
|
22 |
-
pipe = pipeline(task=Tasks.text_generation, model=selected_model)
|
23 |
|
24 |
messages = [{"role": "system", "content": system_message}]
|
25 |
|
|
|
1 |
import gradio as gr
|
2 |
from modelscope.pipelines import pipeline
|
3 |
from modelscope.utils.constant import Tasks
|
|
|
4 |
|
5 |
# 使用可能なモデルのリスト
|
6 |
models = ["Qwen/Qwen2.5-7B-Instruct", "Qwen/Qwen2.5-14B-Instruct", "Qwen/Qwen2.5-32B-Instruct"]
|
7 |
|
8 |
+
# モデルを事前にロード
|
9 |
+
model_pipelines = {model: pipeline(task=Tasks.text_generation, model=model) for model in models}
|
10 |
+
|
11 |
def respond(
|
12 |
message,
|
13 |
history: list[tuple[str, str]],
|
|
|
17 |
top_p,
|
18 |
selected_model
|
19 |
):
|
20 |
+
# 選択したモデルに基づいてPipelineを選択
|
21 |
+
pipe = model_pipelines[selected_model]
|
|
|
|
|
|
|
22 |
|
23 |
messages = [{"role": "system", "content": system_message}]
|
24 |
|