update app.py
Browse files
app.py
CHANGED
@@ -1,23 +1,18 @@
|
|
1 |
import gradio as gr
|
2 |
-
from
|
3 |
|
4 |
-
# 加载
|
5 |
-
|
6 |
-
pipe = pipeline("text-generation", model=model_name)
|
7 |
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
|
|
12 |
|
13 |
# 创建 Gradio 界面
|
14 |
-
interface = gr.Interface(
|
15 |
-
|
16 |
-
|
17 |
-
outputs="text",
|
18 |
-
title="Medical Text Generation",
|
19 |
-
description="输入医疗相关的文本,模型将自动补全内容。",
|
20 |
-
)
|
21 |
|
22 |
-
# 运行 Gradio 应用
|
23 |
interface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
from llama_cpp import Llama
|
3 |
|
4 |
+
# 加载 GGUF 模型(替换成你的模型路径)
|
5 |
+
model_path = "YLX1965/medical-model/unsloth.Q8_0.gguf"
|
|
|
6 |
|
7 |
+
llm = Llama(model_path=model_path)
|
8 |
+
|
9 |
+
def chat(prompt):
|
10 |
+
output = llm(prompt, max_tokens=200)
|
11 |
+
return output["choices"][0]["text"]
|
12 |
|
13 |
# 创建 Gradio 界面
|
14 |
+
interface = gr.Interface(fn=chat, inputs="text", outputs="text",
|
15 |
+
title="Medical Chatbot",
|
16 |
+
description="使用 GGUF 量化模型进行医疗文本生成")
|
|
|
|
|
|
|
|
|
17 |
|
|
|
18 |
interface.launch()
|