Skip to content

OpenAPI Skill server-url configurations#797

Merged
adrianwyatt merged 23 commits into
microsoft:mainfrom
teresaqhoang:prohibit-planner-server-url-override
May 5, 2023
Merged

OpenAPI Skill server-url configurations#797
adrianwyatt merged 23 commits into
microsoft:mainfrom
teresaqhoang:prohibit-planner-server-url-override

Conversation

@teresaqhoang

@teresaqhoang teresaqhoang commented May 3, 2023

Copy link
Copy Markdown
Contributor

Motivation and Context

1. Add default parameter values for available functions on Plan creation (ActionPlanner)

  • This commit changes the PopulateList function to include the default value of each parameter in the generated string. This makes the list of available functions more informative and helpful for LLM to know the default behavior of a function. The default value is shown in parentheses after the parameter description.

  • This is helpful in parsing the correct server-url for OpenAPI functions (before, the planner was suggesting arbitrary values that were more-than-intermittently wrong).

2. Add support to override the server-url from user input

  • User input is passed as customer variable in Ask context when SK is invoked in the format {openApiSkillName}-server-url
  • This can then be parsed in the SemanticKernelController and passed to the Import method
    i.e.,
if (openApiSkillsAuthHeaders.JiraAuthentication != null)
        {
            this._logger.LogInformation("Registering Jira Skill");
            var authenticationProvider = new BasicAuthenticationProvider(() => { return Task.FromResult(openApiSkillsAuthHeaders.JiraAuthentication); });
            var hasServerUrlOverride = variables.Get("jira-server-url", out string serverUrlOverride);

            await planner.Kernel.ImportOpenApiSkillFromFileAsync(
                skillName: "JiraSkill",
                filePath: Path.Combine(System.IO.Directory.GetCurrentDirectory(), @"Skills/OpenApiSkills/JiraSkill/openapi.json"),
                authCallback: authenticationProvider.AuthenticateRequestAsync,
                serverUrlOverride: hasServerUrlOverride ? serverUrlOverride : null
                );
        }
  1. Adds missing user-agent parameter to all ImportOpenApiSkill methods for consistency

@teresaqhoang teresaqhoang added PR: ready for review All feedback addressed, ready for reviews planner Anything related to planner or plans kernel Issues or pull requests impacting the core kernel labels May 3, 2023
amsacha
amsacha previously approved these changes May 3, 2023
@github-actions github-actions Bot added the .NET Issue or Pull requests regarding .NET code label May 3, 2023
Comment thread dotnet/src/Extensions/Planning.ActionPlanner/ActionPlanner.cs Outdated
Comment thread dotnet/src/Extensions/Planning.ActionPlanner/ActionPlanner.cs Outdated
Comment thread dotnet/src/Extensions/Planning.ActionPlanner/ActionPlanner.cs Outdated
@adrianwyatt adrianwyatt added PR: feedback to address Waiting for PR owner to address comments/questions and removed PR: ready for review All feedback addressed, ready for reviews labels May 3, 2023
@adrianwyatt

This comment was marked as resolved.

lemillermicrosoft

This comment was marked as resolved.

adrianwyatt
adrianwyatt previously approved these changes May 4, 2023
@adrianwyatt adrianwyatt self-requested a review May 4, 2023 00:34
teresaqhoang and others added 4 commits May 3, 2023 21:33
### Motivation and Context
This PR enables GitHub integration with Copilot Planner. 


### Description
Server-side
- Added C# classes for GitHub schema objects
- Adds tokenLimit for Planner response content. Currently, it's set at
75% of the remaining limit after memories response and document context
have already been allocated.
- Added `OptimizeOpenApiSkillJson` method that is called on Planner
completion. This method:
- removes all new line characters (huge token suck) from API response
- truncates the API response by object until it's under the
relatedInformationTokenLimit.
- If the request can't be truncated, error message added to bot context
- For GitHub skills specifically, the API response is deserialized into
`PullRequest` or `PullRequest[]` objects to filter noisy properties.

