This commit is contained in:
2026-03-29 16:19:26 +08:00
parent 289145e901
commit 56a5c2e4c0
7 changed files with 19 additions and 23 deletions
+3
View File
@@ -22,6 +22,9 @@ class InferenceEngine:
revision=settings.revision,
)
def close(self) -> None:
return None
def generate(self, req: GenerateRequest) -> GenerateResponse:
sampling_params = SamplingParams(
temperature=req.temperature,
+2
View File
@@ -25,6 +25,8 @@ async def lifespan(_: FastAPI):
settings = get_settings()
engine = InferenceEngine(settings)
yield
if engine is not None:
engine.close()
engine = None
+6 -5
View File
@@ -43,11 +43,12 @@ def _resolve_profile_model_path(profile: dict[str, Any], model_root: str, model_
raise ValueError(f"model profile '{model_key}' must provide local_path")
if "://" in local_path:
raise ValueError(f"model profile '{model_key}' local_path must be local filesystem path")
if local_path.startswith("/"):
return local_path
if not model_root:
raise ValueError("config.json model_root cannot be empty when local_path is relative")
return _join_posix(model_root, local_path)
resolved = local_path
if not local_path.startswith("/"):
if not model_root:
raise ValueError("config.json model_root cannot be empty when local_path is relative")
resolved = _join_posix(model_root, local_path)
return resolved
def load_catalog(catalog_path: str = "config.json") -> dict[str, Any]:
+1 -1
View File
@@ -18,9 +18,9 @@ def build_command() -> list[str]:
os.environ[key] = value
host = str(runtime["openai_host"])
port = str(runtime["openai_port"])
api_key = runtime["api_key"] or ""
dtype = str(runtime["dtype"])
revision = runtime["revision"] or ""
api_key = runtime["api_key"] or ""
cmd = [
sys.executable,
"-m",