BramLeo commited on
Commit
eb468e4
·
verified ·
1 Parent(s): 06f217b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -10,6 +10,7 @@ from llama_index.embeddings.huggingface import HuggingFaceEmbedding
10
  from llama_index.core import Settings
11
  from llama_cpp import Llama
12
  from huggingface_hub import hf_hub_download
 
13
 
14
  # Fungsi untuk memasang ulang llama-cpp-python dengan dukungan CUDA
15
  def install_llama_with_cuda():
@@ -21,7 +22,7 @@ def install_llama_with_cuda():
21
  # Install setiap paket dengan CMAKE_ARGS untuk dukungan CUDA
22
  for package in packages:
23
  subprocess.run(
24
- ["pip", "install", "--force-reinstall", "--no-cache-dir", "llama-cpp-python"],
25
  env={"CMAKE_ARGS": "-DGGML_CUDA=on"},
26
  check=True
27
  )
@@ -49,13 +50,12 @@ def initialize_llama_model():
49
  return model_path
50
 
51
  # Fungsi untuk mengatur konfigurasi Settings
52
- def initialize_settings(model_path): # Terima model_path sebagai parameter
53
- Settings.llm = LlamaCPP(
54
  model_path=model_path,
55
- model_kwargs={"n_gpu_layers": 0, # Sesuaikan dengan kebutuhan perangkat Anda
56
- "temperature": 0.7, # Sesuaikan untuk respons yang lebih cepat
57
- "top_p": 0.9, # Mengurangi eksplorasi token
58
- }
59
  )
60
 
61
  # Fungsi untuk Menginisialisasi Index
 
10
  from llama_index.core import Settings
11
  from llama_cpp import Llama
12
  from huggingface_hub import hf_hub_download
13
+ from llama_cpp import Llama
14
 
15
  # Fungsi untuk memasang ulang llama-cpp-python dengan dukungan CUDA
16
  def install_llama_with_cuda():
 
22
  # Install setiap paket dengan CMAKE_ARGS untuk dukungan CUDA
23
  for package in packages:
24
  subprocess.run(
25
+ ["python", "-m", "pip", "install", "--force-reinstall", "--no-cache-dir", "llama-cpp-python"],
26
  env={"CMAKE_ARGS": "-DGGML_CUDA=on"},
27
  check=True
28
  )
 
50
  return model_path
51
 
52
  # Fungsi untuk mengatur konfigurasi Settings
53
+ def initialize_settings(model_path):
54
+ Settings.llm = Llama(
55
  model_path=model_path,
56
+ n_gpu_layers=1, # Sesuaikan dengan kebutuhan perangkat Anda
57
+ temperature=0.7, # Sesuaikan untuk respons yang lebih cepat
58
+ top_p=0.9 # Mengurangi eksplorasi token
 
59
  )
60
 
61
  # Fungsi untuk Menginisialisasi Index