Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,23 +1,23 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from llama_cpp import Llama
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
-
# -----------------------------
|
| 5 |
-
# 1) GGUF λͺ¨λΈ λ‘λ
|
| 6 |
-
# -----------------------------
|
| 7 |
llm = Llama(
|
| 8 |
-
model_path=
|
| 9 |
n_ctx=4096,
|
| 10 |
-
n_threads=6,
|
| 11 |
n_gpu_layers=0,
|
| 12 |
verbose=False
|
| 13 |
)
|
| 14 |
|
| 15 |
-
# -----------------------------
|
| 16 |
-
# 2) μ± ν¨μ
|
| 17 |
-
# -----------------------------
|
| 18 |
def chat_fn(message, history):
|
| 19 |
messages = []
|
| 20 |
-
|
| 21 |
for user, bot in history:
|
| 22 |
messages.append({"role": "user", "content": user})
|
| 23 |
messages.append({"role": "assistant", "content": bot})
|
|
@@ -33,13 +33,10 @@ def chat_fn(message, history):
|
|
| 33 |
answer = response["choices"][0]["message"]["content"]
|
| 34 |
return answer
|
| 35 |
|
| 36 |
-
# -----------------------------
|
| 37 |
-
# 3) Gradio UI
|
| 38 |
-
# -----------------------------
|
| 39 |
interface = gr.ChatInterface(
|
| 40 |
fn=chat_fn,
|
| 41 |
title="π° News Intelligence Bot",
|
| 42 |
description="Your local GGUF chatbot running on llama.cpp"
|
| 43 |
)
|
| 44 |
|
| 45 |
-
interface.launch(
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from llama_cpp import Llama
|
| 3 |
+
from huggingface_hub import hf_hub_download
|
| 4 |
+
|
| 5 |
+
# GGUF λ€μ΄λ‘λ
|
| 6 |
+
model_path = hf_hub_download(
|
| 7 |
+
repo_id="HaGPT/news-intelligence-bot",
|
| 8 |
+
filename="meta-llama-3.1-8b.Q4_K_M.gguf",
|
| 9 |
+
)
|
| 10 |
|
|
|
|
|
|
|
|
|
|
| 11 |
llm = Llama(
|
| 12 |
+
model_path=model_path,
|
| 13 |
n_ctx=4096,
|
| 14 |
+
n_threads=6,
|
| 15 |
n_gpu_layers=0,
|
| 16 |
verbose=False
|
| 17 |
)
|
| 18 |
|
|
|
|
|
|
|
|
|
|
| 19 |
def chat_fn(message, history):
|
| 20 |
messages = []
|
|
|
|
| 21 |
for user, bot in history:
|
| 22 |
messages.append({"role": "user", "content": user})
|
| 23 |
messages.append({"role": "assistant", "content": bot})
|
|
|
|
| 33 |
answer = response["choices"][0]["message"]["content"]
|
| 34 |
return answer
|
| 35 |
|
|
|
|
|
|
|
|
|
|
| 36 |
interface = gr.ChatInterface(
|
| 37 |
fn=chat_fn,
|
| 38 |
title="π° News Intelligence Bot",
|
| 39 |
description="Your local GGUF chatbot running on llama.cpp"
|
| 40 |
)
|
| 41 |
|
| 42 |
+
interface.launch()
|