Download llama.cpp/examples/server/tests/unit/test_lora.py from Mat17892/iris: direct link, hf CLI and curl.
- Browser
- Download file 1.45 kB
-
https://huggingface.co/spaces/Mat17892/iris/resolve/main/llama.cpp/examples/server/tests/unit/test_lora.py
- Command line
-
hf download hf://spaces/Mat17892/iris/llama.cpp/examples/server/tests/unit/test_lora.py
-
curl -L -o test_lora.py https://huggingface.co/spaces/Mat17892/iris/resolve/main/llama.cpp/examples/server/tests/unit/test_lora.py
1.45 kB
| import pytest | |
| import os | |
| from utils import * | |
| server = ServerPreset.stories15m_moe() | |
| LORA_FILE_URL = "https://huggingface.co/ggml-org/stories15M_MOE/resolve/main/moe_shakespeare15M.gguf" | |
| def create_server(): | |
| global server | |
| server = ServerPreset.stories15m_moe() | |
| # download lora file if needed | |
| file_name = LORA_FILE_URL.split('/').pop() | |
| lora_file = f'../../../{file_name}' | |
| if not os.path.exists(lora_file): | |
| print(f"Downloading {LORA_FILE_URL} to {lora_file}") | |
| with open(lora_file, 'wb') as f: | |
| f.write(requests.get(LORA_FILE_URL).content) | |
| print(f"Done downloading lora file") | |
| server.lora_files = [lora_file] | |
| def test_lora(scale: float, re_content: str): | |
| global server | |
| server.start() | |
| res_lora_control = server.make_request("POST", "/lora-adapters", data=[ | |
| {"id": 0, "scale": scale} | |
| ]) | |
| assert res_lora_control.status_code == 200 | |
| res = server.make_request("POST", "/completion", data={ | |
| "prompt": "Look in thy glass", | |
| }) | |
| assert res.status_code == 200 | |
| assert match_regex(re_content, res.body["content"]) | |