|
|
|
@ -1,9 +1,6 @@
|
|
|
|
|
import asyncio
|
|
|
|
|
import json
|
|
|
|
|
<<<<<<< HEAD
|
|
|
|
|
=======
|
|
|
|
|
import os.path
|
|
|
|
|
>>>>>>> 66c0614648a1e8f5f7b9274bdb7218f082104b24
|
|
|
|
|
import subprocess
|
|
|
|
|
import tempfile
|
|
|
|
|
import urllib
|
|
|
|
@ -21,20 +18,9 @@ from starlette.staticfiles import StaticFiles
|
|
|
|
|
from Util.LightRagUtil import *
|
|
|
|
|
from Util.PostgreSQLUtil import init_postgres_pool
|
|
|
|
|
|
|
|
|
|
<<<<<<< HEAD
|
|
|
|
|
# 在程序开始时添加以下配置
|
|
|
|
|
logging.basicConfig(
|
|
|
|
|
level=logging.INFO, # 设置日志级别为INFO
|
|
|
|
|
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# 或者如果你想更详细地控制日志输出
|
|
|
|
|
=======
|
|
|
|
|
rag_instances = {}
|
|
|
|
|
rag_lock = asyncio.Lock()
|
|
|
|
|
|
|
|
|
|
# 想更详细地控制日志输出
|
|
|
|
|
>>>>>>> 66c0614648a1e8f5f7b9274bdb7218f082104b24
|
|
|
|
|
logger = logging.getLogger('lightrag')
|
|
|
|
|
logger.setLevel(logging.DEBUG)
|
|
|
|
|
handler = logging.StreamHandler()
|
|
|
|
@ -65,12 +51,10 @@ app.mount("/static", StaticFiles(directory="Static"), name="static")
|
|
|
|
|
async def rag(request: fastapi.Request):
|
|
|
|
|
data = await request.json()
|
|
|
|
|
topic = data.get("topic") # Chinese, Math
|
|
|
|
|
mode = data.get("mode", "hybrid") # 默认为hybrid模式
|
|
|
|
|
# 拼接路径
|
|
|
|
|
WORKING_PATH = "./Topic/" + topic
|
|
|
|
|
# 查询的问题
|
|
|
|
|
query = data.get("query")
|
|
|
|
|
<<<<<<< HEAD
|
|
|
|
|
# 关闭参考资料
|
|
|
|
|
user_prompt = "\n 1、不要输出参考资料 或者 References !"
|
|
|
|
|
user_prompt = user_prompt + "\n 2、资料中提供化学反应方程式的,一定要严格按提供的Latex公式输出,绝对不允许对Latex公式进行修改 !"
|
|
|
|
|