Daffaadityp commited on
Commit
db9f8aa
·
verified ·
1 Parent(s): 979e34b

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +41 -0
app.py ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from huggingface_hub import hf_hub_download
3
+ from llama_cpp import Llama
4
+
5
+ print("Downloading model...")
6
+
7
+ MODEL_PATH = hf_hub_download(
8
+ repo_id="Daffaadityp/AxonAI-MX4-2.0-GGUF",
9
+ filename="AxonAI-MX4-2.0-Q4_K_M.gguf"
10
+ )
11
+
12
+ print("Loading model...")
13
+
14
+ llm = Llama(
15
+ model_path=MODEL_PATH,
16
+ n_ctx=2048,
17
+ n_threads=2,
18
+ n_batch=128,
19
+ verbose=False,
20
+ )
21
+
22
+ print("Model loaded!")
23
+
24
+ def chat(message, history):
25
+
26
+ result = llm(
27
+ message,
28
+ max_tokens=128,
29
+ temperature=0.7,
30
+ stop=["<|im_end|>", "</s>"]
31
+ )
32
+
33
+ return result["choices"][0]["text"]
34
+
35
+ demo = gr.ChatInterface(
36
+ fn=chat,
37
+ title="AxonAI MX4 2.0",
38
+ description="AxonAI-MX4-2.0-Q4_K_M.gguf"
39
+ )
40
+
41
+ demo.launch(server_name="0.0.0.0")