-
Notifications
You must be signed in to change notification settings - Fork 25
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
Chat history #421
Comments
I lean towards option 2 as well: history at the chat level, maybe to default to True for all chats via the persistent config or during startup at the CLI level. Chat histories could be loaded in bulk from the DB and toggled on a per-chat basis via the UI. |
It looks like Langchain creates a special input type that is a combination of prompt + message_history, then builds a history-aware retriever that further rephrases the prompt using the history before sending everything to the LLM. https://python.langchain.com/v0.2/docs/tutorials/qa_chat_history/#adding-chat-history |
To model things similarly to Langchain, we would replace the |
Aren't the start and end of the sentence contradict each other? If we have the history at the chat level, we cannot have it globally set either through the config file or CLI option. When doing it on the chat level, we can have a boolean parameter that gets passed during chat creation regardless if that happens at the Python or REST API or the web UI. Defaulting to
I dislike this approach somewhat. Right now we have components that process data objects, e.g. a source storage gets passed documents and returns sources. The data objects don't have any processing logic on them. IMO this makes it a lot easier to keep the model of a pipeline. Thus, I'd prefer that functionality like rephrasing becomes a component rather than a method on a data object. Re formatting: I don't think this can even be on the |
Maybe I have to look more closely at how the global config interacts with the system. I meant that default history behavior is defined globally (i.e. the user can decide whether chat history is on or off for all new chats), but can be toggled per-chat.
This makes a lot of sense to me. Keeping the new Input class as a pure data type would still help abstract away the details from rest of the pipeline, and then a rephrasing component can process these pieces elsewhere.
I'm pretty sure this is how Langchain handles it too. |
I like this, excellent research @blakerosenthal. Abstracting the prompt like this would also allow us to potentially tackle another (small, but important) problem that has come up - being able to use different system prompts with the same assistant. I am currently doing this by creating multiple assistants, which feels unnecessary. @pmeier Do we have consensus for adding a new data model
@pmeier The rest of your proposal regarding implementation seems sensible to me - make use of the Excited about this! |
I'll just keep my comments at the higher LLM-interaction level as I have less opinion about how ragna should do it specifically, but with that said:
|
@pmeier Can I close this? |
Let's keep it open until our builtin assistants actually use the chat history. |
Feature description
Currently each prompt passed to
Chat.answer
will be independent of the chat history. Meaning, although it is presented as one chat, each prompt-answer-pair is independent from each other. This can cause some confusion as users might reference a previous prompt or answer will get a nonsensical answer given that the assistant is not aware of them.To overcome this, I propose we add a chat history feature that can be toggled on and off. I'm not sure on what level this should apply:
ragna.Rag()
or set in the configurationRag().chat()
Chat().answer()
I prefer 2. here, but I'm open to other opinions.
I'm not sure about the interface either. Naively, I would say that instead of passing the prompt to the assistant
ragna/ragna/core/_components.py
Line 216 in 84cf4f6
We could also pass a list of messages here. The current case would have only a single item in there, whereas with chat history we would have multiple entries. If we go for this implementation, we also need to decide whether we pass
str
s orragna.core.Messages
and whether we pass a flat list or a list of prompt-answer-pairs. Let's survey the ecosystem and not reinvent the wheel here.Value and/or benefit
Less user confusion and actual conversations rather than independent Q/A.
Anything else?
To pass historical messages to the assistant, we already have access to the
Chat._messages
attributeragna/ragna/core/_rag.py
Line 168 in 84cf4f6
However, on the API side we never bothered to fill this up when loading a chat from the DB, since the chat so far never accesses the historical messages:
ragna/ragna/deploy/_api/core.py
Lines 236 to 240 in 84cf4f6
The text was updated successfully, but these errors were encountered: