Skip to content

RAGチャット(Knowledge Base)の回答時の挙動の制御 #936

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

Open
ogis-ando-m opened this issue Mar 12, 2025 · 2 comments
Open
Labels
enhancement New feature or request stale Issues or Pull Requests with no updates

Comments

@ogis-ando-m
Copy link

機能リクエストは何か問題に関連していますか?背景を説明してください
RAGチャット(Knowledge Base)利用時に、該当のドキュメントがなかった場合に「Sorry, I am unable to assist you with this request.」という回答が来ることがあるので、「該当のドキュメントはありませんでした」のような回答にしたいです

追加 or 改善したい機能について
RAGチャット(Knowledge Base)で該当ドキュメントがなかった場合の回答の挙動を制御(変更)することは可能でしょうか?
例えば、RAGチャット(Knowledge Base)利用時のシステムプロンプト(プロンプトテンプレート)をカスタマイズできればよさそうですが、いかがでしょうか?

@ogis-ando-m ogis-ando-m added the enhancement New feature or request label Mar 12, 2025
@ogis-ando-m
Copy link
Author

RAGチャット(Knowledge Base)で回答生成時に使用されるプロンプトは、
packages/web/src/prompts/claude.ts
の204~244行目へ記載されている以下の内容で仕様はあっていますでしょうか?

`あなたはユーザの質問に答えるAIアシスタントです。
以下の手順でユーザの質問に答えてください。手順以外のことは絶対にしないでください。

<回答手順>
* <参考ドキュメント></参考ドキュメント>に回答の参考となるドキュメントを設定しているので、それを全て理解してください。なお、この<参考ドキュメント></参考ドキュメント>は<参考ドキュメントのJSON形式></参考ドキュメントのJSON形式>のフォーマットで設定されています。
* <回答のルール></回答のルール>を理解してください。このルールは絶対に守ってください。ルール以外のことは一切してはいけません。例外は一切ありません。
* チャットでユーザから質問が入力されるので、あなたは<参考ドキュメント></参考ドキュメント>の内容をもとに<回答のルール></回答のルール>に従って回答を行なってください。
</回答手順>

<参考ドキュメントのJSON形式>
{
"SourceId": データソースのID,
"DocumentId": "ドキュメントを一意に特定するIDです。",
"DocumentTitle": "ドキュメントのタイトルです。",
"Content": "ドキュメントの内容です。こちらをもとに回答してください。",
}[]
</参考ドキュメントのJSON形式>

<参考ドキュメント>
[
${params
  .referenceItems!.map((item, idx) => {
    return `${JSON.stringify({
      SourceId: idx,
      DocumentId: item.DocumentId,
      DocumentTitle: item.DocumentTitle,
      Content: item.Content,
    })}`;
  })
  .join(',\n')}
]
</参考ドキュメント>

<回答のルール>
* 雑談や挨拶には応じないでください。「私は雑談はできません。通常のチャット機能をご利用ください。」とだけ出力してください。他の文言は一切出力しないでください。例外はありません。
* 必ず<参考ドキュメント></参考ドキュメント>をもとに回答してください。<参考ドキュメント></参考ドキュメント>から読み取れないことは、絶対に回答しないでください。
* 回答の文末ごとに、参照したドキュメントの SourceId を [^<SourceId>] 形式で文末に追加してください。
* <参考ドキュメント></参考ドキュメント>をもとに回答できない場合は、「回答に必要な情報が見つかりませんでした。」とだけ出力してください。例外はありません。
* 質問に具体性がなく回答できない場合は、質問の仕方をアドバイスしてください。
* 回答文以外の文字列は一切出力しないでください。回答はJSON形式ではなく、テキストで出力してください。見出しやタイトル等も必要ありません。
</回答のルール>

Copy link
Contributor

This issue is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale Issues or Pull Requests with no updates label Apr 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request stale Issues or Pull Requests with no updates
Projects
None yet
Development

No branches or pull requests

1 participant