-
Notifications
You must be signed in to change notification settings - Fork 232
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add some scripts for replacing and restoring max tokens (#21)
- Loading branch information
Showing
2 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
' VBScript to change max tokens to 2048 | ||
|
||
MsgBox "It may take a few seconds to execute this script." & vbCrLf & vbCrLf & "Click 'OK' button and wait for the prompt of 'Done.' to pop up!" | ||
|
||
Const ForReading = 1 | ||
Const ForWriting = 2 | ||
|
||
' Subpath of the file to be replaced | ||
subpath = "dist\extension.js" | ||
|
||
pattern = "\.maxPromptCompletionTokens\(([a-zA-Z0-9_]+),([0-9]+)\)" | ||
replacement = ".maxPromptCompletionTokens($1,2048)" | ||
|
||
' Iterate over all github copilot directories | ||
Set objFSO = CreateObject("Scripting.FileSystemObject") | ||
Set objShell = CreateObject("WScript.Shell") | ||
Set colExtensions = objFSO.GetFolder(objShell.ExpandEnvironmentStrings("%USERPROFILE%") & "\.vscode\extensions").SubFolders | ||
|
||
For Each objExtension In colExtensions | ||
extension_path = objExtension.Path & "\" & subpath | ||
If objFSO.FileExists(extension_path) Then | ||
backupfile = extension_path & ".bak" | ||
|
||
' Delete if backup file exists | ||
If objFSO.FileExists(backupfile) Then | ||
objFSO.DeleteFile backupfile, True | ||
End If | ||
|
||
' Backup | ||
objFSO.CopyFile extension_path, backupfile | ||
|
||
' Do search and replace with pattern | ||
Set objFile = objFSO.OpenTextFile(extension_path, ForReading) | ||
strContent = objFile.ReadAll | ||
objFile.Close | ||
|
||
Set objRegEx = New RegExp | ||
objRegEx.Global = True | ||
objRegEx.IgnoreCase = True | ||
objRegEx.Pattern = pattern | ||
strContent = objRegEx.Replace(strContent, replacement) | ||
|
||
Set objFile = objFSO.OpenTextFile(extension_path, ForWriting) | ||
objFile.Write strContent | ||
objFile.Close | ||
End If | ||
Next | ||
|
||
MsgBox "Max tokens modification completed" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
' VBScript to recovery max tokens | ||
MsgBox "It may take a few seconds to execute this script." & vbCrLf & vbCrLf & "Click 'OK' button and wait for the prompt of 'Done.' to pop up!" | ||
|
||
Const ForReading = 1 | ||
Const ForWriting = 2 | ||
|
||
' Subpath of the file to be recovery | ||
subpath = "dist\extension.js" | ||
|
||
' Iterate over all github copilot directories | ||
Set objFSO = CreateObject("Scripting.FileSystemObject") | ||
Set objShell = CreateObject("WScript.Shell") | ||
Set colExtensions = objFSO.GetFolder(objShell.ExpandEnvironmentStrings("%USERPROFILE%") & "\.vscode\extensions").SubFolders | ||
|
||
For Each objExtension In colExtensions | ||
extension_path = objExtension.Path & "\" & subpath | ||
backupfile = extension_path & ".bak" | ||
|
||
If objFSO.FileExists(backupfile) Then | ||
' Delete if exist extension file | ||
If objFSO.FileExists(extension_path) Then | ||
objFSO.DeleteFile extension_path, True | ||
End If | ||
|
||
' Replace | ||
objFSO.MoveFile backupfile, extension_path | ||
End If | ||
Next | ||
|
||
MsgBox "Restore max tokens to default successed" |