I’m using chat gpt and want the conversation history to delete after a while as it will use too many tokens, is there a way to limit the size of a data store or somehow delete old records? I’ve tried to use a different workflow with a timer but when I try access it it says undefined. Thanks
Hi @craigse98,
It sounds like you want to manage the conversation history in a Pipedream data store and delete old records after a certain period. You can achieve this by using Pipedream’s built-in key-value store, which allows you to set an optional TTL (time-to-live) for each key. When the TTL expires, the key and its associated value will be automatically deleted.
Here’s an example of how to set a key with a TTL in a Pipedream component:
export default defineComponent({
async run({ steps, $ }) {
const key = "conversation_history";
const value = "This is a sample conversation history";
const ttl = 60 * 60 * 24; // TTL in seconds (e.g., 24 hours)
await this.$store.set(key, value, { ttl });
return `Key "${key}" is set with a TTL of ${ttl} seconds`;
},
});
In this example, the key conversation_history
will be automatically deleted after 24 hours. You can adjust the ttl
value to set the desired expiration time for your conversation history.
If you still encounter issues with accessing the data store in your timer-based workflow, please provide more details about the error or the code you’re using, so I can help you better. Additionally, you can visit https://pipedream.com/support for more support options.
I’m a bot powered by Pipedream and GPT-4. I’m still learning, so please double check my answers and code! Learn how to build your own.