-
Notifications
You must be signed in to change notification settings - Fork 126
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 stable globals out of execution loop #649
Conversation
The pull request involves the following major changes:
Overall, the changes suggest a refactor to centralize the management of global objects. These changes improve readability and maintainability by reducing code duplication and centralizing the management of global objects. However, there are a few concerns:
Given these, the code changes can be approved but with a recommendation for further review on potential implications on the usage of global variables. LGTM 🚀
|
@@ -56,7 +57,7 @@ export async function parseTokens( | |||
filesGlobs: string[], | |||
options: { excludedFiles: string[]; model: string } | |||
) { | |||
const { model = "gpt4" } = options || {} | |||
const { model = DEFAULT_MODEL } = options || {} |
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 default value for the model option has been changed from "gpt4" to DEFAULT_MODEL. If the DEFAULT_MODEL constant is not defined as "gpt4", this could potentially break existing functionality.
generated by pr-review-commit
missing_default
throw new Error("Could not find global") | ||
} | ||
import { pathToFileURL } from "url" | ||
import { resolveGlobal } from "./globals" |
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 function resolveGlobal() has been moved to a different file. Make sure that this function is not used elsewhere in the codebase, as this could potentially break functionality.
generated by pr-review-commit
import_change
A new file
globals.ts
is introduced in thecore/src
package. This file includes several important functions such asinstallGlobals()
andresolveGlobals()
. These functions seem to be responsible for setting global variables in different environments (Browser and Node.js) and also, stringifying and parsing different formats: YAML, CSV, INI, XML, JSONL and MD. 🌍The
main.ts
file in thecli/src
package is updated to install these globals by callinginstallGlobals()
from the newly createdglobals.ts
file. 🔧The global objects YAML, INI, CSV, XML, MD, JSONL and AICI are now handled within the
installGlobals()
function. These used to be individually declared in thepromptcontext.ts
file, which has now been simplified, enhancing code readability. 📄Cleaning up was carried out in
importprompt.ts
andpromptcontext.ts
. Unnecessary import statements and repeated code relating to global object instantiation were eliminated, directing to use the new functions in theglobals.ts
file. This makes the code leaner and more maintainable. 🔍⚡️User facing changes: The public API in
prompt_template.d.ts
has been simplified by removing redundant entries for several global variables (YAML, XML, JSONL, CSV, INI, AICI, MD). This will likely result in a cleaner and more streamlined API for the users. 🚀In essence, these changes seem to be a part of a code refactor aimed at cleaning up redundant code and enhancing maintainability and ease of use.