fix: don't drop earlier user messages with same content from chat history
The filter was meant to skip the message just pushed by the caller, but it matches by content, so a repeated message like "tell me more" also removes the previous turn from the history sent to the backend.
This commit is contained in:
parent
fa0f6519b1
commit
442d5fd6cf
|
|
@ -684,7 +684,7 @@ const sendToReportAgent = async (message) => {
|
||||||
|
|
||||||
// Build chat history for API
|
// Build chat history for API
|
||||||
const historyForApi = chatHistory.value
|
const historyForApi = chatHistory.value
|
||||||
.filter(msg => msg.role !== 'user' || msg.content !== message)
|
.slice(0, -1)
|
||||||
.slice(-10) // Keep last 10 messages
|
.slice(-10) // Keep last 10 messages
|
||||||
.map(msg => ({
|
.map(msg => ({
|
||||||
role: msg.role,
|
role: msg.role,
|
||||||
|
|
@ -720,7 +720,7 @@ const sendToAgent = async (message) => {
|
||||||
let prompt = message
|
let prompt = message
|
||||||
if (chatHistory.value.length > 1) {
|
if (chatHistory.value.length > 1) {
|
||||||
const historyContext = chatHistory.value
|
const historyContext = chatHistory.value
|
||||||
.filter(msg => msg.content !== message)
|
.slice(0, -1)
|
||||||
.slice(-6)
|
.slice(-6)
|
||||||
.map(msg => `${msg.role === 'user' ? '提问者' : '你'}:${msg.content}`)
|
.map(msg => `${msg.role === 'user' ? '提问者' : '你'}:${msg.content}`)
|
||||||
.join('\n')
|
.join('\n')
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue