-
Notifications
You must be signed in to change notification settings - Fork 132
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
++Enable caching for LLM requests with configurable cache names #677
Conversation
@@ -8,12 +8,20 @@ keywords: cache management, LLM request caching, script performance, cache file | |||
|
|||
import { FileTree } from "@astrojs/starlight/components" | |||
|
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.
The statement about LLM requests caching has been changed. It was previously stated that LLM requests are cached by default, but the updated content states that they are not cached by default. This is a significant change and should be verified for accuracy.
generated by pr-docs-review-commit
content_change
|
||
```sh "--cache" | ||
npx genaiscript run ... --cache | ||
``` |
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.
New content has been added to explain how to enable LLM request caching. This includes a JavaScript code snippet and a shell command. Ensure that these instructions are correct and clear for users.
generated by pr-docs-review-commit
content_addition
@@ -26,23 +34,6 @@ This file is excluded from git by default. | |||
|
|||
</FileTree> | |||
|
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.
The section on disabling the cache has been removed. If this information is still relevant and useful, consider adding it back to the documentation.
generated by pr-docs-review-commit
content_removal
@@ -51,7 +42,7 @@ The name will be used to create a file in the `.genaiscript/cache` directory. | |||
```js | |||
script({ | |||
..., |
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.
The property name in the JavaScript code snippet has been changed from 'cacheName' to 'cache'. This could potentially confuse users if not properly explained in the surrounding text.
generated by pr-docs-review-commit
content_change
The changes in the GIT_DIFF are:
I have a few concerns:
Suggested improvements: Rename - const cache = getChatCompletionCache(
- typeof cacheOrName === "string" ? cacheOrName : cacheName
- )
+ // cacheControl can be a boolean or a string.
+ // If it's a boolean, it determines whether to use the cache.
+ // If it's a string, it is used as the cache name.
+ const cacheControl = cacheOrName;
+ const cache = getChatCompletionCache(
+ typeof cacheControl === "string" ? cacheControl : cacheName
+ ) Aside from these concerns, the rest of the changes look good. They appear to be part of a refactor to simplify the caching behavior. No obvious security, reliability, scalability, or performance issues are visible from the diff.
|
…rror handling in OpenAI chat completion
|
||
```sh "--cache" | ||
npx genaiscript run ... --cache | ||
``` |
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.
New code examples have been added to illustrate how to enable LLM request caching. Ensure these examples are correct and clear to the reader.
generated by pr-docs-review-commit
code_example_added
@@ -51,7 +42,7 @@ The name will be used to create a file in the `.genaiscript/cache` directory. | |||
```js | |||
script({ | |||
..., | |||
cacheName: "summary" | |||
cache: "summary" | |||
}) |
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.
The section on disabling the cache has been removed. If this information is still relevant, it should be included in the documentation.
generated by pr-docs-review-commit
content_removed
…and vscode packages
@@ -51,7 +42,7 @@ The name will be used to create a file in the `.genaiscript/cache` directory. | |||
```js | |||
script({ | |||
..., | |||
cacheName: "summary" | |||
cache: "summary" | |||
}) |
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.
The section on disabling the cache has been removed. This information might be important for users who want to disable caching. Consider adding it back or providing an alternative way to disable caching.
generated by pr-docs-review-commit
content_removal
`error: run failed with ${exitCode}, retry #${r + 1}/${runRetry} in ${delayMs}ms` | ||
) | ||
await delay(delayMs) | ||
} |
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.
The retry logic has been changed to only retry if runRetry
is greater than 1. This could potentially skip necessary retries if runRetry
is 1, which might lead to unexpected behavior. Please ensure this is the intended behavior.
generated by pr-review-commit
retry_logic
@@ -70,7 +70,7 @@ export interface PromptScriptRunOptions { | |||
model: string |
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.
The type of cache
has been changed from boolean
to boolean | string
. This could potentially break existing code that expects cache
to be a boolean. Please ensure that all usage of cache
has been updated to handle the new type.
generated by pr-review-commit
cache_type_change
++
The caching functionality in the script execution has been thoroughly revamped. 🔄
temperature < 0.5
,top_p < 0.5
,seed
not used, no functions used, which automatically enabled cache usage. These have been removed.There have been user-facing changes in the public API.
cache
option in scripts now accepts a boolean value or a string. If it'strue
, the script will use caching. If it's a string, this will override the default cache name.cacheName
is marked as deprecated, replaced by the string option incache
. 💾Changes have been made to
OpenAIChatCompletion
inopenai.ts
.Constants
CACHE_CHAT
andGITHUB_PULLREQUEST_REVIEW_COMMENT_LINE_DISTANCE
got renamed fromchatv2
tochat
and 5 to 6 respectively inconstants.ts
. ⛓Scripts inside
genaisrc
have been updated to comply with the recent changes related to caching. Thecache
andcacheName
options are replaced with justcache
which can hold a boolean value or a string (cache name).In essence, this update is focused on giving more control over caching to the user rather than the system deciding it based on certain conditions. 🎛