File size: 1,186 Bytes
86b7c7d
d56e067
ce15b97
86b7c7d
ce15b97
d56e067
 
824b03a
a35f14b
86b7c7d
3fdb9fc
86b7c7d
 
824b03a
86b7c7d
 
a35f14b
86b7c7d
a35f14b
 
d56e067
 
 
3fdb9fc
ce15b97
d56e067
ce15b97
 
 
d56e067
 
 
 
 
 
 
 
 
 
ce15b97
a418d00
 
 
7cf53d3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import os
import gradio as gr
from llama_cpp import Llama
from huggingface_hub import snapshot_download

# Optionally increase the HTTP timeout via an environment variable
os.environ["HF_HUB_HTTP_TIMEOUT"] = "3600"  # 1 hour

# Download the model repository locally; this call blocks until the download completes.
local_repo = snapshot_download(
    repo_id="DebabrataHalder/mysqlmodel",
    revision="main",
    local_dir_use_symlinks=False,
    resume_download=True
)

# Load the model using the remote repo_id and specify the local cache directory
llm = Llama.from_pretrained(
    repo_id="DebabrataHalder/mysqlmodel",  # valid repo id format
    filename="mysqlmodel.gguf",
    cache_dir=local_repo,                   # point to the downloaded snapshot
    n_ctx=2048,                           # adjust context size if needed
    local_files_only=True                   # ensure only local files are used
)

def chat(prompt):
    output = llm(prompt)
    return output["choices"][0]["text"]

iface = gr.Interface(
    fn=chat,
    inputs="text",
    outputs="text",
    title="MySQL LLM Chat",
    description="Chat interface for the MySQL finetuned model"
)

iface.launch()