2023-04-05 16:23:25 -04:00
|
|
|
"""Example FastAPI server for llama.cpp.
|
|
|
|
|
|
|
|
To run this example:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
pip install fastapi uvicorn sse-starlette
|
|
|
|
export MODEL=../models/7B/...
|
|
|
|
```
|
|
|
|
|
2023-04-28 22:43:37 -07:00
|
|
|
Then run:
|
|
|
|
```
|
|
|
|
uvicorn llama_cpp.server.app:app --reload
|
|
|
|
```
|
2023-04-05 16:23:25 -04:00
|
|
|
|
2023-04-28 22:43:37 -07:00
|
|
|
or
|
2023-04-05 16:23:25 -04:00
|
|
|
|
2023-04-28 22:43:37 -07:00
|
|
|
```
|
|
|
|
python3 -m llama_cpp.server
|
|
|
|
```
|
2023-04-05 16:23:25 -04:00
|
|
|
|
2023-04-28 22:43:37 -07:00
|
|
|
Then visit http://localhost:8000/docs to see the interactive API docs.
|
2023-04-05 16:23:25 -04:00
|
|
|
|
2023-04-28 22:43:37 -07:00
|
|
|
"""
|
|
|
|
import os
|
|
|
|
import uvicorn
|
2023-04-05 16:23:25 -04:00
|
|
|
|
2023-05-01 22:38:46 -04:00
|
|
|
from llama_cpp.server.app import create_app
|
2023-04-05 16:23:25 -04:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2023-05-01 22:38:46 -04:00
|
|
|
app = create_app()
|
2023-04-05 16:23:25 -04:00
|
|
|
|
2023-04-06 21:07:35 -04:00
|
|
|
uvicorn.run(
|
|
|
|
app, host=os.getenv("HOST", "localhost"), port=int(os.getenv("PORT", 8000))
|
|
|
|
)
|