llama_cpp server: slight refactor to init_llama function

Define an init_llama function that starts llama with supplied settings instead of just doing it in the global context of app.py

This allows the test to be less brittle by not needing to mess with os.environ, then importing the app
This commit is contained in:
Lucas Doyle
2023-04-28 23:47:36 -07:00
parent 6d8db9d017
commit efe8e6f879
3 changed files with 31 additions and 26 deletions

View File

@@ -132,10 +132,11 @@ def test_utf8(monkeypatch):
def test_llama_server():
from fastapi.testclient import TestClient
import os
os.environ["MODEL"] = MODEL
os.environ["VOCAB_ONLY"] = "true"
from llama_cpp.server.app import app
from llama_cpp.server.app import app, init_llama, Settings
s = Settings()
s.model = MODEL
s.vocab_only = True
init_llama(s)
client = TestClient(app)
response = client.get("/v1/models")
assert response.json() == {