YLX1965 commited on
Commit
4d880c5
·
verified ·
1 Parent(s): 151f648

update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -16
app.py CHANGED
@@ -1,23 +1,18 @@
1
  import gradio as gr
2
- from transformers import pipeline
3
 
4
- # 加载 Hugging Face 预训练模型
5
- model_name = "YLX1965/medical-model" # 你的模型名称
6
- pipe = pipeline("text-generation", model=model_name)
7
 
8
- # 定义 Gradio 交互函数
9
- def generate_text(prompt):
10
- result = pipe(prompt, max_length=200)[0]["generated_text"]
11
- return result
 
12
 
13
  # 创建 Gradio 界面
14
- interface = gr.Interface(
15
- fn=generate_text,
16
- inputs="text",
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()