Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RAGチャット2回目以降の文書不正対応 (#601) #782

Merged
merged 1 commit into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/web/src/hooks/useRag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,10 @@ const useRag = (id: string) => {
// 前処理:Few-shot で参考にされてしまうため、過去ログから footnote を削除
return messages.map((message) => ({
...message,
content: message.content.replace(/\[\^(\d+)\]:.*/g, ''),
content: message.content
.replace(/\[\^0\]:[\s\S]*/s, '') // 文末の脚注を削除
.replace(/\[\^(\d+)\]/g, '') // 文中の脚注アンカーを削除
.trim(), // 前後の空白を削除
}));
},
(message: string) => {
Expand Down
5 changes: 4 additions & 1 deletion packages/web/src/hooks/useRagKnowledgeBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,10 @@ const useRagKnowledgeBase = (id: string) => {
// 前処理:Few-shot で参考にされてしまうため、過去ログから footnote を削除
return messages.map((message) => ({
...message,
content: message.content.replace(/\[\^(\d+)\]:.*/g, ''),
content: message.content
.replace(/\[\^0\]:[\s\S]*/s, '') // 文末の脚注を削除
.replace(/\[\^(\d+)\]/g, '') // 文中の脚注アンカーを削除
.trim(), // 前後の空白を削除
}));
},
(message: string) => {
Expand Down
Loading