Updated app
Browse files
app.py
CHANGED
|
@@ -1,10 +1,21 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from
|
|
|
|
| 3 |
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
-
|
|
|
|
|
|
|
| 10 |
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from llama_cpp import Llama
|
| 3 |
+
from huggingface_hub import hf_hub_download
|
| 4 |
|
| 5 |
+
# Download GGUF to local file
|
| 6 |
+
model_path = hf_hub_download(
|
| 7 |
+
repo_id="astegaras/Llama3.2_3B",
|
| 8 |
+
filename="model-Q4_K_M.gguf"
|
| 9 |
+
)
|
| 10 |
|
| 11 |
+
llm = Llama(
|
| 12 |
+
model_path=model_path,
|
| 13 |
+
n_ctx=2048,
|
| 14 |
+
n_gpu_layers=0,
|
| 15 |
+
)
|
| 16 |
|
| 17 |
+
def respond(prompt):
|
| 18 |
+
out = llm(prompt, max_tokens=256)
|
| 19 |
+
return out["choices"][0]["text"]
|
| 20 |
|
| 21 |
+
gr.Interface(fn=respond, inputs="text", outputs="text").launch()
|