Initial commit: LocalPilot:本地模型运行时,复用 llama-server 并提供 Ollama 兼容 provider
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import json
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
from localpilot.config import AppConfig, ModelConfig, infer_kind, load_config
|
||||
|
||||
|
||||
class ConfigTests(unittest.TestCase):
|
||||
def test_infer_extensions(self) -> None:
|
||||
self.assertEqual(infer_kind(ModelConfig(id="x", path="E:/x/model.gguf")), "gguf")
|
||||
self.assertEqual(infer_kind(ModelConfig(id="x", path="E:/x/model.onnx")), "onnx")
|
||||
self.assertEqual(infer_kind(ModelConfig(id="x", kind="cloud")), "cloud")
|
||||
|
||||
def test_load_config(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as folder:
|
||||
path = Path(folder) / "config.json"
|
||||
path.write_text(json.dumps({"models": [{"id": "x", "kind": "gguf", "path": "x.gguf"}]}), encoding="utf-8")
|
||||
config = load_config(path)
|
||||
self.assertIsInstance(config, AppConfig)
|
||||
self.assertEqual(config.models[0].id, "x")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user