Skip to content

Commit

Permalink
RAGチャット2回目以降の文書不正対応 (#601) (#782)
Browse files Browse the repository at this point in the history
Co-authored-by: h.komori <h.komori@jast.co.jp>
  • Loading branch information
ttrdthsffr and h.komori authored Dec 18, 2024
1 parent 5780ff0 commit 4c7207d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
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

0 comments on commit 4c7207d

Please sign in to comment.