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()