-
Notifications
You must be signed in to change notification settings - Fork 15
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
Bugs in conversations #260
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the problem comes from here, where memories
is being reversed. Those memories include, in some way, the messages that form the chat, and they are included in a way that older (question, answer) pairs go first, and questions go before answers. That is, Q1, A1, ... Qn, An
. When reversing memories, we have An, Qn, ..., A1, Q1
, so answers go before questions.
I don't know if it's better to reverse the order in which question, answer pairs are added to the memory (what you are doing) or if we should take into account that Chat memories come in pairs and that we should reverse them keeping the relative order of pairs the same (and thus changing that messages
function. I guess that for this case, your solution is better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my bad 🙋 , thank you!
I hadn't noticed the I have found other 2 bugs in the conversations when we are storing the messages in the |
9efef72
I have updated the PR with the new fixes and added some tests @victorcrrd @raulraja could you please review it? |
core/src/commonMain/kotlin/com/xebia/functional/xef/vectorstores/LocalVectorStore.kt
Outdated
Show resolved
Hide resolved
core/src/commonMain/kotlin/com/xebia/functional/xef/vectorstores/LocalVectorStore.kt
Show resolved
Hide resolved
core/src/commonTest/kotlin/com/xebia/functional/xef/vectorstores/LocalVectorStoreSpec.kt
Outdated
Show resolved
Hide resolved
core/src/commonTest/kotlin/com/xebia/functional/xef/vectorstores/LocalVectorStoreSpec.kt
Show resolved
Hide resolved
examples/kotlin/src/main/kotlin/com/xebia/functional/xef/auto/Conversation.kt
Outdated
Show resolved
Hide resolved
@victorcrrd @raulraja I have fixed some problems in the order messages on We are using |
core/src/commonTest/kotlin/com/xebia/functional/xef/vectorstores/LocalVectorStoreSpec.kt
Show resolved
Hide resolved
core/src/commonTest/kotlin/com/xebia/functional/xef/vectorstores/CombinedVectorStoreSpec.kt
Outdated
Show resolved
Hide resolved
* format * syntax error in createMemoryTable query * being able to connect to db * added missing test * added documentation to indicate that timestamp is measured in millis * modeling timestamp in postgres as a BIGINT instead of a TIMESTAMP to avoid problems * messages retrieved from postgres were assigned always the same name "role", now it matches the name stored in the database * getting postgres messages in the right order: from oldest to newest (in the form of a chat) * added simple test * specifying more the test * substituting localhost by IP 0.0.0.0 is fine for this test
@raulraja I have been talking with @victorcrrd because we are going to change the On the other hand, should we review the |
@raulraja @Montagon This PR is ready for review. Here are the changes:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you!
This PR tries to resolve 2 bugs:
Bug 1
When we are working in conversations in Xef (remember that we are creating by default the
conversionId
inCoreAIScope
)The problem is the order of the messages when we are sending the
messages
toOpenAI
Currently, we are storing the messages in the conversation in the wrong order. When we send the request to
OpenAI
the messages have the following order:And when we add a new question from the user, we add this message to the end like this:
In my tests, this is a problem that sometimes
OpenAI
isn't responding to the last question, it is responding to the second to lastThe right order should be:
This PR changes the way that we are storing the conversation in the memory in order to fix that
Note: You can revert the changes in
Chat.kt
and you will see that theConversation.kt
example gives the same result both timesBug 2
Resolving this issue