HaGPT commited on
Commit
9674609
Β·
verified Β·
1 Parent(s): 61058f2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -13
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="meta-llama-3.1-8b.Q4_K_M.gguf", # λ„ˆ 파일 이름
9
  n_ctx=4096,
10
- n_threads=6, # CPU μ½”μ–΄ 수
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(share=True)
 
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()