shell_gpt
shell_gpt copied to clipboard
Implement caching
In some cases, we may need to run sgpt twice with the same prompt in order to pipe the output somwhere else. For example:
sgpt --code "implement merge sort algorithm using C language"
#include <stdio.h>
void merge(int arr[], int l, int m, int r)
{
int i, j, k;
int n1 = m - l + 1;
int n2 = r - m;
...
The output in this case can be quite large, and it would be helpful to use less to view it:
sgpt --code "implement merge sort algorithm using C language" | less
But we would spent +1 query and couple seconds of waiting just to get same (not always) response. It would be useful to implement some form of caching for the last n outputs, as well as a way to invalidate the cache (for example, by using --cache and --no-cache arguments)."