Spaces:
Build error
Build error
Download app.py from Mykola99100/Mythos: direct link, hf CLI and curl.
- Browser
- Download file 809 Bytes
-
https://huggingface.co/spaces/Mykola99100/Mythos/resolve/main/app.py
- Command line
-
hf download hf://spaces/Mykola99100/Mythos/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Mykola99100/Mythos/resolve/main/app.py
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() | |