|
|
|
@ -183,18 +183,6 @@ async def generate_stream(client, es_pool, collection_manager, query, documents)
|
|
|
|
|
logger.info("Elasticsearch连接已释放")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
http://10.10.21.22:8000/static/ai.html
|
|
|
|
|
|
|
|
|
|
知识库中有的内容:
|
|
|
|
|
小学数学中有哪些模型?
|
|
|
|
|
帮我写一下 “如何理解点、线、面、体、角”的教学设计
|
|
|
|
|
|
|
|
|
|
知识库中没有的内容:
|
|
|
|
|
你知道黄海是谁吗?
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class QueryRequest(BaseModel):
|
|
|
|
|
query: str = Field(..., description="用户查询的问题")
|
|
|
|
|
documents: List[str] = Field(..., description="用户上传的文档")
|
|
|
|
@ -225,7 +213,7 @@ async def save_to_word(request: Request):
|
|
|
|
|
f.write(html_content)
|
|
|
|
|
|
|
|
|
|
# 使用pandoc转换
|
|
|
|
|
output_file = os.path.join(tempfile.gettempdir(), "小学数学问答.docx")
|
|
|
|
|
output_file = os.path.join(tempfile.gettempdir(), "理想大模型问答.docx")
|
|
|
|
|
subprocess.run(['pandoc', temp_html, '-o', output_file], check=True)
|
|
|
|
|
|
|
|
|
|
# 读取生成的Word文件
|
|
|
|
@ -233,7 +221,7 @@ async def save_to_word(request: Request):
|
|
|
|
|
stream = BytesIO(f.read())
|
|
|
|
|
|
|
|
|
|
# 返回响应
|
|
|
|
|
encoded_filename = urllib.parse.quote("小学数学问答.docx")
|
|
|
|
|
encoded_filename = urllib.parse.quote("理想大模型问答.docx")
|
|
|
|
|
return StreamingResponse(
|
|
|
|
|
stream,
|
|
|
|
|
media_type="application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
|
|
|