|
|
|
@ -61,8 +61,9 @@ async def rag(request: fastapi.Request):
|
|
|
|
|
if output_model == "txt":
|
|
|
|
|
user_prompt = "1、如果资料中提供了图片的,一定要严格按照原文提供图片输出,绝对不能省略或不输出!"
|
|
|
|
|
user_prompt = user_prompt + "\n 2、不要提供引用信息!"
|
|
|
|
|
user_prompt = user_prompt + "\n 3、提供给你的材料中,与问题完全相关的需要完整保留!"
|
|
|
|
|
user_prompt = user_prompt + "\n 4、提供给你的材料中,与问题不完全相关的一定不要输出!"
|
|
|
|
|
user_prompt = user_prompt + "\n 3、依据提供的材料,判断是否与问题强相关,强相关的可以适当发挥!"
|
|
|
|
|
#user_prompt = user_prompt + "\n 3、提供给你的材料中,与问题完全相关的需要完整保留!"
|
|
|
|
|
#user_prompt = user_prompt + "\n 4、提供给你的材料中,与问题不完全相关的一定不要输出!"
|
|
|
|
|
user_prompt = user_prompt + "\n 5、资料中提供化学反应方程式的,一定要严格按提供的Latex公式输出,绝对不允许对Latex公式进行修改 !"
|
|
|
|
|
user_prompt = user_prompt + "\n 6、发现输出内容中包含Latex公式的,一定要检查是不是包含了$$或$的包含符号,不能让Latex无包含符号出现!"
|
|
|
|
|
elif output_model == 'html':
|
|
|
|
@ -106,7 +107,7 @@ async def rag(request: fastapi.Request):
|
|
|
|
|
|
|
|
|
|
# 使用PG库后,这个是没有用的,但目前的项目代码要求必传,就写一个吧。
|
|
|
|
|
WORKING_DIR = './output/'
|
|
|
|
|
async def generate_response_stream(query: str):
|
|
|
|
|
async def generate_response_stream(query: str, workspace: str):
|
|
|
|
|
try:
|
|
|
|
|
logger.info("workspace=" + workspace)
|
|
|
|
|
# 使用锁确保线程安全
|
|
|
|
@ -128,7 +129,7 @@ async def rag(request: fastapi.Request):
|
|
|
|
|
# 发送流结束标记
|
|
|
|
|
yield "data: [DONE]\n\n"
|
|
|
|
|
|
|
|
|
|
return EventSourceResponse(generate_response_stream(query=query))
|
|
|
|
|
return EventSourceResponse(generate_response_stream(query=query, workspace=workspace))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.post("/api/save-word")
|
|
|
|
|