Is it possible to inject RAG retrieved documents as SystemMessage instead of UserMessage #4233
-
|
Hi, @dliubarskyi Inject retrieved documents as SystemMessage My Question: Is this approach feasible with the current architecture? Use Case: |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
|
Hi, this is not possible to do OOTB with the current implementation, but you can do some tricks to make it work. |
Beta Was this translation helpful? Give feedback.
Hi, this is not possible to do OOTB with the current implementation, but you can do some tricks to make it work.
Please keep in mind that there is usually a single
SystemMessagefor the entire conversation, so if you are going to put RAG content (that is retrieved before each LLM request) inside the system message, this meand that RAG content from previous iterations will be overriden. If this is intended, you can try using https://docs.langchain4j.dev/tutorials/ai-services#programmatic-chatrequest-rewriting and manipulate messages that are sent to the LLM. You could cut RAG content fromUserMessages and insert it into theSystemMessage. This will not be reflected inChatMemorythough, b…