mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-16 03:47:49 +01:00
Migrate to python logging module with env var control.
This commit is contained in:
@@ -4,6 +4,7 @@ import markdown
|
||||
import time
|
||||
import os
|
||||
import sys
|
||||
import logging
|
||||
import requests
|
||||
|
||||
from fastapi import FastAPI, Request, Depends, status
|
||||
@@ -38,9 +39,14 @@ from config import (
|
||||
FRONTEND_BUILD_DIR,
|
||||
MODEL_FILTER_ENABLED,
|
||||
MODEL_FILTER_LIST,
|
||||
GLOBAL_LOG_LEVEL,
|
||||
SRC_LOG_LEVELS,
|
||||
)
|
||||
from constants import ERROR_MESSAGES
|
||||
|
||||
logging.basicConfig(stream=sys.stdout, level=GLOBAL_LOG_LEVEL)
|
||||
log = logging.getLogger(__name__)
|
||||
log.setLevel(SRC_LOG_LEVELS["MAIN"])
|
||||
|
||||
class SPAStaticFiles(StaticFiles):
|
||||
async def get_response(self, path: str, scope):
|
||||
@@ -66,7 +72,7 @@ class RAGMiddleware(BaseHTTPMiddleware):
|
||||
if request.method == "POST" and (
|
||||
"/api/chat" in request.url.path or "/chat/completions" in request.url.path
|
||||
):
|
||||
print(request.url.path)
|
||||
log.debug(f"request.url.path: {request.url.path}")
|
||||
|
||||
# Read the original request body
|
||||
body = await request.body()
|
||||
@@ -89,7 +95,7 @@ class RAGMiddleware(BaseHTTPMiddleware):
|
||||
)
|
||||
del data["docs"]
|
||||
|
||||
print(data["messages"])
|
||||
log.debug(f"data['messages']: {data['messages']}")
|
||||
|
||||
modified_body_bytes = json.dumps(data).encode("utf-8")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user