|
@@ -23,7 +23,11 @@ from applications.utils.chat import RAGChatAgent
|
|
|
from applications.utils.mysql import Dataset, Contents, ContentChunks, ChatResult, Books
|
|
from applications.utils.mysql import Dataset, Contents, ContentChunks, ChatResult, Books
|
|
|
from applications.api.qwen import QwenClient
|
|
from applications.api.qwen import QwenClient
|
|
|
from applications.utils.oss.oss_client import OSSClient
|
|
from applications.utils.oss.oss_client import OSSClient
|
|
|
-from applications.utils.task.async_task import handle_books, process_question, query_search
|
|
|
|
|
|
|
+from applications.utils.task.async_task import (
|
|
|
|
|
+ handle_books,
|
|
|
|
|
+ process_question,
|
|
|
|
|
+ query_search,
|
|
|
|
|
+)
|
|
|
|
|
|
|
|
server_bp = Blueprint("api", __name__, url_prefix="/api")
|
|
server_bp = Blueprint("api", __name__, url_prefix="/api")
|
|
|
server_bp = cors(server_bp, allow_origin="*")
|
|
server_bp = cors(server_bp, allow_origin="*")
|
|
@@ -481,7 +485,6 @@ async def rag_search():
|
|
|
return jsonify({"status_code": 200, "detail": "success", "data": data_list})
|
|
return jsonify({"status_code": 200, "detail": "success", "data": data_list})
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
@server_bp.route("/chat/history", methods=["GET"])
|
|
@server_bp.route("/chat/history", methods=["GET"])
|
|
|
async def chat_history():
|
|
async def chat_history():
|
|
|
page_num = int(request.args.get("page", 1))
|
|
page_num = int(request.args.get("page", 1))
|
|
@@ -525,7 +528,6 @@ async def upload_pdf():
|
|
|
|
|
|
|
|
# 获取文件名
|
|
# 获取文件名
|
|
|
filename = file.filename
|
|
filename = file.filename
|
|
|
- print(filename)
|
|
|
|
|
|
|
|
|
|
book_id = f"book-{uuid.uuid4()}"
|
|
book_id = f"book-{uuid.uuid4()}"
|
|
|
# 检查文件的 MIME 类型是否是 application/pdf
|
|
# 检查文件的 MIME 类型是否是 application/pdf
|
|
@@ -549,17 +551,12 @@ async def upload_pdf():
|
|
|
oss_path = f"rag/pdfs/{book_id}"
|
|
oss_path = f"rag/pdfs/{book_id}"
|
|
|
oss_client.upload_file(file_path, oss_path)
|
|
oss_client.upload_file(file_path, oss_path)
|
|
|
await books.insert_book(book_id, filename, oss_path)
|
|
await books.insert_book(book_id, filename, oss_path)
|
|
|
- # os.remove(file_path)
|
|
|
|
|
- return jsonify(
|
|
|
|
|
- {
|
|
|
|
|
- "status": "success",
|
|
|
|
|
- "message": f"File {filename} uploaded successfully to OSS!",
|
|
|
|
|
- }
|
|
|
|
|
- ), 200
|
|
|
|
|
|
|
+ return jsonify({"status_code": 200, "detail": "success"})
|
|
|
except Exception as e:
|
|
except Exception as e:
|
|
|
- return jsonify({"status": "error", "message": str(e)}), 500
|
|
|
|
|
|
|
+ return jsonify({"status_code": 500, "detail": str(e)})
|
|
|
|
|
+
|
|
|
else:
|
|
else:
|
|
|
- return jsonify({"status": "error", "message": "No file uploaded."}), 400
|
|
|
|
|
|
|
+ return jsonify({"status_code": 400, "detail": "No file uploaded."})
|
|
|
|
|
|
|
|
|
|
|
|
|
@server_bp.route("/process/book", methods=["GET"])
|
|
@server_bp.route("/process/book", methods=["GET"])
|