DebabrataHalder commited on
Commit
a35f14b
·
verified ·
1 Parent(s): 824b03a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -11
app.py CHANGED
@@ -3,10 +3,10 @@ import gradio as gr
3
  from llama_cpp import Llama
4
  from huggingface_hub import snapshot_download
5
 
6
- # Optionally, set a high timeout environment variable (if your HF Hub version honors this)
7
- os.environ["HF_HUB_HTTP_TIMEOUT"] = "3600" # 1 hour in seconds
8
 
9
- # Download the model repository locally; this will block until the download completes
10
  local_repo = snapshot_download(
11
  repo_id="DebabrataHalder/mysqlmodel",
12
  revision="main",
@@ -14,20 +14,19 @@ local_repo = snapshot_download(
14
  resume_download=True
15
  )
16
 
17
- # Load the model from the local repository
18
  llm = Llama.from_pretrained(
19
- repo_id=local_repo, # local folder path now
20
- filename="mysqlmodel.gguf", # the GGUF file name
21
- n_ctx=2048, # adjust context size if needed
22
- local_files_only=True # force local file loading
 
23
  )
24
 
25
  def chat(prompt):
26
- # Generate a response using the model
27
  output = llm(prompt)
28
  return output["choices"][0]["text"]
29
 
30
- # Create Gradio interface
31
  iface = gr.Interface(
32
  fn=chat,
33
  inputs="text",
@@ -38,4 +37,3 @@ iface = gr.Interface(
38
 
39
  iface.launch()
40
 
41
-
 
3
  from llama_cpp import Llama
4
  from huggingface_hub import snapshot_download
5
 
6
+ # Optionally increase the HTTP timeout via an environment variable
7
+ os.environ["HF_HUB_HTTP_TIMEOUT"] = "3600" # 1 hour
8
 
9
+ # Download the model repository locally; this call blocks until the download completes.
10
  local_repo = snapshot_download(
11
  repo_id="DebabrataHalder/mysqlmodel",
12
  revision="main",
 
14
  resume_download=True
15
  )
16
 
17
+ # Load the model using the remote repo_id and specify the local cache directory
18
  llm = Llama.from_pretrained(
19
+ repo_id="DebabrataHalder/mysqlmodel", # valid repo id format
20
+ filename="mysqlmodel.gguf",
21
+ cache_dir=local_repo, # point to the downloaded snapshot
22
+ n_ctx=2048, # adjust context size if needed
23
+ local_files_only=True # ensure only local files are used
24
  )
25
 
26
  def chat(prompt):
 
27
  output = llm(prompt)
28
  return output["choices"][0]["text"]
29
 
 
30
  iface = gr.Interface(
31
  fn=chat,
32
  inputs="text",
 
37
 
38
  iface.launch()
39