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

Adding support for custom plugin import #29

Merged
merged 13 commits into from
Jul 25, 2023

Conversation

teresaqhoang
Copy link
Contributor

@teresaqhoang teresaqhoang commented Jul 25, 2023

Motivation and Context

This PR adds support for custom plugins. This implementation follows manifest requirements set by OpenAI for custom ChatGPT plugins and is defined here: https://learn.microsoft.com/en-us/semantic-kernel/ai-orchestration/chatgpt-plugins#add-the-plugin-manifest-file

Description

webapi

  • Added GetPluginAuthHeaders() to ChatController.cs to parse plugin auth values from request headers. This was manually parsed using hardcoded headers before.
    • Standardized all plugin headers to x-sk-copilot-(.*)-auth
  • Updated RegisterPlannerSkillsAsync() to accept a Dictionary of auth headers and register authenticated skills with the planner's kernel.
  • Added logic to register custom plugins from context variables, including support for loading custom plugins from manifest files with authentication support for user PAT and no auth.

webapp

  • General
    • Added .well-known* to .gitignore.
    • Consolidated all hooks into libs/hooks directory. Updated imports accordingly
    • Consolidated dialog styles into shared class
  • Create BaseCard component to render a generic card.
    • Add AddPluginCard component to render a card for adding custom plugins. Card action triggers Plugin Wizard
    • Create PluginCard component to render a card for existing plugins.
  • Fix PluginGallery component to use new PluginCard and AddPluginCard components.
  • Update PluginConnector component to use new Dialog classes.
  • Remove unused code from PluginCard and PluginConnector components.
  • Create PluginWizard component to handle custom plugin import. Includes three steps: EnterManifestStep, ValidateManifestStep, and a confirmation page
  • Manifest Validation:
    • Domain is a valid URL (doesn't throw when constructed using new URL)
    • Meets all the property requirements as defined by OpenAI
  • If manifest domain is valid and user imports plugin, a new card will be added for that plugin at the end of the plugin gallery. User must explicitly enable the plugin before it's used with the planner.
  • If plugin is enabled, header matching x-sk-copilot-{pluginNameForModel}-auth is added to request for bot response.

New Plugin Gallery look with Import card
image

New card for custom plugin added to gallery
image

Plugin Wizard
image

  • If URL is invalid:
    image

Validate Manifest Step
image

  • If Manifest validation fails:
    image

Confirmation
image

Enabling custom Plugin
image

Once user enables plugin, sample request herader:
image

Planner integration
image

Contribution Checklist

@teresaqhoang teresaqhoang added webapp Pull requests that update Typescript code webapi Pull requests that update .net code PR: ready to merge PR has been approved by all reviewers, and is ready to merge. labels Jul 25, 2023
@teresaqhoang teresaqhoang marked this pull request as ready for review July 25, 2023 15:28
@teresaqhoang teresaqhoang self-assigned this Jul 25, 2023
@teresaqhoang teresaqhoang added enhancement New feature or request PR: ready for review and removed PR: ready to merge PR has been approved by all reviewers, and is ready to merge. labels Jul 25, 2023
TaoChenOSU
TaoChenOSU previously approved these changes Jul 25, 2023
dehoward
dehoward previously approved these changes Jul 25, 2023
@teresaqhoang teresaqhoang added PR: ready to merge PR has been approved by all reviewers, and is ready to merge. and removed PR: ready for review labels Jul 25, 2023
alliscode
alliscode previously approved these changes Jul 25, 2023
@alliscode alliscode added this pull request to the merge queue Jul 25, 2023
Merged via the queue into microsoft:main with commit 841ce2d Jul 25, 2023
7 checks passed
@teresaqhoang teresaqhoang deleted the custom-chatgpt-plugins branch August 11, 2023 15:26
teamleader-dev pushed a commit to vlink-group/chat-copilot that referenced this pull request Oct 7, 2024
### Motivation and Context

<!-- Thank you for your contribution to the copilot-chat repo!
Please help reviewers and future users, providing the following
information:
  1. Why is this change required?
  2. What problem does it solve?
  3. What scenario does it contribute to?
  4. If it fixes an open issue, please link to the issue here.
-->

This PR adds support for custom plugins. This implementation follows
manifest requirements set by OpenAI for custom ChatGPT plugins and is
defined here:
https://learn.microsoft.com/en-us/semantic-kernel/ai-orchestration/chatgpt-plugins#add-the-plugin-manifest-file

### Description

<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->

webapi
- Added GetPluginAuthHeaders() to ChatController.cs to parse plugin auth
values from request headers. This was manually parsed using hardcoded
headers before.
    - Standardized all plugin headers to `x-sk-copilot-(.*)-auth`
- Updated RegisterPlannerSkillsAsync() to accept a Dictionary of auth
headers and register authenticated skills with the planner's kernel.
- Added logic to register custom plugins from context variables,
including support for loading custom plugins from manifest files with
authentication support for user PAT and no auth.

webapp
- General
    - Added .well-known* to .gitignore. 
- Consolidated all hooks into `libs/hooks` directory. Updated imports
accordingly
    - Consolidated dialog styles into shared class
- Create BaseCard component to render a generic card. 
- Add AddPluginCard component to render a card for adding custom
plugins. Card action triggers Plugin Wizard
- Create PluginCard component to render a card for existing plugins.
- Fix PluginGallery component to use new PluginCard and AddPluginCard
components.
- Update PluginConnector component to use new Dialog classes. 
- Remove unused code from PluginCard and PluginConnector components. 
- Create PluginWizard component to handle custom plugin import. Includes
three steps: `EnterManifestStep`, `ValidateManifestStep`, and a
confirmation page
- Manifest Validation:
- Domain is a valid URL (doesn't throw when constructed using new URL)
- Meets all the property requirements as [defined by
OpenAI](https://learn.microsoft.com/en-us/semantic-kernel/ai-orchestration/chatgpt-plugins#add-the-plugin-manifest-file)
- If manifest domain is valid and user imports plugin, a new card will
be added for that plugin at the end of the plugin gallery. User must
explicitly enable the plugin before it's used with the planner.
- If plugin is enabled, header matching
x-sk-copilot-{pluginNameForModel}-auth is added to request for bot
response.

New Plugin Gallery look with Import card

![image](https:/microsoft/chat-copilot/assets/125500434/5e3b54c4-a674-4dc2-a5d3-b2231edea2f1)

New card for custom plugin added to gallery

![image](https:/microsoft/chat-copilot/assets/125500434/1573a69f-8d8d-4260-ab1d-64c7feb07700)


Plugin Wizard

![image](https:/microsoft/chat-copilot/assets/125500434/4277b93c-3b0a-4ccc-ae40-ff5e06d21ec3)
- If URL is invalid:

![image](https:/microsoft/chat-copilot/assets/125500434/4ff37cc5-34e7-48c7-8814-50330c3c7da4)

Validate Manifest Step

![image](https:/microsoft/chat-copilot/assets/125500434/e40a7933-8e99-42a4-bd39-907fa9f5378a)
- If Manifest validation fails:

![image](https:/microsoft/chat-copilot/assets/125500434/4c735a40-82df-4a7d-b828-8b13c6b17ba1)

Confirmation

![image](https:/microsoft/chat-copilot/assets/125500434/bfa3e4e6-6d01-43a3-8ad2-ba68b5b48a01)

Enabling custom Plugin

![image](https:/microsoft/chat-copilot/assets/125500434/ffaed95b-822c-422b-afaa-84f5eef07d64)

Once user enables plugin, sample request herader:

![image](https:/microsoft/chat-copilot/assets/125500434/8e888ce7-2ebd-440c-907d-4a9270e32850)

Planner integration

![image](https:/microsoft/chat-copilot/assets/125500434/23e45c8b-28a4-4506-b995-c6750977e6b7)

### Contribution Checklist

<!-- Before submitting this PR, please make sure: -->

- [x] The code builds clean without any errors or warnings
- [x] The PR follows the [Contribution
Guidelines](https:/microsoft/copilot-chat/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https:/microsoft/copilot-chat/blob/main/CONTRIBUTING.md#dev-scripts)
raises no violations
~~- [ ] All unit tests pass, and I have added new tests where possible~~
- [x] I didn't break anyone 😄
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request PR: ready to merge PR has been approved by all reviewers, and is ready to merge. webapi Pull requests that update .net code webapp Pull requests that update Typescript code
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

6 participants