Skip to content
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

Copilot - Dataverse Integration for Lists and Forms #598

Draft
wants to merge 141 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
141 commits
Select commit Hold shift + click to select a range
ec584c9
creating req. files for webview
May 4, 2023
2ba4a7a
seprated js, prompt engine, active editor context
May 5, 2023
641538d
added api service file
May 5, 2023
d8b39ce
updated package.json for webview
May 6, 2023
ca5da6a
vsce package update
May 9, 2023
bf65c98
1 conditional support of CREATE in desktop
May 9, 2023
905cd90
Yeoman integration for copilot
May 9, 2023
a943b38
added CSP for script, extenal connection
May 9, 2023
026bed2
cleaned and refined icons, js, & css
May 9, 2023
96c776d
Moving Api call into seprate file
May 9, 2023
3486969
1. reverted changes for API
May 10, 2023
13f45b2
removed duplicate fxn
May 10, 2023
4fd053a
1. Removed API call from script
May 11, 2023
d547b85
AIB Auth
May 12, 2023
1865c37
Merge branch 'users/amitjoshi/copilotInfra' into users/rishjain/copil…
May 12, 2023
df5c6a6
build stash
May 15, 2023
a2f7e51
consuming local api endpoint of AIB
May 19, 2023
de6f4f4
updated vsce package
May 22, 2023
d0053aa
webview toolkit infra
May 23, 2023
fdba5fb
added prompt template object
May 23, 2023
6f9340a
removed preview icon
May 23, 2023
6626f31
added AIB prompt for NL2page
May 23, 2023
a476b80
increased token limit
May 23, 2023
fc5440e
added fetchXML scenerio
May 23, 2023
8d74ab3
enhanced css of list
May 23, 2023
173ef89
added clear chat option
May 23, 2023
eaa8cd9
added animation prompt
May 23, 2023
8b4d24b
removing langauage name from code block
May 25, 2023
b9bc374
moving prompt templates location
May 25, 2023
73688c9
reducing temprature
May 25, 2023
c387776
changes
May 25, 2023
f5b7b73
added a text-field and link using toolkit
May 26, 2023
8472797
added button to text field
May 29, 2023
d4d8e9d
added copilot.js file to main.ts
May 29, 2023
f25112a
updated main.ts
May 29, 2023
daf4052
Merge remote-tracking branch 'origin/users/amitjoshi/bapAiDay' into u…
May 29, 2023
e0b1f60
updated html and input field
May 30, 2023
9a07524
AIB integration
Jun 1, 2023
022a70d
added scenario switching
Jun 1, 2023
7df5d53
styled input box, added user icon, code scroll bar
Jun 1, 2023
2b5a49f
Merge remote-tracking branch 'origin/users/rishjain/aib_integration' …
Jun 1, 2023
06fa111
updated code formatting & styling
Jun 1, 2023
e7c9af5
updated / list container
Jun 1, 2023
2183bcb
retaining context of webview
Jun 7, 2023
5b9f6bd
retaining webview for vscode.dv
Jun 7, 2023
baf7713
1 Authentication 2 Icons & name 3 ActiveFile
Jun 7, 2023
3eb9eb5
clear updates session id and user profile
Jun 8, 2023
da112d0
Clear all icon in view/title
Jun 8, 2023
6da1d9c
migrated from main.ts and added thinking
Jun 12, 2023
b296ec5
Changed to copilot.js and added custom input box
Jun 12, 2023
072cec9
css change for feedback div
Jun 13, 2023
a581f05
Added fxn to get selected text
Jun 13, 2023
dd4df5d
added a generic error msg
Jun 13, 2023
dbb993e
Custom when clause for copilot and Create menu
Jun 13, 2023
649fa40
copilot conditional view- comments
Jun 14, 2023
91f5b7e
Login Screen
Jun 14, 2023
36aa9b6
Login Screen. TODO: Handle Logout
Jun 14, 2023
514e131
moving welcome screen in new div
Jun 14, 2023
4897abf
Merge branch 'users/amitjoshi/webviewUIStructure' into users/amitjosh…
Jun 15, 2023
60e912a
Added 'pac org who' to pacWrapper
Jun 20, 2023
9bb26fe
PacOrg who and input box for org id
Jun 21, 2023
57deeb0
Updated welcome screen
Jun 21, 2023
a4b61c6
Merge branch 'users/amitjoshi/copilotLoginFlow' into users/amitjoshi/…
Jun 21, 2023
834e8f6
webUiToolkit related main.js and gulp
Jun 21, 2023
e18ab56
fixed sendbutton bug
Jun 21, 2023
bcc0dd1
Merge branch 'users/amitjoshi/copilotLoginFlow' into users/amitjoshi/…
Jun 21, 2023
4308ce0
updated input border
Jun 26, 2023
a83bfe7
removed Create related changes for copilot
Jun 27, 2023
e963b29
Merge remote-tracking branch 'origin/main' into users/amitjoshi/copil…
Jun 27, 2023
4e386ff
removed create flow from copilot
Jun 27, 2023
6b81b57
added clipath to copilot constructor
Jun 27, 2023
49e7679
updated css and when clause for clear conversation
Jun 27, 2023
fb059a9
Added Test Env Endpoint
Jun 27, 2023
ef72a94
updated copilot view json and moved header in chat
Jun 27, 2023
2d0c8ba
updated styling for code block: added margin
Jun 27, 2023
5417743
FCB to enable/disable copilot view
Jun 28, 2023
b68a297
Added telemetry for API auth
Jun 28, 2023
5e43491
removed comments
Jun 28, 2023
61604f9
Enhanced and cleaned webview file
Jun 28, 2023
2c93a00
removed webuitoolkit integration file
Jun 28, 2023
0b57765
removed comments
Jun 28, 2023
de648ae
cleaned copilot.js file
Jun 28, 2023
40ffa33
Merge remote-tracking branch 'origin/main' into users/amitjoshi/webvi…
Jun 28, 2023
3f7e5dd
added experimental tag to FCB
Jun 28, 2023
157f490
Removed config for webview toolkit
Jun 28, 2023
71e108c
handling feedback thumb click
Jun 29, 2023
6605bab
updated styling
Jun 29, 2023
1cdfeed
added <hr> before feedback div
Jun 29, 2023
5a53928
Added Maps for contract req.
Jul 3, 2023
d156c2d
Added ActiveFileParam handling
Jul 3, 2023
de10eef
updated learn more link
Jul 3, 2023
8541e36
Fixed snippet insertion issue
Jul 3, 2023
ec0c7cf
sending feedback msg to ext.
Jul 3, 2023
9deea2c
added advanced form
Jul 3, 2023
e78c007
Updated welcome message as per figma. V2
Jul 3, 2023
33dd211
Merge branch 'users/amitjoshi/webviewUIStructure' into users/amitjosh…
Jul 3, 2023
92168bf
Added infra for CES survey
Jul 3, 2023
fa1924f
Added line above feedback
Jul 4, 2023
de0f294
update login button UI
Jul 4, 2023
47ee9d0
Updated UI for login button
Jul 4, 2023
903dfa5
updated package for yaml
Jul 4, 2023
7c1cb5d
updated test endpoint
Jul 4, 2023
e4aa224
handling violation and unclear responses in code
Jul 4, 2023
f08b565
Disposing panel on submit
Jul 4, 2023
4b9762a
added console statement
Jul 4, 2023
5efe7a4
Merge branch 'users/amitjoshi/webviewUIStructure' into users/amitjosh…
Jul 4, 2023
856a9b2
Added notification for code copy
Jul 4, 2023
9eeac1c
error handling for PAC org who
Jul 4, 2023
408be16
Added styling to the feedback form
Jul 5, 2023
1c2d51a
updated feedback font
Jul 5, 2023
582aab9
Add script to handle dynamic update of form label
Jul 5, 2023
8d894b8
Preview tag
Jul 5, 2023
916981a
removed active file content from body
Jul 5, 2023
86e80a1
Removed environment pill from copilot view
Jul 6, 2023
790a5ae
Added pac org who in login
Jul 6, 2023
9ce5f3c
Org change handling
Jul 6, 2023
677bd97
updated login flow to handle no org
Jul 6, 2023
9dee302
enhanced first load exp. for login
Jul 6, 2023
aed0782
removed delay for pac org who
Jul 6, 2023
2b99a8c
user initial fix
Jul 6, 2023
a396d71
profile icon shrink fixed
Jul 7, 2023
7a9b497
Added prompt for url input box
Jul 7, 2023
1e42373
Try copilot notification
Jul 7, 2023
fcc4bec
Added Telemetry for copilot
Jul 10, 2023
bf5cde7
removed try copilot notification
Jul 10, 2023
0bf4751
Added check for org url input box for copilot
Jul 10, 2023
1b1d428
Response to user if, no active org
Jul 10, 2023
2cc9bbd
removed log statements
Jul 10, 2023
b55ad69
removed logs from copilot.js
Jul 10, 2023
9ad75a9
Added error constants and removed log
Jul 10, 2023
e8e0d72
Merge remote-tracking branch 'origin/main' into users/amitjoshi/webvi…
Jul 10, 2023
a460a30
updated based on main branch
Jul 10, 2023
0c5cc86
scope redeclare fix
Jul 10, 2023
44bb53e
added telemetry for ces and removed log
Jul 10, 2023
d127ed3
Merge remote-tracking branch 'origin/main' into users/amitjoshi/webvi…
Jul 10, 2023
32e3af2
disabled eslint for error
Jul 10, 2023
f50eac0
fixing constant file name
Jul 10, 2023
0422f4c
added constants back
Jul 10, 2023
ade184d
Merge branch 'main' into users/amitjoshi/webviewUIStructure
Jul 10, 2023
c2066e7
Dataverse integration
Jul 11, 2023
8e80f86
updated contract and dataverse scope
Jul 12, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"cSpell.words": [
"nupkg",
"powerapps",
"powerpages",
"powerplatform"
],
"sarif-viewer.connectToGithubCodeScanning": "off"
Expand Down
14,481 changes: 1,890 additions & 12,591 deletions package-lock.json

