Spaces:
Runtime error
Runtime error
Download app.py from hyperpixel123/hyperpixel_1.0: direct link, hf CLI and curl.
- Browser
- Download file 841 Bytes
-
https://huggingface.co/spaces/hyperpixel123/hyperpixel_1.0/resolve/main/app.py
- Command line
-
hf download hf://spaces/hyperpixel123/hyperpixel_1.0/app.py
-
curl -L -o app.py https://huggingface.co/spaces/hyperpixel123/hyperpixel_1.0/resolve/main/app.py
841 Bytes
| from gradio import Interface | |
| from llama_cpp import Llama | |
| # Load your model | |
| model_path = "models/blobs/sha256-2bada8a7450677000f678be90653b85d364de7db25eb5ea54136ada5f3933730" # Upload your model file to the Space | |
| llm = Llama(model_path=model_path, n_ctx=4096, verbose=False) | |
| def generate(system_prompt, messages): | |
| """Generate response from the model""" | |
| full_messages = [{"role": "system", "content": system_prompt}] | |
| for msg in messages: | |
| full_messages.append({"role": "user", "content": msg}) | |
| response = llm.create_chat_completion( | |
| messages=full_messages, | |
| temperature=0.7, | |
| max_tokens=1024 | |
| ) | |
| return response["choices"][0]["message"]["content"] | |
| iface = Interface( | |
| fn=generate, | |
| inputs=["text", "text"], | |
| outputs="text", | |
| title="Hyperpixel AI Model" | |
| ) | |
| iface.launch() |