-
Notifications
You must be signed in to change notification settings - Fork 134
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
Move cancel function implementation from promptcontext to globals #696
Conversation
@@ -62,4 +63,7 @@ export function installGlobals() { | |||
convertToMarkdown: HTMLToMarkdown, | |||
convertToText: HTMLToText, | |||
}) | |||
glb.cancel = (reason?: string) => { | |||
throw new CancelError(reason || "user cancelled") | |||
} |
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.
You are throwing a new CancelError
in the cancel
function but it's not being caught anywhere. This could lead to an unhandled promise rejection. Please make sure to catch this error where the cancel
function is being called. 🚀
generated by pr-review-commit
unhandled_rejection
@@ -237,9 +221,6 @@ export async function createPromptContext( | |||
defFileMerge: (fn) => { | |||
appendPromptChild(createFileMerge(fn)) | |||
}, | |||
cancel: (reason?: string) => { | |||
throw new CancelError(reason || "user cancelled") | |||
}, | |||
runPrompt: async (generator, runOptions): Promise<RunPromptResult> => { |
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 cancel
function has been removed from the PromptContext
. If this function was being used elsewhere in the code, it could lead to a TypeError
of cancel
is not a function. Please ensure that the cancel
function is not being used elsewhere in the code or provide an alternative implementation. 🧐
generated by pr-review-commit
removed_functionality
@@ -2276,7 +2276,6 @@ interface PromptContext extends ChatGenerationContext { | |||
text?: 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 cancel
method has been removed from the PromptContext
interface. This change could break existing implementations that rely on this method. Please ensure that this change is intentional and that all implementations of this interface have been updated accordingly. 🕵️♀️
generated by pr-review-commit
interface_change
The changes in the GIT_DIFF involve two main adjustments in the TypeScript code:
There don't appear to be any major issues with these changes. It looks like a refactoring effort to globalize the
Otherwise, LGTM 🚀
|
cancel
method has been moved from thePromptContext
object to the global scope of the application. This is evident from the changes in 'packages/core/src/globals.ts' and 'packages/core/src/promptcontext.ts' files. This could be to makecancel
functionality universally accessible. 🌎cancel
method was removed from thePromptContext
interface definition in the 'packages/core/src/types/prompt_template.d.ts' file. This is a user facing change as it modifies how users interact with the 'PromptContext' interface.createPromptContext
function no longer throws aCancelError
exception; this responsibility seems to have been shifted to the movedcancel
method. Therefore, the code might be becoming more modular or adhering to separation of concerns principle. 📏