File size: 775 Bytes
fc3790e
1c2fbc9
8896598
1c2fbc9
 
 
 
 
fc3790e
1c2fbc9
 
 
 
 
8896598
 
fc3790e
 
af7f4e5
 
fc3790e
 
 
 
db134f6
fc3790e
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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()