Spaces:
Sleeping
Sleeping
import gradio as gr | |
import pathlib | |
from huggingface_hub import hf_hub_download | |
from llama_cpp import Llama | |
# 書き込み可能なディレクトリを指定(例:現在のディレクトリの "models" フォルダ) | |
models_dir = pathlib.Path(__file__).parent / "models" | |
models_dir.mkdir(exist_ok=True) | |
model_path = hf_hub_download( | |
repo_id="Mori-kamiyama/sarashina2-13b-r1", | |
filename="model.gguf", | |
local_dir=models_dir | |
) | |
llm = Llama(model_path=model_path) | |
def generate_text(prompt): | |
result = llm(prompt) | |
return result['choices'][0]['text'] | |
iface = gr.Interface(fn=generate_text, | |
inputs="text", | |
outputs="text", | |
title="GGUFモデルテキストジェネレーター") | |
iface.launch() |