Mythos / app.py
Mykola99100's picture
Update app.py
9e0db18 verified
Raw History Blame Contribute Delete
809 Bytes
import gradio as gr
from llama_cpp import Llama
from huggingface_hub import hf_hub_download
# Download the model file
model_path = hf_hub_download(
repo_id="Squ11z1/Mythos-nano-GGUF",
filename="mythos-nano-q4_k_m.gguf"
)
# Initialize the model (CPU only)
llm = Llama(model_path=model_path, n_ctx=2048)
def chat(message, history):
# Format history for llama-cpp
formatted_prompt = ""
for human, assistant in history:
formatted_prompt += f"User: {human}\nAssistant: {assistant}\n"
formatted_prompt += f"User: {message}\nAssistant:"
# Generate response
response = llm(formatted_prompt, max_tokens=512, stop=["User:"], echo=False)
return response['choices'][0]['text']
# Launch Gradio interface
gr.ChatInterface(fn=chat, title="Mythos-nano CPU Chat").launch()