-
Notifications
You must be signed in to change notification settings - Fork 81
removal of LLM instructions deployment logic #3126
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
Open
languy
wants to merge
8
commits into
main
Choose a base branch
from
dev/languy/remove-llminstructions-deploy-logic
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
0e6d625
refactor: remove LLM instructions deployment logic and related assets
languy 2f30787
feat: add cleanup logic for obsolete LLM instructions files on activa…
languy 9875993
refactor: enhance cleanup logic for LLM instructions files with telem…
languy 3a221f4
Potential fix for pull request finding
languy 6eac021
Potential fix for pull request finding
languy 46ba0b8
Potential fix for pull request finding
languy 201635c
Merge branch 'main' into dev/languy/remove-llminstructions-deploy-logic
a9df80c
Fix format
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
Empty file.
This file contains hidden or 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
This file contains hidden or 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,70 @@ | ||
| /*--------------------------------------------------------------------------------------------- | ||
| * Copyright (c) Microsoft Corporation. All rights reserved. | ||
| * Licensed under the MIT License. See License.txt in the project root for license information. | ||
| *--------------------------------------------------------------------------------------------*/ | ||
|
|
||
| import { callWithTelemetryAndErrorHandling } from '@microsoft/vscode-azext-utils'; | ||
| import * as crypto from 'crypto'; | ||
| import * as fs from 'fs'; | ||
| import * as path from 'path'; | ||
| import { ext } from '../../extensionVariables'; | ||
|
|
||
| const LLM_ASSETS_MANIFEST_KEY = 'llm.assets.manifest'; | ||
| const INSTRUCTIONS_FILENAME = 'azurecosmosdb.instructions.md'; | ||
| const EXPECTED_MD5 = 'A54B319AD86975EB072A681AFA9CB553'; | ||
|
|
||
| /** | ||
| * Cleans up the obsolete LLM instructions file that was previously deployed | ||
| * to the VS Code prompts folder by older versions of this extension. | ||
| * | ||
| * - Deletes the file only if its MD5 hash matches the known unmodified hash | ||
| * - Clears the obsolete manifest key from globalState | ||
| * | ||
| * This is idempotent and safe to call on every activation. | ||
| */ | ||
| export async function cleanupLLMInstructionsFiles(): Promise<void> { | ||
| await callWithTelemetryAndErrorHandling('cosmosDB.llmInstructions.cleanup', async (context) => { | ||
| context.errorHandling.suppressDisplay = true; | ||
| context.errorHandling.rethrow = false; | ||
|
|
||
| // Remove the file if it exists and hasn't been modified | ||
| const promptFolder = getPromptFolder(); | ||
| const filePath = path.join(promptFolder, INSTRUCTIONS_FILENAME); | ||
|
|
||
| // Mask file paths from any error telemetry (fs errors often include paths) | ||
| context.valuesToMask.push(promptFolder, filePath); | ||
| const fileExists = fs.existsSync(filePath); | ||
| context.telemetry.properties.fileFound = String(fileExists); | ||
|
|
||
| if (fileExists) { | ||
| const content = fs.readFileSync(filePath); | ||
| const actualMd5 = crypto.createHash('md5').update(content).digest('hex').toUpperCase(); | ||
| const md5Matched = actualMd5 === EXPECTED_MD5; | ||
| context.telemetry.properties.md5Matched = String(md5Matched); | ||
| ext.outputChannel.info( | ||
| `Found existing instructions file "${INSTRUCTIONS_FILENAME}" in prompts folder (md5Matched=${md5Matched})`, | ||
| ); | ||
|
|
||
| if (md5Matched) { | ||
| fs.unlinkSync(filePath); | ||
| context.telemetry.properties.fileDeleted = String(true); | ||
| ext.outputChannel.info( | ||
| `Deleted obsolete instructions file "${INSTRUCTIONS_FILENAME}" from prompts folder`, | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| // Clear the obsolete manifest from globalState | ||
| await ext.context.globalState.update(LLM_ASSETS_MANIFEST_KEY, undefined); | ||
| }); | ||
| } | ||
|
|
||
| /** | ||
| * Returns the VS Code user-level prompts folder, matching the path used | ||
| * by the old deployLLMInstructionsFiles logic. | ||
| */ | ||
| function getPromptFolder(): string { | ||
| const globalStorageUri = ext.context.globalStorageUri; | ||
| const userFolder = path.dirname(globalStorageUri.fsPath); | ||
| return path.join(userFolder, '..', 'prompts'); | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.