Download app.py from Bush233/test: direct link, hf CLI and curl.
- Browser
- Download file 517 Bytes
-
https://huggingface.co/spaces/Bush233/test/resolve/main/app.py
- Command line
-
hf download hf://spaces/Bush233/test/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Bush233/test/resolve/main/app.py
517 Bytes
| import gradio as gr | |
| # pipeline函数用来加载模型并且推理 | |
| from transformers import pipeline | |
| # 创建文本生成管道 | |
| pipe = pipeline("text-generation", model="Bush233/olmo3-190m-zh-nano") | |
| # 定义预测(predict)函数 | |
| def predict(message): | |
| # 调用pipe管道实现文本生成 | |
| # message:输入的提示词 | |
| # max_new_tokens:输出token的最大值 | |
| output = pipe(message, max_new_tokens=256) | |
| return output[0]["generated_text"] | |
| gr.Interface(fn=predict, inputs="text", outputs="text").launch() |