Web app side
- If plugins require additional api requirements, these are added to the
ask variables (rather than headers in http request) -- this allows the
kernel/planner to directly consume these without any additional handling
server side
- `repo` and `owner` added as additional GitHub api requirements
- Rename ApiRequirements to ApiProperties. These properties can be
optional.


![image](https://user-images.githubusercontent.com/125500434/236005717-14016432-b5de-47b3-a128-e38418c267e3.png)
@teresaqhoang teresaqhoang changed the title Removing server-url from suggested Planner parameters Add default parameter values for available functions on Plan creation (ActionPlanner) May 4, 2023
@teresaqhoang teresaqhoang added PR: ready for review All feedback addressed, ready for reviews and removed PR: feedback to address Waiting for PR owner to address comments/questions labels May 5, 2023
adrianwyatt
adrianwyatt previously approved these changes May 5, 2023
@adrianwyatt adrianwyatt added PR: ready to merge PR has been approved by all reviewers, and is ready to merge. and removed PR: ready for review All feedback addressed, ready for reviews labels May 5, 2023
Comment thread dotnet/src/Skills/Skills.OpenAPI/Extensions/RestApiOperationExtensions.cs Outdated
Comment thread dotnet/src/Skills/Skills.OpenAPI/Extensions/KernelOpenApiExtensions.cs Outdated
adrianwyatt
adrianwyatt previously approved these changes May 5, 2023
@adrianwyatt adrianwyatt enabled auto-merge (squash) May 5, 2023 18:52
@adrianwyatt adrianwyatt disabled auto-merge May 5, 2023 18:54
@adrianwyatt adrianwyatt merged commit f1448c9 into microsoft:main May 5, 2023
@teresaqhoang teresaqhoang mentioned this pull request May 8, 2023
5 tasks
@teresaqhoang teresaqhoang deleted the prohibit-planner-server-url-override branch May 15, 2023 16:59
codebrain pushed a commit to searchpioneer/semantic-kernel that referenced this pull request May 16, 2023
### Motivation and Context
**1. Add default parameter values for available functions on Plan
creation (ActionPlanner)**

- This commit changes the `PopulateList` function to include the default
value of each parameter in the generated string. This makes the list of
available functions more informative and helpful for LLM to know the
default behavior of a function. The default value is shown in
parentheses after the parameter description.

- This is helpful in parsing the correct server-url for OpenAPI
functions (before, the planner was suggesting arbitrary values that were
more-than-intermittently wrong).


**2. Add support to override the server-url from user input**

- User input is passed as customer variable in Ask context when SK is
invoked in the format {openApiSkillName}-server-url
- This can then be parsed in the `SemanticKernelController` and passed
to the Import method
i.e., 
```
if (openApiSkillsAuthHeaders.JiraAuthentication != null)
        {
            this._logger.LogInformation("Registering Jira Skill");
            var authenticationProvider = new BasicAuthenticationProvider(() => { return Task.FromResult(openApiSkillsAuthHeaders.JiraAuthentication); });
            var hasServerUrlOverride = variables.Get("jira-server-url", out string serverUrlOverride);

            await planner.Kernel.ImportOpenApiSkillFromFileAsync(
                skillName: "JiraSkill",
                filePath: Path.Combine(System.IO.Directory.GetCurrentDirectory(), @"Skills/OpenApiSkills/JiraSkill/openapi.json"),
                authCallback: authenticationProvider.AuthenticateRequestAsync,
                serverUrlOverride: hasServerUrlOverride ? serverUrlOverride : null
                );
        }
```

3. Adds missing user-agent parameter to all ImportOpenApiSkill methods
for consistency

---------

Co-authored-by: Adrian Bonar <[email protected]>
Co-authored-by: Adrian Bonar (HE/HIM) <[email protected]>
dehoward pushed a commit to lemillermicrosoft/semantic-kernel that referenced this pull request Jun 1, 2023
### Motivation and Context
**1. Add default parameter values for available functions on Plan
creation (ActionPlanner)**

- This commit changes the `PopulateList` function to include the default
value of each parameter in the generated string. This makes the list of
available functions more informative and helpful for LLM to know the
default behavior of a function. The default value is shown in
parentheses after the parameter description.

- This is helpful in parsing the correct server-url for OpenAPI
functions (before, the planner was suggesting arbitrary values that were
more-than-intermittently wrong).


**2. Add support to override the server-url from user input**

- User input is passed as customer variable in Ask context when SK is
invoked in the format {openApiSkillName}-server-url
- This can then be parsed in the `SemanticKernelController` and passed
to the Import method
i.e., 
```
if (openApiSkillsAuthHeaders.JiraAuthentication != null)
        {
            this._logger.LogInformation("Registering Jira Skill");
            var authenticationProvider = new BasicAuthenticationProvider(() => { return Task.FromResult(openApiSkillsAuthHeaders.JiraAuthentication); });
            var hasServerUrlOverride = variables.Get("jira-server-url", out string serverUrlOverride);

            await planner.Kernel.ImportOpenApiSkillFromFileAsync(
                skillName: "JiraSkill",
                filePath: Path.Combine(System.IO.Directory.GetCurrentDirectory(), @"Skills/OpenApiSkills/JiraSkill/openapi.json"),
                authCallback: authenticationProvider.AuthenticateRequestAsync,
                serverUrlOverride: hasServerUrlOverride ? serverUrlOverride : null
                );
        }
```

3. Adds missing user-agent parameter to all ImportOpenApiSkill methods
for consistency

---------

Co-authored-by: Adrian Bonar <[email protected]>
Co-authored-by: Adrian Bonar (HE/HIM) <[email protected]>
golden-aries pushed a commit to golden-aries/semantic-kernel that referenced this pull request Oct 10, 2023
### Motivation and Context
**1. Add default parameter values for available functions on Plan
creation (ActionPlanner)**

- This commit changes the `PopulateList` function to include the default
value of each parameter in the generated string. This makes the list of
available functions more informative and helpful for LLM to know the
default behavior of a function. The default value is shown in
parentheses after the parameter description.

- This is helpful in parsing the correct server-url for OpenAPI
functions (before, the planner was suggesting arbitrary values that were
more-than-intermittently wrong).


**2. Add support to override the server-url from user input**

- User input is passed as customer variable in Ask context when SK is
invoked in the format {openApiSkillName}-server-url
- This can then be parsed in the `SemanticKernelController` and passed
to the Import method
i.e., 
```
if (openApiSkillsAuthHeaders.JiraAuthentication != null)
        {
            this._logger.LogInformation("Registering Jira Skill");
            var authenticationProvider = new BasicAuthenticationProvider(() => { return Task.FromResult(openApiSkillsAuthHeaders.JiraAuthentication); });
            var hasServerUrlOverride = variables.Get("jira-server-url", out string serverUrlOverride);

            await planner.Kernel.ImportOpenApiSkillFromFileAsync(
                skillName: "JiraSkill",
                filePath: Path.Combine(System.IO.Directory.GetCurrentDirectory(), @"Skills/OpenApiSkills/JiraSkill/openapi.json"),
                authCallback: authenticationProvider.AuthenticateRequestAsync,
                serverUrlOverride: hasServerUrlOverride ? serverUrlOverride : null
                );
        }
```

3. Adds missing user-agent parameter to all ImportOpenApiSkill methods
for consistency

---------

Co-authored-by: Adrian Bonar <[email protected]>
Co-authored-by: Adrian Bonar (HE/HIM) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kernel Issues or pull requests impacting the core kernel .NET Issue or Pull requests regarding .NET code planner Anything related to planner or plans PR: ready to merge PR has been approved by all reviewers, and is ready to merge.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants