Spaces:
Build error
Build error
Update app.py
Browse files
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
|
| 7 |
-
os.environ["HF_HUB_HTTP_TIMEOUT"] = "3600" # 1 hour
|
| 8 |
|
| 9 |
-
# Download the model repository locally; this
|
| 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
|
| 18 |
llm = Llama.from_pretrained(
|
| 19 |
-
repo_id=
|
| 20 |
-
filename="mysqlmodel.gguf",
|
| 21 |
-
|
| 22 |
-
|
|
|
|
| 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 |
|
|
|