-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Hook for create site command with nl2page&site (#1057)
* Hook for create site command with nl2page&site * Disable any type validation * Refactor PowerPagesChatParticipantConstants and CreateSiteCommand - Add NL2SITE_GENERATING_SITE constant for generating a new Power Pages site - Update progress message in CreateSiteCommand to use NL2SITE_GENERATING_SITE constant - Remove unnecessary markdown formatting in CreateSiteHelper error handling * Refactor localization files and update Power Pages chat participant utils * Refactor NL2SiteService and Nl2PageService to include additional telemetry logging --------- Co-authored-by: amitjoshi <[email protected]> Co-authored-by: tyaginidhi <[email protected]>
- Loading branch information
1 parent
a38fef0
commit 9dd77cd
Showing
10 changed files
with
160 additions
and
29 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
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
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
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
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
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
50 changes: 50 additions & 0 deletions
50
src/common/chat-participants/powerpages/commands/create-site/CreateSiteCommand.ts
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,50 @@ | ||
/* | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*/ | ||
|
||
import { Command } from "../../../CommandRegistry"; | ||
import * as vscode from 'vscode'; | ||
import { createSite } from "./CreateSiteHelper"; | ||
import { FAILED_TO_CREATE_SITE, NL2SITE_GENERATING_SITE } from "../../PowerPagesChatParticipantConstants"; | ||
import { oneDSLoggerWrapper } from "../../../../OneDSLoggerTelemetry/oneDSLoggerWrapper"; | ||
import { VSCODE_EXTENSION_CREATE_SITE_COMMAND_FAILED} from "../../PowerPagesChatParticipantTelemetryConstants"; | ||
|
||
export class CreateSiteCommand implements Command { | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
async execute(request: any, stream: vscode.ChatResponseStream): Promise<any> { | ||
const { prompt, intelligenceAPIEndpointInfo, intelligenceApiToken, powerPagesAgentSessionId, telemetry, orgId, envId, userId } = request; | ||
|
||
stream.progress(NL2SITE_GENERATING_SITE); | ||
try { | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
const result = await createSite( | ||
intelligenceAPIEndpointInfo.intelligenceEndpoint, | ||
intelligenceApiToken, | ||
prompt, | ||
powerPagesAgentSessionId, | ||
stream, | ||
telemetry, | ||
orgId, | ||
envId, | ||
userId | ||
); | ||
// Process the result | ||
|
||
return { | ||
metadata: { | ||
command: 'create-site', | ||
} | ||
}; | ||
} catch (error) { | ||
stream.markdown(FAILED_TO_CREATE_SITE); | ||
telemetry.sendTelemetryEvent(VSCODE_EXTENSION_CREATE_SITE_COMMAND_FAILED, { sessionId: powerPagesAgentSessionId, orgId:orgId, envId: envId, userId: userId, error: error as string }); | ||
oneDSLoggerWrapper.getLogger().traceError(VSCODE_EXTENSION_CREATE_SITE_COMMAND_FAILED, error as string, error as Error, { sessionId: powerPagesAgentSessionId, orgId:orgId, envId: envId, userId: userId}, {}); | ||
return { | ||
metadata: { | ||
command: '' | ||
} | ||
}; | ||
} | ||
} | ||
} |
Oops, something went wrong.