lilagi5822 commited on
Commit
ba466bf
·
verified ·
1 Parent(s): d62666d

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from llama_cpp import Llama
3
+ from huggingface_hub import hf_hub_download
4
+
5
+ # Download model
6
+ model_path = hf_hub_download(
7
+ "mradermacher/Falcon-H1-Tiny-R-90M-GGUF",
8
+ "Falcon-H1-Tiny-R-90M.Q2_K.gguf"
9
+ )
10
+
11
+ llm = Llama(model_path, n_ctx=512, n_threads=2)
12
+
13
+ def chat(message):
14
+ response = llm(
15
+ f"User: {message}\nAssistant:",
16
+ max_tokens=50,
17
+ temperature=0.7,
18
+ stop=["User:"]
19
+ )
20
+ return response['choices'][0]['text'].strip()
21
+
22
+ demo = gr.Interface(chat, "text", "text")
23
+ demo.launch()