Large diffs are not rendered by default.

30 changes: 24 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,14 @@
}
],
"commands": [
{
"command": "powerpages.copilot",
"title": "Power Pages: Copilot"
},
{
"command": "extension.createChatView",
"title": "Create Chat View"
},
{
"command": "pacCLI.openDocumentation",
"category": "Power Platform CLI",
Expand Down Expand Up @@ -306,9 +314,10 @@
"title": "New Page Template"
},
{
"command": "microsoft-powerapps-portals.bootstrap-diff",
"category": "Powerpages",
"title": "Bootstrap Diff"
"command": "powerpages.copilot.clearConversation",
"category": "Power Pages Copilot",
"title": "Clear Conversation",
"icon": "$(clear-all)"
}
],
"configuration": {
Expand Down Expand Up @@ -661,6 +670,10 @@
"command": "pacCLI.authPanel.clearAuthProfile",
"when": "!virtualWorkspace"
},
{
"command": "powerpages.copilot.clearConversation",
"when": "!virtualWorkspace"
},
{
"command": "microsoft-powerapps-portals.webpage",
"when": "config.powerPlatform.generatorInstalled"
Expand Down Expand Up @@ -702,6 +715,11 @@
"command": "pacCLI.envAndSolutionsPanel.refresh",
"when": "!virtualWorkspace && view == pacCLI.envAndSolutionsPanel",
"group": "navigation"
},
{
"command": "powerpages.copilot.clearConversation",
"when": "!virtualWorkspace && view == powerpages.copilot",
"group": "navigation"
}
],
"view/item/context": [
Expand Down Expand Up @@ -864,8 +882,8 @@
"@types/webpack-env": "^1.17.0",
"@typescript-eslint/eslint-plugin": "^5.15.0",
"@typescript-eslint/parser": "^5.15.0",
"@vscode/l10n-dev": "^0.0.24",
"@vscode/test-electron": "^2.3.0",
"@vscode/l10n-dev": "^0.0.23",
"@vscode/test-electron": "^2.1.5",
"@vscode/test-web": "^0.0.24",
"@vscode/vsce": "^2.19.0",
"assert": "^2.0.0",
Expand Down Expand Up @@ -904,7 +922,7 @@
"yargs": "^16.2.0"
},
"dependencies": {
"@microsoft/generator-powerpages": "1.21.19",
"@microsoft/generator-powerpages": "1.21.16",
"@types/jwt-decode": "2.2.0",
"@types/node-fetch": "^2.6.2",
"@vscode/extension-telemetry": "^0.6.2",
Expand Down
15 changes: 8 additions & 7 deletions src/client/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,12 @@ export async function activate(

// registering bootstrapdiff command
_context.subscriptions.push(
vscode.commands.registerCommand('microsoft-powerapps-portals.bootstrap-diff', async() => {
_telemetry.sendTelemetryEvent("StartCommand", {
commandId: "microsoft-powerapps-portals.bootstrap-diff",
});
bootstrapDiff();
}
vscode.commands.registerCommand('microsoft-powerapps-portals.bootstrap-diff', async () => {
_telemetry.sendTelemetryEvent("StartCommand", {
commandId: "microsoft-powerapps-portals.bootstrap-diff",
});
bootstrapDiff();
}
)
);

Expand Down Expand Up @@ -180,7 +180,7 @@ export async function activate(

_telemetry.sendTelemetryEvent("activated");

const copilotProvider = new PowerPagesCopilot(context.extensionUri);
const copilotProvider = new PowerPagesCopilot(context.extensionUri, _context, _telemetry, cliPath);

_context.subscriptions.push(vscode.window.registerWebviewViewProvider('powerpages.copilot', copilotProvider, {
webviewOptions: {
Expand Down Expand Up @@ -318,6 +318,7 @@ function registerClientToReceiveNotifications(client: LanguageClient) {
});
}


function isCurrentDocumentEdited(): boolean {
const workspaceFolderExists =
vscode.workspace.workspaceFolders !== undefined;
Expand Down
2 changes: 1 addition & 1 deletion src/client/lib/AuthPanelView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ class AuthProfileTreeItem extends vscode.TreeItem {
}
}

function GetAuthProfileWatchPattern(): vscode.RelativePattern | undefined {
export function GetAuthProfileWatchPattern(): vscode.RelativePattern | undefined {
if (os.platform() === 'win32') {
return process.env.LOCALAPPDATA
? new vscode.RelativePattern(path.join(process.env.LOCALAPPDATA, "Microsoft", "PowerAppsCli"), "authprofiles*.json")
Expand Down
9 changes: 0 additions & 9 deletions src/common/copilot/Constants.ts

This file was deleted.

78 changes: 78 additions & 0 deletions src/common/copilot/IntelligenceApi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*/

import fetch, { RequestInit } from "node-fetch";
import {sessionID} from "./PowerPagesCopilot";
import { InvalidResponse, NetworkError } from "./constants";


export async function sendApiRequest(userPrompt: string, activeFileParams: string[], orgID:string, apiToken:string, entityName:string, columns: string[]) {

const AIBTestUrl = `https://aibuildertextapiservice.wus-il001.gateway.test.island.powerapps.com/v1.0/${orgID}/appintelligence/chat`

console.log("columns", columns.toString());
const requestBody = {
"question": userPrompt,
"top": 1,
"context": {
"sessionId": sessionID,
"scenario": "PowerPagesProDev",
"subScenario": "PowerPagesProDevGeneric",
"version": "V1",
"information": {
"dataverseEntity": activeFileParams[0],
"entityField": activeFileParams[1],
"fieldType": activeFileParams[2],
"activeFileContent": '',
"targetEntity" : entityName, //TODO: add target entity
"targetColumns": columns //TODO: add target columns
}
}
};


const requestInit: RequestInit = {
method: "POST",
headers: {
'Content-Type': "application/json",
Authorization: `Bearer ${apiToken}`,
},
body: JSON.stringify(requestBody),
}

try {
const response = await fetch(AIBTestUrl, {
...requestInit
});

if (response.ok) {
try {
const jsonResponse = await response.json();
if (jsonResponse.additionalData && Array.isArray(jsonResponse.additionalData) && jsonResponse.additionalData.length > 0) {
const additionalData = jsonResponse.additionalData[0];
if (additionalData.properties && additionalData.properties.response) {
const responseMessage = additionalData.properties.response;
return responseMessage;
}
}
throw new Error("Invalid response format");
} catch (error) {
return InvalidResponse;
}
} else {
try {
const errorResponse = await response.json();
if (errorResponse.error && errorResponse.error.message) {
return [{ displayText: errorResponse.error.message, code: '' }];
}
} catch (error) {
return InvalidResponse;
}
}
} catch (error) {
return NetworkError;
}

}
Loading