13.08.2026 налажена работа с ИИ. Подготовка к разбивке файлов agent и db_tools
This commit is contained in:
@@ -104,28 +104,6 @@ async def favicon():
|
||||
return FileResponse(file_path)
|
||||
raise HTTPException(status_code=404)
|
||||
|
||||
@app.get("/{file_path:path}")
|
||||
def serve_static_fallback(file_path: str):
|
||||
clean_path = file_path.lstrip("/")
|
||||
|
||||
# Игнорируем сканеры WordPress / PHP
|
||||
if any(clean_path.startswith(prefix) for prefix in ["wp-", "wordpress", "php", "cms", "shop"]):
|
||||
raise HTTPException(status_code=404, detail="Not Found")
|
||||
|
||||
target = os.path.join("static", clean_path)
|
||||
if os.path.isfile(target):
|
||||
return FileResponse(target)
|
||||
|
||||
filename = os.path.basename(clean_path)
|
||||
target_js = os.path.join("static/js", filename)
|
||||
if filename.endswith(".js") and os.path.isfile(target_js):
|
||||
return FileResponse(target_js, media_type="application/javascript")
|
||||
|
||||
target_css = os.path.join("static/css", filename)
|
||||
if filename.endswith(".css") and os.path.isfile(target_css):
|
||||
return FileResponse(target_css, media_type="text/css")
|
||||
|
||||
raise HTTPException(status_code=404, detail="File not found")
|
||||
|
||||
@app.post("/api/v1/auth/login")
|
||||
def login(req: AuthRequest):
|
||||
@@ -245,37 +223,36 @@ async def chat_endpoint(
|
||||
file: Optional[UploadFile] = File(default=None),
|
||||
current_user: dict = Depends(get_current_user)
|
||||
):
|
||||
logging.info(f"=== [CHAT API] Входящий запрос от user_id={current_user['id']}, file={file.filename if file else 'None'} ===")
|
||||
file_content_text = ""
|
||||
parsed_file = {"text": "", "image_b64": None}
|
||||
if file and file.filename:
|
||||
file_bytes = await file.read()
|
||||
file_content_text = extract_text_from_file(file_bytes, file.filename)
|
||||
parsed_file = extract_text_from_file(file_bytes, file.filename)
|
||||
|
||||
reply, history = process_chat_message(
|
||||
user_id=current_user["id"],
|
||||
user_message=message,
|
||||
file_context=file_content_text,
|
||||
file_context=parsed_file["text"],
|
||||
image_b64=parsed_file["image_b64"],
|
||||
session_id=session_id
|
||||
)
|
||||
return {"reply": reply, "history": history}
|
||||
|
||||
# ЕДИНЫЙ ГОСТЕВОЙ ЧАТ (FormData + Файлы)
|
||||
@app.post("/api/v1/chat/guest")
|
||||
async def guest_chat_endpoint(
|
||||
session_id: str = Form("web_session_main"),
|
||||
message: str = Form(""),
|
||||
file: Optional[UploadFile] = File(default=None)
|
||||
):
|
||||
logging.info(f"=== [GUEST CHAT API] Входящий запрос, file={file.filename if file else 'None'} ===")
|
||||
file_content_text = ""
|
||||
parsed_file = {"text": "", "image_b64": None}
|
||||
if file and file.filename:
|
||||
file_bytes = await file.read()
|
||||
file_content_text = extract_text_from_file(file_bytes, file.filename)
|
||||
parsed_file = extract_text_from_file(file_bytes, file.filename)
|
||||
|
||||
reply, history = process_chat_message(
|
||||
user_id=0,
|
||||
user_message=message,
|
||||
file_context=file_content_text,
|
||||
file_context=parsed_file["text"],
|
||||
image_b64=parsed_file["image_b64"],
|
||||
session_id=session_id
|
||||
)
|
||||
return {"reply": reply, "history": history}
|
||||
@@ -299,4 +276,4 @@ def serve_static_fallback(file_path: str):
|
||||
if filename.endswith(".css") and os.path.isfile(target_css):
|
||||
return FileResponse(target_css, media_type="text/css")
|
||||
|
||||
raise HTTPException(status_code=404, detail="File not found")
|
||||
raise HTTPException(status_code=404, detail="File not found")
|
||||
|
||||
Reference in New Issue
Block a user