View user AI chat

I have an app where users can use the Retool AI chat to query the data. Is it possible to see the chat questions that users have asked so that we can add features to the app and improve it?

1 Like

The chat component has a property called messageHistory which stores an array of the interactions. I'm fairly certain you would have trigger something to persist this information outside of the app (into a local DB or something) but here is an example of 5 things I asked the bot (pulled from the component's messageHistory property):

[{
        "role": "user",
        "content": "Can I test this bot?"
    }, {
        "role": "assistant",
        "content": "Of course! I'm here to assist you. You can test me by asking questions or giving tasks."
    }, {
        "role": "user",
        "content": "How many messages do you store in your messageHistory property?"
    }, {
        "role": "assistant",
        "content": "As an AI developed by OpenAI, I want to clarify that I don't have the capacity to store personal data provided during our conversation and I don't have a 'messageHistory' property. I am designed to respect user privacy and confidentiality. Our conversation does not have a memory and is not used to aid responses in the future."
    }, {
        "role": "user",
        "content": "You are a component in a development application that has a property called messageHistory which stores an array of message information"
    }, {
        "role": "assistant",
        "content": "I'm sorry for the confusion, but as an AI developed by OpenAI, I don't have the capacity to have properties such as 'messageHistory'. I am a stateless model which means I don't have the ability to store or retrieve past interactions. If you're developing an application that includes such a component, the limits and capabilities of the 'messageHistory' feature would depend on how you implement it in your specific application code."
    }, {
        "role": "user",
        "content": "How much memory would you assume you would need to store the historical data of a conversation such as this one?"
    }, {
        "role": "assistant",
        "content": "The amount of memory required to store the history of a conversation like this would depend on the structure of the data and the length of the conversation. Each character in a string typically requires anywhere from 1 to 4 bytes, so a conversation can be roughly estimated based on its length in characters. If the conversation is being stored in an array, where each message is an object including text, sender information, timestamps, etc., additional memory will be required for these data points and the overhead of the array and objects.So, to estimate:1. Calculate the total number of characters (N) in the conversation (including spaces and any metadata).\n2. Treat each character as taking up, say, an average of 2 bytes (it depends on the encoding, but this is a reasonable estimate). This gives 2N bytes.\n3. Consider that the actual data structure might inflate this by a factor—say, doubling it, to account for keys, object structure, etc.This is just a rough estimation, and the true amount might vary depending on the programming language, data structures, and other factors. It's also worth noting that modern systems should be able to handle storing many text conversations comfortably, unless they're extraordinarily long or numerous."
    }, {
        "role": "user",
        "content": "Would it be possible for an online application state to store this kind of historical data indefinitely? How long do you think such a conversation would have to be to break the memory capacity of the server running it?"
    }, {
        "role": "assistant",
        "content": "Storing the historical data indefinitely in an application's state, such as in a web server's RAM, is not a good practice. As the data grows, it could indeed surpass the memory capacity of the server. However, the exact length that would break the capacity highly depends on the server's particular specifications.For large or long-term data storage, it's common to use a database or some form of persistent storage rather than trying to keep everything in memory. This transfers the limitation from the RAM, which is relatively limited and volatile, to disk storage, which is much more plentiful.If your concern is privacy or data retention laws, you can establish procedures to anonymize or delete data after a certain time period. As an alternative, you can use streaming or batch processing to analyze the data on-the-go and only store the summary or result rather than the raw data.Ultimately, proper capacity planning, system architecture, and handling of data are crucial to ensure that your server and application can handle the load and operate reliably."
    }
]

I am also very interested implementing the user chat history storage. Need to save all conversations, how would you guys do it step-by-step? Appreciate any response!

You could create a table in Retool Database to store the data & have a query that sends this data to that table on success of the chat query :slightly_smiling_face: