Inject ChatMemory into the Prompt #879
Closed
andreadimaio
started this conversation in
Ideas
Replies: 2 comments 4 replies
-
This is indeed interesting and I think it's somewhat related to |
Beta Was this translation helpful? Give feedback.
3 replies
-
I'm thinking about how to control the use of the custom format and whether it's better to have this as a property of the |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I'd like to share an idea that could speed-up the process of creating a prompt that leverage
ChatMemory
for AI interactions.The focus of this proposal is to simplify how developers pass conversation history into prompts.
Problem
Currently, when developing an AI service that utilizes a conversation history as part of the prompt, the developer is responsible for manually formatting the chat history. This involves extracting and formatting past
user
andassistant
messages into a structured format.Consider the example below, where the developer needs to inject a conversation history (as a formatted string) into the prompt:
Where the
chatHistory
placeholder has the format:To implement this example, the developer needs to inject the
ChatMemoryStore
in a service class and generate the correct format for thechatHistory
placeholder.Simplifying ChatMemory Injection
To accelerate this process and reduce manual work, it could be useful to have a new feature that allows the
ChatMemoryStore/ChatMemory
to be passed directly as a method parameter. In this case a specific implementation will be used to automatically map theChatMemoryStore/ChatMemory
to the appropriate format that the developer requires for the prompt, where the default format could be what I wrote above.Customizable Format:
If the developer requires a different conversation format, they could customize the formatting by adding a property in the
@RegisterAiService
annotation. For example:This is an idea that came to mind while using quarkus-langchain4j. I don't know if it makes sense or if there is already something that can be used to do this operation, let me know 😄.
Beta Was this translation helpful? Give feedback.
All reactions