Commit
·
2cc08e0
1
Parent(s):
d1b15a7
� 修复预设system prompt显示在聊记录中的问题
Browse files❌ 问题描述:
- 选择Quick Presets时,system prompt会作为Assistant消息显示在聊天窗口
- 用户不希望看到system prompt在聊天记录中
� 解决方案:
- 移除将system prompt添加到聊天记录的逻辑
- System prompt现在只通过API的system_prompt参数传递
- 聊天界面不再显示系统提示消息
✅ 修复效果:
- 选择预设后,system prompt不会在聊天窗口显示
- System prompt仍然正常工作,影响AI回复行为
- 聊天记录更加干净,只显示用户和AI的对话
- 保持向后兼容性,过滤历史会话中的系统消息
� 用户体验改善:
- 更清洁的聊天界面
- 系统提示静默生效,不干扰对话流程
- frontend/src/hooks/useChat.ts +1 -14
- static/assets/index-55ba4284.js +0 -0
- static/assets/index-55ba4284.js.map +0 -0
- static/index.html +1 -1
frontend/src/hooks/useChat.ts
CHANGED
|
@@ -152,20 +152,7 @@ export function useChat(options: UseChatOptions = {}) {
|
|
| 152 |
setSessions([...updatedSessions]) // Create new array reference to force re-render
|
| 153 |
}
|
| 154 |
|
| 155 |
-
//
|
| 156 |
-
// Check actual session messages from storage, not React state
|
| 157 |
-
const actualSession = chatStorage.getSession(sessionId!)
|
| 158 |
-
const hasMessages = actualSession?.messages && actualSession.messages.length > 1 // >1 because user message was just added
|
| 159 |
-
|
| 160 |
-
if (systemPrompt && !hasMessages && sessionId) {
|
| 161 |
-
chatStorage.addMessageToSession(sessionId, {
|
| 162 |
-
role: 'system',
|
| 163 |
-
content: systemPrompt
|
| 164 |
-
})
|
| 165 |
-
// Force update sessions state with fresh data
|
| 166 |
-
const updatedSessions = chatStorage.getAllSessions()
|
| 167 |
-
setSessions([...updatedSessions]) // Create new array reference to force re-render
|
| 168 |
-
}
|
| 169 |
|
| 170 |
try {
|
| 171 |
// Get conversation history (excluding system messages for the API)
|
|
|
|
| 152 |
setSessions([...updatedSessions]) // Create new array reference to force re-render
|
| 153 |
}
|
| 154 |
|
| 155 |
+
// System prompt is handled via API parameter, not as a chat message
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 156 |
|
| 157 |
try {
|
| 158 |
// Get conversation history (excluding system messages for the API)
|
static/assets/index-55ba4284.js
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
static/assets/index-55ba4284.js.map
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
static/index.html
CHANGED
|
@@ -5,7 +5,7 @@
|
|
| 5 |
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
| 6 |
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
| 7 |
<title>Edge LLM</title>
|
| 8 |
-
<script type="module" crossorigin src="/assets/index-
|
| 9 |
<link rel="stylesheet" href="/assets/index-c748e53d.css">
|
| 10 |
</head>
|
| 11 |
<body>
|
|
|
|
| 5 |
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
| 6 |
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
| 7 |
<title>Edge LLM</title>
|
| 8 |
+
<script type="module" crossorigin src="/assets/index-55ba4284.js"></script>
|
| 9 |
<link rel="stylesheet" href="/assets/index-c748e53d.css">
|
| 10 |
</head>
|
| 11 |
<body>
|