Skip to content
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

Add keys method to WorkspaceFileCache #676

Merged
merged 2 commits into from
Aug 29, 2024
Merged

Add keys method to WorkspaceFileCache #676

merged 2 commits into from
Aug 29, 2024

Conversation

pelikhan
Copy link
Member

@pelikhan pelikhan commented Aug 29, 2024

This pull request adds a keys method to the WorkspaceFileCache interface. The keys method returns a promise that resolves to an array of keys in the cache. This allows users to retrieve a list of keys stored in the cache. The changes also include updating the documentation to reflect the new method.

  • The developers have added a new method to WorkspaceFileCache interface, in the file "packages/core/src/types/prompt_template.d.ts". This new method allows to get all the keys from the cache. Now you can list the keys in the cache as well as the values. 🔑⚡
  • The changes have also been reflected in the related code files to add the keys-listing functionality. In the file "packages/core/src/filesystem.ts", the newly added keys method is used to fetch all the keys from the cache. 📄🔄
  • A change has been made in "docs/src/content/docs/reference/scripts/cache.mdx" to include instructions on how to use the new keys method. This is expected to help the users of the public API to learn how to get a list of keys from the cache memory. 📖🔍
  • There is an update on a test file at "packages/sample/genaisrc/cache.genai.mts". Now they are checking if particular keys exist in the cache as part of the test case. This validates the implementation of the new method. ✅🤓

generated by pr-describe

Copy link

The changes in the pull request add a new method to the WorkspaceFileCache interface in prompt_template.d.ts. The new method, keys(), is expected to return a promise that resolves with an array of keys.

In filesystem.ts, the createFileSystem function has been updated to include this new keys() method in the file cache object it creates. The implementation of keys() calls the keys() method of the res object, which is presumably another implementation of the same cache interface.

In terms of function, this change allows users of the file system cache to retrieve an array of the cache's keys without having to retrieve the whole entries. This could be more performant in cases where only the keys are needed.

There are no apparent functional issues with these changes. However, as a code reviewer, I can't guarantee the correctness of the method because the actual implementation of the keys() method in the res object is not shown in the diff.

Overall, this change is LGTM 🚀. It adds a useful function to the file system interface that improves its flexibility and potential efficiency.

generated by pr-review

@pelikhan pelikhan merged commit d118049 into main Aug 29, 2024
12 checks passed
@pelikhan pelikhan deleted the cache-keys branch August 29, 2024 18:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant