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

@alvesfabi OBO Support #803

Merged
merged 76 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
30b55c0
initial version
alvesfabi Jan 29, 2024
bbb1446
in progress with OBO token
alvesfabi Jan 31, 2024
d096fe3
working version native plugin hardcoded
alvesfabi Jan 31, 2024
05d6888
working version odata query
alvesfabi Jan 31, 2024
529ed41
working version persona
alvesfabi Jan 31, 2024
72fb304
working version with app settings
alvesfabi Feb 5, 2024
e17ab92
Merge pull request #1 from alvesfabi/clean-for-pr
alvesfabi Feb 5, 2024
5960d97
cleaned up version
alvesfabi Feb 13, 2024
7e9bc5a
Merge pull request #2 from alvesfabi/clean-for-pr
alvesfabi Feb 13, 2024
bde84da
cleaned up version 3
alvesfabi Feb 13, 2024
f02cb0f
Merge pull request #3 from alvesfabi/clean-for-pr
alvesfabi Feb 13, 2024
0b348f3
improved readme
alvesfabi Feb 13, 2024
2616c56
Merge pull request #4 from alvesfabi/clean-for-pr
alvesfabi Feb 13, 2024
39f2611
fixed obo readme
alvesfabi Feb 14, 2024
683d7a9
Merge pull request #5 from alvesfabi/fixed-readme-obo
alvesfabi Feb 14, 2024
f5a2f2d
Merge remote-tracking branch 'upstream/main'
alvesfabi Feb 14, 2024
da81269
fixed plugin description
alvesfabi Feb 14, 2024
4f402e6
Including OBO Auth Config in PlannerOptions + leveraging existing DI
teresaqhoang Feb 16, 2024
1022cc5
Merge branch 'main' of https://github.com/microsoft/chat-copilot
teresaqhoang Feb 21, 2024
62a9505
update config settins
alvesfabi Feb 22, 2024
00647c4
Merge pull request #7 from alvesfabi/clean-for-pr-3
alvesfabi Feb 22, 2024
2e98d6f
fix for pr
alvesfabi Feb 22, 2024
64d4b2a
Merge pull request #8 from alvesfabi/clean-for-pr-4
alvesfabi Feb 22, 2024
c8566d8
fix text
alvesfabi Feb 22, 2024
003d16c
fix formatting
alvesfabi Feb 22, 2024
4b5bc58
fix formatting with dotnet format
alvesfabi Feb 22, 2024
78fcfef
fix using order
alvesfabi Feb 22, 2024
844c451
fix using order
alvesfabi Feb 22, 2024
a869401
fix using order 2
alvesfabi Feb 22, 2024
0752212
fix typo
alvesfabi Feb 22, 2024
5cfbcb8
fix warnings
alvesfabi Feb 23, 2024
e1ea576
fix more warnings
alvesfabi Feb 23, 2024
f7ea66c
remove local settings
alvesfabi Feb 23, 2024
fc330b2
fixed comments
alvesfabi Feb 27, 2024
96f3942
revert .vscode
alvesfabi Feb 27, 2024
f882c49
revert .vscode 2
alvesfabi Feb 27, 2024
f80ebbf
Merge pull request #9 from alvesfabi/fixes-review
alvesfabi Feb 27, 2024
3867f09
initial merge
alvesfabi Apr 8, 2024
75f3170
initial merge
alvesfabi Apr 8, 2024
f0cbebe
webapp msal fixes
alvesfabi Apr 8, 2024
6b3fbf0
webapp msal fixes
alvesfabi Apr 9, 2024
0242376
test-for-teresa
alvesfabi May 1, 2024
ba9d934
Working MS Graph Obo Plugin
teresaqhoang May 2, 2024
86fae32
test-gtp-4
alvesfabi May 2, 2024
a1d2aaf
Merge branch 'main' of https://github.com/microsoft/chat-copilot into…
alvesfabi May 5, 2024
edec36b
Merge branch 'microsoft-main'
alvesfabi May 5, 2024
013d1e1
workin with merged
alvesfabi May 5, 2024
e631266
formatting fixes
alvesfabi May 6, 2024
090d4fe
space formatting issue
alvesfabi May 6, 2024
01c85a4
space formatting issue
alvesfabi May 6, 2024
9cf6b77
space formatting issue 2
alvesfabi May 6, 2024
0ba89eb
space formatting issue 3
alvesfabi May 6, 2024
73e9f17
Merge pull request #12 from alvesfabi/fixes-over-merged
alvesfabi May 6, 2024
ea6e2b9
fix readme.md
alvesfabi May 6, 2024
662b6af
fix readme.md
alvesfabi May 6, 2024
11334cb
fix readme.md
alvesfabi May 6, 2024
0d760a4
readme fixes 2
alvesfabi May 6, 2024
5717794
readme fixes 3
alvesfabi May 6, 2024
690d5a8
readme fixes 4
alvesfabi May 6, 2024
90ed2d4
fix json response
alvesfabi May 6, 2024
2a5d2e3
fix json response 2
alvesfabi May 6, 2024
a0719a8
fix json response 3
alvesfabi May 8, 2024
a18b0b3
fix json response 4
alvesfabi May 8, 2024
4dedf43
fix in doc and remove token control
alvesfabi May 9, 2024
75e657b
fix remove token limit
alvesfabi May 9, 2024
bde294d
fix remove token limit
alvesfabi May 9, 2024
69bf834
fix remove token limit
alvesfabi May 9, 2024
f4ec445
Merge pull request #13 from alvesfabi/fix-doc-obo
alvesfabi May 9, 2024
1eb3b1e
fix obo readme doc 2
alvesfabi May 10, 2024
da6a3d5
Merge pull request #14 from alvesfabi/fix-doc-obo
alvesfabi May 10, 2024
02f2708
Update plugins/OBO/README.md
alvesfabi May 10, 2024
849f88e
Update webapi/Controllers/ChatController.cs
alvesfabi May 10, 2024
2ae555d
Addressing comments
teresaqhoang May 10, 2024
a5a5b1f
get changes from index.ts
alvesfabi May 11, 2024
015d564
Merge branch 'main' of https://github.com/microsoft/chat-copilot
alvesfabi May 11, 2024
9d84e41
get changes msal fix for version changes
alvesfabi May 11, 2024
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
41 changes: 39 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"version": "0.2.0",
teresaqhoang marked this conversation as resolved.
Show resolved Hide resolved
"configurations": [

{
"name": "Debug CopilotChatWebApi",
"type": "coreclr",
Expand All @@ -11,7 +10,45 @@
"cwd": "${workspaceFolder}/webapi",
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
}
},
{
"name": "Attach to .NET Functions",
"type": "coreclr",
"request": "attach",
"processId": "${command:azureFunctions.pickProcess}"
},
{
"type": "node-terminal",
"name": "Run Script: start",
"request": "launch",
"command": "yarn start",
"cwd": "${workspaceFolder}\\webapp"
},
{
"type": "node",
"request": "launch",
"name": "TypeScript",
"runtimeArgs": ["-r", "ts-node/register/transpile-only"],
"env": {"TS_NODE_COMPILER_OPTIONS": "{\"jsx\": \"react\"}"},
"args": ["${workspaceFolder}/webapp/src/index.tsx"], // replace with your entry point
"outputCapture": "std",
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"cwd": "${workspaceFolder}/webapp"
},
{
"type": "pwa-node",
"request": "launch",
"name": "Debug TypeScript",
"runtimeArgs": ["-r", "ts-node/register"],
"args": ["${workspaceFolder}/webapp/src/index.tsx"], // replace with your entry point
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"cwd": "${workspaceFolder}/webapp",
"env": {
"TS_NODE_PROJECT": "${workspaceFolder}/webapp/tsconfig.json"
}
}
]
}
117 changes: 64 additions & 53 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,54 +1,65 @@
{
teresaqhoang marked this conversation as resolved.
Show resolved Hide resolved
"prettier.enable": true,
"editor.formatOnType": true,
"editor.formatOnSave": true,
"editor.formatOnPaste": true,
"[csharp]": {
"editor.defaultFormatter": "ms-dotnettools.csharp",
"editor.codeActionsOnSave": {
"source.fixAll": true
}
},
"editor.bracketPairColorization.enabled": true,
"editor.guides.bracketPairs": "active",
"javascript.updateImportsOnFileMove.enabled": "always",
"search.exclude": {
"**/node_modules": true,
"**/build": true
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.codeActionsOnSave": {
"source.organizeImports": true,
"source.fixAll": true
}
},
"[typescriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.codeActionsOnSave": {
"source.organizeImports": true,
"source.fixAll": true
}
},
"typescript.updateImportsOnFileMove.enabled": "always",
"eslint.enable": true,
"eslint.lintTask.enable": true,
"eslint.workingDirectories": [
{
"mode": "auto"
}
],
"files.associations": {
"*.json": "jsonc"
},
"files.exclude": {
"**/.git": true,
"**/.hg": true,
"**/CVS": true,
"**/.DS_Store": true,
"**/Thumbs.db": true,
"**.lock": true,
},
"dotnet.defaultSolution": "CopilotChat.sln",
"editor.tabSize": 2,
}
"prettier.enable": true,
"editor.formatOnType": true,
"editor.formatOnSave": false,
"editor.formatOnPaste": true,
"[csharp]": {
"editor.defaultFormatter": "ms-dotnettools.csharp",
"editor.codeActionsOnSave": {
"source.fixAll": "explicit"
}
},
"editor.bracketPairColorization.enabled": true,
"editor.guides.bracketPairs": "active",
"javascript.updateImportsOnFileMove.enabled": "always",
"search.exclude": {
"**/node_modules": true,
"**/build": true
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.codeActionsOnSave": {
"source.organizeImports": true,
"source.fixAll": true
}
},
"[typescriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.codeActionsOnSave": {
"source.organizeImports": true,
"source.fixAll": true
}
},
"typescript.updateImportsOnFileMove.enabled": "always",
"eslint.enable": true,
"eslint.lintTask.enable": true,
"eslint.workingDirectories": [
{
"mode": "auto"
}
],
"files.associations": {
"*.json": "jsonc"
},
"files.exclude": {
"**/.git": true,
"**/.hg": true,
"**/CVS": true,
"**/.DS_Store": true,
"**/Thumbs.db": true,
"**.lock": true
},
"dotnet.defaultSolution": "CopilotChat.sln",
"editor.tabSize": 2,
"[typescript][typescriptreact]": {
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit",
"source.fixAll": "explicit"
}
},
"azureFunctions.deploySubpath": "plugins\\web-searcher/bin/Release/net6.0/publish",
"azureFunctions.projectLanguage": "C#",
"azureFunctions.projectRuntime": "~4",
"debug.internalConsoleOptions": "neverOpen",
"azureFunctions.preDeployTask": "publish (functions)"
}
97 changes: 89 additions & 8 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
{
"version": "2.0.0",
"tasks": [
// Copilot Chat
{
"label": "run (Copilot Chat)",
"detail": "Run all copilot chat components",
"group": "test",
"dependsOn": ["run (CopilotChatWebApi)", "run (CopilotChatApp)"],
"dependsOn": [
"run (CopilotChatWebApi)",
"run (CopilotChatApp)"
],
"dependsOrder": "parallel"
},
// Copilot Setup
{
"label": "install (CopilotChatApp)",
"detail": "Install all copilot chat app dependencies",
Expand All @@ -32,20 +33,25 @@
"label": "setup (Copilot Chat)",
"detail": "Setup (like setting secrets) for copilot chat app and api",
"group": "test",
"dependsOn": ["GetSecret (AIService:Key)"],
"dependsOn": [
"GetSecret (AIService:Key)"
],
"dependsOrder": "sequence"
// TODO -- add tasks for configuring environment variables
},
{
"label": "GetSecret (AIService:Key)",
"command": "dotnet",
"type": "process",
"args": ["user-secrets", "set", "AIService:Key", "${input:aiServiceSecret}"],
"args": [
"user-secrets",
"set",
"AIService:Key",
"${input:aiServiceSecret}"
],
"options": {
"cwd": "${workspaceFolder}/webapi"
}
},
// Copilot Chat App
{
"label": "build (CopilotChatApp)",
"type": "shell",
Expand Down Expand Up @@ -76,7 +82,6 @@
"cwd": "${workspaceFolder}/webapp"
}
},
// Copilot Chat Api
{
"label": "build (CopilotChatWebApi)",
"command": "dotnet",
Expand Down Expand Up @@ -120,6 +125,82 @@
],
"problemMatcher": "$msCompile",
"group": "build"
},
{
"label": "clean (functions)",
"command": "dotnet",
"args": [
"clean",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"type": "process",
"problemMatcher": "$msCompile",
"options": {
"cwd": "${workspaceFolder}/plugins\\web-searcher"
}
},
{
"label": "build (functions)",
"command": "dotnet",
"args": [
"build",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"type": "process",
"dependsOn": "clean (functions)",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": "$msCompile",
"options": {
"cwd": "${workspaceFolder}/plugins\\web-searcher"
}
},
{
"label": "clean release (functions)",
"command": "dotnet",
"args": [
"clean",
"--configuration",
"Release",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"type": "process",
"problemMatcher": "$msCompile",
"options": {
"cwd": "${workspaceFolder}/plugins\\web-searcher"
}
},
{
"label": "publish (functions)",
"command": "dotnet",
"args": [
"publish",
"--configuration",
"Release",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"type": "process",
"dependsOn": "clean release (functions)",
"problemMatcher": "$msCompile",
"options": {
"cwd": "${workspaceFolder}/plugins\\web-searcher"
}
},
{
"type": "func",
"dependsOn": "build (functions)",
"options": {
"cwd": "${workspaceFolder}/plugins\\web-searcher/bin/Debug/net6.0"
},
"command": "host start",
"isBackground": true,
"problemMatcher": "$func-dotnet-watch"
}
],
"inputs": [
Expand Down
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,29 @@ By default, Chat Copilot runs locally without authentication, using a guest user
./start.sh
```


## Optional Configuration: [API Connector Graph API Plugin with On-Behalf-Of Flow](./plugins/OBO/README.md)

This native plugin enables the execution of Microsoft Graph APIs using the On-Behalf-Of (OBO) flow with delegated permissions.

The OBO flows is used to ensure that the backend APIs are consumed with the identity of the user, not the managed identity or service principal of the middle-tier application (in this case the WebApi).

Also, this ensures that consent is given, so that the client app (WebApp) can call the middle-tier app (WebApi), and the middle-tier app has permission to call the back-end resource (MSGraph).

This sample does not implement incremental consent in the UI so all the Graph scopes to be used need to have "Administrator Consent" given in the middle-tier app registration.

More information in the [OBO readme.md](./plugins/OBO/README.md).

### Requirements
Backend authentication via Azure AD must be enabled. Detailed instructions for enabling backend authentication are provided below.

### Limitations

- Currently, the plugin only supports GET operations. Future updates may add support for other types of operations.
- Graph queries that return large results, may reach the token limit for the AI model, producing an error.
- Incremental consent is not implemented in this sample.


# Troubleshooting

1. **_Issue:_** Unable to load chats.
Expand Down
38 changes: 38 additions & 0 deletions chat azure open ai dev settings.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
teresaqhoang marked this conversation as resolved.
Show resolved Hide resolved
"Planner": {
"Model": "gpt-35-turbo"
},
"Frontend": {
"AadClientId": "bbe4a863-a36c-4243-9259-c54c468389ea"
},
"KernelMemory": {
"Services": {
"AzureOpenAIEmbedding": {
"Endpoint": "https://aadconfigassessment.openai.azure.com/",
"Deployment": "text-embedding-ada-002"
},
"AzureOpenAIText": {
"Endpoint": "https://aadconfigassessment.openai.azure.com/",
"Deployment": "gpt-35-turbo"
}
},
"TextGeneratorType": "AzureOpenAI",
"DataIngestion": {
"EmbeddingGeneratorTypes": [
"AzureOpenAI"
]
},
"Retrieval": {
"EmbeddingGeneratorType": "AzureOpenAI"
}
},
"Authentication": {
"AzureAd": {
"ClientId": "384525a6-b975-4add-b74b-a001955c9426",
"TenantId": "070c2354-e90f-42bb-a620-185a7cbc8f19",
"Scopes": "access_as_user",
"Instance": "https://login.microsoftonline.com"
},
"Type": "AzureAd"
}
}
Loading
Loading