Spaces:
Sleeping
Sleeping
more tweaks
Browse files- .gitignore +2 -1
- api.py +10 -1
- schema.py +5 -2
.gitignore
CHANGED
|
@@ -1 +1,2 @@
|
|
| 1 |
-
test**.py
|
|
|
|
|
|
| 1 |
+
test**.py
|
| 2 |
+
__pycache__
|
api.py
CHANGED
|
@@ -1,16 +1,25 @@
|
|
| 1 |
from fastapi.responses import StreamingResponse
|
| 2 |
from fastapi import FastAPI, HTTPException
|
|
|
|
| 3 |
|
| 4 |
from llm_backend import chat_with_model
|
| 5 |
from schema import ChatRequest
|
| 6 |
|
| 7 |
"""
|
| 8 |
-
uvicorn api:app --reload
|
| 9 |
fastapi dev api.py --port 5723
|
| 10 |
"""
|
| 11 |
|
| 12 |
app = FastAPI()
|
| 13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
@app.post("/chat_stream")
|
| 16 |
def chat_stream(request: ChatRequest):
|
|
|
|
| 1 |
from fastapi.responses import StreamingResponse
|
| 2 |
from fastapi import FastAPI, HTTPException
|
| 3 |
+
import logging
|
| 4 |
|
| 5 |
from llm_backend import chat_with_model
|
| 6 |
from schema import ChatRequest
|
| 7 |
|
| 8 |
"""
|
| 9 |
+
uvicorn api:app --reload --port 5723
|
| 10 |
fastapi dev api.py --port 5723
|
| 11 |
"""
|
| 12 |
|
| 13 |
app = FastAPI()
|
| 14 |
|
| 15 |
+
logger = logging.getLogger("uvicorn.error")
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
@app.get("/")
|
| 19 |
+
def index():
|
| 20 |
+
logger.info("this is a debug message")
|
| 21 |
+
return {"hello": "world"}
|
| 22 |
+
|
| 23 |
|
| 24 |
@app.post("/chat_stream")
|
| 25 |
def chat_stream(request: ChatRequest):
|
schema.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
from pydantic import BaseModel
|
| 2 |
from huggingface_hub import hf_hub_download
|
| 3 |
|
|
|
|
| 4 |
from typing import (
|
| 5 |
List,
|
| 6 |
Optional,
|
|
@@ -22,8 +23,10 @@ MODEL_ARGS = {
|
|
| 22 |
),
|
| 23 |
}
|
| 24 |
|
| 25 |
-
|
| 26 |
-
|
|
|
|
|
|
|
| 27 |
|
| 28 |
|
| 29 |
class Message(BaseModel):
|
|
|
|
| 1 |
from pydantic import BaseModel
|
| 2 |
from huggingface_hub import hf_hub_download
|
| 3 |
|
| 4 |
+
import logging
|
| 5 |
from typing import (
|
| 6 |
List,
|
| 7 |
Optional,
|
|
|
|
| 23 |
),
|
| 24 |
}
|
| 25 |
|
| 26 |
+
logger = logging.getLogger("uvicorn.error")
|
| 27 |
+
for model_arg in MODEL_ARGS.values():
|
| 28 |
+
logger.info("this is a debug message")
|
| 29 |
+
hf_hub_download(**model_arg)
|
| 30 |
|
| 31 |
|
| 32 |
class Message(BaseModel):
|