main
HuangHai 2 weeks ago
parent 3b31f77575
commit 0e5bacf35b

@ -43,6 +43,7 @@ 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
# 查询的问题
@ -67,7 +68,7 @@ async def rag(request: fastapi.Request):
await initialize_pipeline_status()
resp = await rag.aquery(
query=query,
param=QueryParam(mode="hybrid", stream=True, user_prompt=user_prompt))
param=QueryParam(mode=mode, stream=True, user_prompt=user_prompt))
# hybrid naive
async for chunk in resp:

@ -232,6 +232,20 @@
</div>
</div>
<div class="mode-selection">
<h3>回答模式</h3>
<div class="mode-checkboxes">
<label>
<input type="radio" name="mode" value="hybrid" checked>
深度思考
</label>
<label>
<input type="radio" name="mode" value="naive">
快速回答
</label>
</div>
</div>
<br>
<button id="submitBtn" onclick="submitQuestion()"><span class="icon">💡</span>提问</button>
<button id="clearBtn" onclick="clearAll()"><span class="icon">🗑️</span>清空</button>
</div>
@ -293,6 +307,7 @@
const question = document.getElementById('questionInput').value.trim();
const answerArea = document.getElementById('answerArea');
const topic = document.querySelector('input[name="topic"]:checked').value;
const mode = document.querySelector('input[name="mode"]:checked').value;
if (!question) {
alert('请输入问题!');
@ -310,7 +325,8 @@
},
body: JSON.stringify({
query: question,
topic: topic
topic: topic,
mode: mode
})
})
.then(response => {

Loading…
Cancel
Save