Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,13 +1,17 @@
|
|
1 |
import gradio as gr
|
2 |
from llama_cpp import Llama
|
|
|
3 |
|
4 |
-
#
|
5 |
-
|
|
|
|
|
|
|
6 |
|
7 |
# Load model
|
8 |
-
llm = Llama(model_path=
|
9 |
|
10 |
-
#
|
11 |
def format_prompt(user_message):
|
12 |
return f"""### Instruction:
|
13 |
{user_message}
|
@@ -24,7 +28,7 @@ def respond(user_message, chat_history):
|
|
24 |
|
25 |
# Gradio UI
|
26 |
with gr.Blocks() as demo:
|
27 |
-
gr.Markdown("## 🤖 DStv AI Assistant
|
28 |
chatbot = gr.Chatbot()
|
29 |
msg = gr.Textbox(placeholder="Ask your question...")
|
30 |
state = gr.State([])
|
@@ -32,4 +36,3 @@ with gr.Blocks() as demo:
|
|
32 |
msg.submit(respond, [msg, state], [msg, chatbot])
|
33 |
|
34 |
demo.launch()
|
35 |
-
|
|
|
1 |
import gradio as gr
|
2 |
from llama_cpp import Llama
|
3 |
+
from huggingface_hub import hf_hub_download
|
4 |
|
5 |
+
# Download GGUF model from Hugging Face Hub
|
6 |
+
MODEL_REPO = "Futuresony/gemma2-2b-gguf-q4_k_m"
|
7 |
+
MODEL_FILENAME = "gemma-2b-it-q4_k_m.gguf" # Or check exact filename on the repo
|
8 |
+
|
9 |
+
model_path = hf_hub_download(repo_id=MODEL_REPO, filename=MODEL_FILENAME)
|
10 |
|
11 |
# Load model
|
12 |
+
llm = Llama(model_path=model_path, n_ctx=2048, n_threads=4, verbose=True)
|
13 |
|
14 |
+
# Format prompt as Alpaca-style
|
15 |
def format_prompt(user_message):
|
16 |
return f"""### Instruction:
|
17 |
{user_message}
|
|
|
28 |
|
29 |
# Gradio UI
|
30 |
with gr.Blocks() as demo:
|
31 |
+
gr.Markdown("## 🤖 DStv AI Assistant - Powered by Gemma 2B GGUF")
|
32 |
chatbot = gr.Chatbot()
|
33 |
msg = gr.Textbox(placeholder="Ask your question...")
|
34 |
state = gr.State([])
|
|
|
36 |
msg.submit(respond, [msg, state], [msg, chatbot])
|
37 |
|
38 |
demo.launch()
|
|