cortex.6.sol / cortex_ai /api /serve.py
asdfasdfqrqwer's picture
feat(cortex-ai): agent engine, tool registry, OpenAI-compatible API, fine-tuning pipeline
c63bc31
Raw History Blame Contribute Delete
843 Bytes
"""Run the CORTEX AI API server.
python -m cortex_ai.api.serve
Uses the mock adapter by default so the server starts on any machine. Set
CORTEX_ADAPTER=hf to load the real checkpoint instead.
"""
from __future__ import annotations
import os
from .server import create_app
from ..adapters.mock import MockAdapter
from ..config import CortexConfig
def build_adapter(config: CortexConfig):
kind = os.getenv("CORTEX_ADAPTER", "mock").lower()
if kind == "hf":
from ..adapters.hf_adapter import HFAdapter
return HFAdapter(config.model_id).load()
return MockAdapter()
def main() -> None:
import uvicorn
config = CortexConfig.from_env()
app = create_app(build_adapter(config), config)
uvicorn.run(app, host=config.server.host, port=config.server.port)
if __name__ == "__main__":
main()