### Motivation and Context
Add support for creating calendar events on Copilot Plugin Agents
<!-- Thank you for your contribution to the semantic-kernel 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.
-->
### Description
Add support for creating calendar events on Copilot Plugin Agents
<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->
### Contribution Checklist
<!-- Before submitting this PR, please make sure: -->
- [ ] The code builds clean without any errors or warnings
- [ ] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [ ] All unit tests pass, and I have added new tests where possible
- [ ] I didn't break anyone 😄
### Description
This PR adds the following:
- A README file for the Processes with Dapr demo application to help
explain how to run it and understand what is happening.
- Cleans up naming of things within the demo and adds Console output to
help follow execution of the process.
- Improves tasks and launch config in VS Code and adds the Dapr
extension as a recommended extension.
### Contribution Checklist
<!-- Before submitting this PR, please make sure: -->
- [x] The code builds clean without any errors or warnings
- [x] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [x] All unit tests pass, and I have added new tests where possible
- [x] I didn't break anyone 😄
---------
Co-authored-by: Ben Thomas <[email protected]>
### Description
This PR adds the Dapr runtime for Processes. The runtime is very similar
in concept to the local runtime with a few changes to accommodate the
single threaded remote actors.
A new Demo has also been added called `ProcessWithDapr` that shows a
asp.net core service with Dapr configured. The sample has a single API
that triggers a simple process to run within Dapr. This sample is still
very basic and more work is needed to demonstrate all the patterns that
can be used with Processes.
### Contribution Checklist
<!-- Before submitting this PR, please make sure: -->
- [x] The code builds clean without any errors or warnings
- [x] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [x] All unit tests pass, and I have added new tests where possible
- [x] I didn't break anyone 😄
---------
Co-authored-by: Ben Thomas <[email protected]>
### Description
This PR is the first in a series that will enable the Dapr runtime for
Processes. This change makes adjustments to the abstractions and core
builder that are mainly focused on supporting the DataContract
serialization used for Dapr actor remoted function calling.
### Contribution Checklist
<!-- Before submitting this PR, please make sure: -->
- [x] The code builds clean without any errors or warnings
- [x] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [x] All unit tests pass, and I have added new tests where possible
- [x] I didn't break anyone 😄
---------
Co-authored-by: Ben Thomas <[email protected]>
Co-authored-by: Chris <[email protected]>
### Motivation and Context
<!-- Thank you for your contribution to the semantic-kernel 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.
-->
Switches from poetry to uv
much faster and easier lock management
easier maintenance of pyproject.toml
fixes: #6584fixes: #8326
### Description
<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->
### Contribution Checklist
<!-- Before submitting this PR, please make sure: -->
- [x] The code builds clean without any errors or warnings
- [x] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [x] All unit tests pass, and I have added new tests where possible
- [ ] I didn't break anyone 😄
### Motivation and Context
Closes#6166
### Description
<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->
### Contribution Checklist
<!-- Before submitting this PR, please make sure: -->
- [ ] The code builds clean without any errors or warnings
- [ ] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [ ] All unit tests pass, and I have added new tests where possible
- [ ] I didn't break anyone 😄
## Phase 2 - Sample Restructuring
- Removal of Examples numbering
- Decomposing `KernelSyntaxExamples` into meaningful Feature base
folders within `Concepts`.
- Update current sample projects to use `sample` centric
`InternalUtilities` reducing code repetition
- Update SDK projects type to be correctly idenfified as xUnit Test
projects
- Update projects to be implicit using friendly, reducing considerably
the extra lines of code for every sample.
- Decomposing `Concepts\AgentSyntax` into `Concepts\Agents`
- Decomposing `Concepts\AgentSyntax\GettingStarted` into a new root
dedicated `GettingStartedWithAgents`
### Motivation and Context
<!-- Thank you for your contribution to the semantic-kernel 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.
-->
### Description
<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->
### Contribution Checklist
<!-- Before submitting this PR, please make sure: -->
- [ ] The code builds clean without any errors or warnings
- [ ] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [ ] All unit tests pass, and I have added new tests where possible
- [ ] I didn't break anyone 😄
### Motivation and Context
Adds a simple sample windows forms application to the `dotnet/samples`
folder for guidance on how to use `ImageToText` services.
### Contribution Checklist
<!-- Before submitting this PR, please make sure: -->
- [x] The code builds clean without any errors or warnings
- [x] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [x] All unit tests pass, and I have added new tests where possible
- [x] I didn't break anyone 😄
### Motivation and Context
Currently, users in Python have no ability to configure default_headers
for the AzureOpenAI/OpenAI clients we use. Additionally, if a user wants
to set up their own AzureOpenAI/OpenAI client, this isn't possible. This
PR addresses #2895.
<!-- Thank you for your contribution to the semantic-kernel 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.
-->
### Description
Allow users to set default_headers for Chat/Text/Embedding Completion
classes for both OpenAI and AzureOpenAI. Additionally, allow users to
pass in a customer OpenAI/AzureOpenAI client, if desired. Update tests
accordingly.
<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->
### Contribution Checklist
<!-- Before submitting this PR, please make sure: -->
- [ ] The code builds clean without any errors or warnings
- [ ] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [ ] All unit tests pass, and I have added new tests where possible
- [ ] I didn't break anyone 😄
---------
Co-authored-by: Evan Mattson <[email protected]>
### Motivation and Context
Adding the experimental attribute to packages and classes in the .NET
SDK of Semantic Kernel to mark things that won't be ready be v1.0.0 of
Semantic Kernel.
### Contribution Checklist
- [ ] The code builds clean without any errors or warnings
- [ ] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [ ] All unit tests pass, and I have added new tests where possible
- [ ] I didn't break anyone 😄
---------
Co-authored-by: Mark Wallace <[email protected]>
### Motivation and Context
<!-- Thank you for your contribution to the semantic-kernel 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.
-->
### Description
<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->
### Contribution Checklist
<!-- Before submitting this PR, please make sure: -->
- [ ] The code builds clean without any errors or warnings
- [ ] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [ ] All unit tests pass, and I have added new tests where possible
- [ ] I didn't break anyone 😄
---------
Co-authored-by: Ben Thomas <[email protected]>
Fixes#2831
This commit adds a try-catch block to handle SKException when
converting planResultString to a Plan object using the
ToPlanFromXml method. It provides a more informative error message
including the goal and relevant functions in case of failure.
### Contribution Checklist
<!-- Before submitting this PR, please make sure: -->
- [x] The code builds clean without any errors or warnings
- [x] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [x] All unit tests pass, and I have added new tests where possible
- [x] I didn't break anyone 😄
### Motivation and Context
Make it easier to run individual examples in the KernelSyntaxExamples
project.
### Description
This commit combines the updates to launch.json, tasks.json, and
Program.cs to allow passing arguments to the main method and running
examples based on the provided filter. The list of examples in
Program.cs has also been updated to include new examples and ensure
proper execution. These changes make it easier to run specific examples
without having to run all of them and improve the organization and
readability of the code.
### Contribution Checklist
<!-- Before submitting this PR, please make sure: -->
- [x] The code builds clean without any errors or warnings
- [x] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [x] All unit tests pass, and I have added new tests where possible
- [x] I didn't break anyone 😄
---------
Co-authored-by: Dmytro Struk <[email protected]>
Add setup tasks for contributing-python and tests for
Semantic-Kernel-Python. The setup tasks install poetry and python
packages. The tests include unit tests, integration tests, and all tests
for Semantic-Kernel-Python.
### Contribution Checklist
<!-- Before submitting this PR, please make sure: -->
- [x] The code builds clean without any errors or warnings
- [x] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [x] All unit tests pass, and I have added new tests where possible
- [x] I didn't break anyone 😄
---------
Co-authored-by: Dmytro Struk <[email protected]>
Removing copilot-chat-app from semantic-kernel repo.
### Motivation and Context
The semantic-kernel copilot-chat-app sample has moved to [its own
repository](https://github.com/microsoft/chat-copilot).
### Description
Removed all files related to the copilot-chat-app sample and replaced
them with a README linking to the new repository.
### Contribution Checklist
<!-- Before submitting this PR, please make sure: -->
- [x] The code builds clean without any errors or warnings
- [x] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [x] All unit tests pass, and I have added new tests where possible
- [x] I didn't break anyone 😄
---------
Co-authored-by: Ben Thomas <[email protected]>
### Motivation and Context
<!-- Thank you for your contribution to the semantic-kernel 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.
-->
fixes#1915
### Description
<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->
### Contribution Checklist
<!-- Before submitting this PR, please make sure: -->
- [ ] The code builds clean without any errors or warnings
- [ ] The PR follows SK Contribution Guidelines
(https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
- [ ] The code follows the .NET coding conventions
(https://learn.microsoft.com/dotnet/csharp/fundamentals/coding-style/coding-conventions)
verified with `dotnet format`
- [ ] All unit tests pass, and I have added new tests where possible
- [ ] I didn't break anyone 😄
---------
Co-authored-by: Abby Harrison <[email protected]>
Co-authored-by: Abby Harrison <[email protected]>
Co-authored-by: Shawn Callegari <[email protected]>
### Motivation and Context
This PR ports the plan object model found in the .NET SK to Python. This
fundamentally changes the concept of a planner from a `semantic skill`
to a unique type of `SKFunction`. With this model, we can begin
implementing sequential planner and offer much better plan
customization.
**Notes:**
- This PR does not implement plan serialization/deserialization to/from
JSON. There is a huge existing effort to make the Python SK completely
Pydantic enabled, which will bring serialization and deserialization
capability with it.
- This PR does not include ports of `Action Planner` and `Sequential
Planner` to the Plan Object Model (POM). Following PRs will address
this.
- I also added some missing copywrite headers. A future PR will add
headers to any still missing them.
- added a VSCode launch configuration to run the current file with
pytest
- closes#1486
### Description
- Added file called `plan.py` which is a python port of the Plan.cs file
found in the .NET SK. Note that it does not contain serialization logic
at this time.
- Added new kernel error `FunctionInvokeError` - mirrors the error list
of the .NET SK
- Added tests for Plan creation
- Added tests for Plan execution - both sync and async
### Contribution Checklist
<!-- Before submitting this PR, please make sure: -->
- [ ] The code builds clean without any errors or warnings
- [ ] The PR follows SK Contribution Guidelines
(https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
- [ ] The code follows the .NET coding conventions
(https://learn.microsoft.com/dotnet/csharp/fundamentals/coding-style/coding-conventions)
verified with `dotnet format`
- [ ] All unit tests pass, and I have added new tests where possible
- [ ] I didn't break anyone 😄
---------
Co-authored-by: Shawn Callegari <[email protected]>
### Motivation and Context
<!-- Thank you for your contribution to the semantic-kernel 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.
-->
fix the ESLint violations in CopilotChat and enable the linter to run
during `yarn start`/`yarn build`.
**lint errors going forward will fail the build** and will need to be
corrected before a PR can merge.
we have already configured the linter to auto-fix on save in VSCode and
for other IDEs the `yarn lint:fix` script can be used.
### Description
<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->
- `.node-pr.yml`: removed unneeded directory filter since `samples/apps`
no longer contains a `yarn.lock`.
- `.vscode/settings.json`: updated to point to the `eslintConfig` in the
`package.json` rather than the shared JS file. this is required so that
the plugins are resolved correctly by the extension.
- `.eslintrc.js`:
- removed deprecated `@typescript-eslint` rules.
- removed plugins already resolved from create-react-app.
- removed `standard-with-typescript` extended config in favor of more
widely used configs.
- `webapp/package.json`:
- pinned TS version to `5.0.4`, the latest version below `5.1.0`. this
is a dependency requirement of `@typescript-eslint` and otherwise the
linter will not work.
- re-added `eslintConfig` that now extends from the `../../eslintrc.js`.
this is required so that the plugins are resolved correctly by ESLint.
- `samples/apps/package.json`:
- deleted since there are now no shared dependencies that need to be
downloaded.
- similarly, the `yarn.lock` file was removed as well.
- all of the plugins/configs used in `.eslintrc.js` are already included
in the [create-react-app
config](https://github.com/facebook/create-react-app/blob/main/packages/eslint-config-react-app/index.js)
which we extend.
- **all other files**: fixed **379** errors and **42** warnings.
### Preview
#### During build
<img width="258" alt="image"
src="https://github.com/microsoft/semantic-kernel/assets/52973358/94a42909-7cb6-48a7-8d5f-6f55a15d6025">
#### In VSCode w/ ESLint extension installed
<img width="253" alt="image"
src="https://github.com/microsoft/semantic-kernel/assets/52973358/182604ab-6228-49f6-8983-4ef902e7e945">
### Contribution Checklist
<!-- Before submitting this PR, please make sure: -->
- [X] The code builds clean without any errors or warnings
- [x] The PR follows SK Contribution Guidelines
(https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
- [X] The code follows the .NET coding conventions
(https://learn.microsoft.com/dotnet/csharp/fundamentals/coding-style/coding-conventions)
verified with `dotnet format`
- [X] All unit tests pass, and I have added new tests where possible
- [X] I didn't break anyone 😄
- [X] Bugbash to double check nothing is broken (not yet but before
merging)
"KernelSyntaxExamples" is the only outstanding project under /samples
that still uses project references to access the kernel libraries.
This change consolidates all the building, linked dotnet SDK code in
SK-dotnet.sln into a single top-level folder. This will simplify build
jobs, automatic code owner assignment, and other dev ops tasks.
Coming next: other projects in samples will get removed from the
dotnet/SK-dotnet.sln solution, and a new solution with dedicated builds
created for the /samples folder.
TBD:
- Language-specific code "samples" will move into a similar subfolder
for each language.
- The current "/samples" folder (at the root) will likely become
something like "apps", with the demo apps promoted to the top-level
folder for better discoverability.
- notebooks may also move to this folder in the future.
Co-authored-by: name <email>
This commit renames the CopilotChatApi project and related files to
CopilotChatWebApi, to avoid confusion with the CopilotChatApp project
and to follow the naming convention of other webapi projects in the
solution. It also updates the launch and task configurations in VSCode
to reflect the new name.
Co-authored-by: Lee Miller <[email protected]>
This commit adds three tasks to the .vscode/tasks.json file for
building, running, and watching the CopilotChatApi project. These tasks
allow developers to easily launch and debug the WebApi service using VS
Code. The commit also updates the README.md file with instructions on
how to use the VS Code tasks. Additionally, the commit fixes some minor
formatting issues in the README.md file.
This commit adds the --results-directory option to the dotnet test tasks
in the .vscode/tasks.json file. This option specifies the directory
where the test results and code coverage reports are stored. By setting
this option, the test tasks can avoid cluttering the default TestResults
folder in the solution root. The commit also adds a new test task that
runs all the tests in the dotnet folder with code coverage enabled.
### Motivation and Context
The change improves the serialization and deserialization of Plan
objects.
### Description
Allows deserialization of Plans without a context. Adds unit tests for
the Plan and ContextVariables classes, which cover various scenarios and
edge cases of serializing and deserializing plans and context variables.
Details:
- Updates the custom converter for the ContextVariables class, which
serializes and deserializes the key-value pairs as an array of objects,
instead of a dictionary. This improves the efficiency and readability of
the JSON format.
- Add a new file PlanSerializationTests.cs to the
SemanticKernel.UnitTests project, which contains unit tests for the Plan
class. The tests verify that a plan can be serialized and deserialized
correctly, and that the plan state is updated correctly after each step
execution. The tests also check for invalid JSON strings.
- Add a new file ContextVariablesConverterTests.cs to the
SemanticKernel.UnitTests project, which contains unit tests for the
ContextVariablesConverter class. The tests verify that the converter can
correctly serialize and deserialize context variables to and from JSON,
and handle null, empty, and invalid inputs.
### Motivation and Context
Fix the VSCode tasks for integration tests.
### Description
This commit changes the tasks.json file to use the
IntegrationTests.csproj file instead of the
SemanticKernel.IntegrationTests.csproj file. This is because the
SemanticKernel project has been renamed to IntegrationTests, and the
tasks.json file needs to reflect this change. This affects the test
coverage task, which runs the integration tests and generates a lcov
report. The commit also updates the cwd option to point to the new
project folder.
### Motivation and Context
Adding the Semantic Kernel Tools as a recommended extension to our
repository at Shannon's request.
### Description
When you open this repository in VS Code you will see this prompt
### Motivation and Context
This is the next PR in improving Planning capabilities in the Kernel. It
builds upon previous
https://github.com/microsoft/semantic-kernel/pull/255 to enable
execution of plans and improves the ability to create plans.
### Description
- Rename the Plan class to SKPlan and add support for invoking functions
as part of the plan execution.
- Add a new class for executing plans, and remove the unused PlanRunner
class.
- Add unit and integration tests for the planning functionality and a
test email skill.
- Fix some minor issues and add documentation and comments to the
planning classes and tests.
- Update the VS Code tasks and editor config files to improve the
development experience.
### Motivation and Context
This pull request introduces several changes to the planner skill, which
is a core skill that allows users to create and execute plans based on
semantic queries. The motivation and context for these changes are as
follows:
- The changes improve the functionality and usability of the planner
skill by adding several parameters and options to the planner skill
functions, such as relevancy threshold, max functions, excluded
functions, excluded skills, and included functions. These parameters
allow users to customize the filtering and selection of registered
functions based on their goals and preferences.
- The changes enable the planner skill to filter the available functions
based on a semantic query and the relevance score from the memory
provider. This allows users to specify a natural language query that
matches their intent and get the most relevant functions to execute.
This feature enhances the planner skill's ability to generate and
execute plans that are relevant, efficient, and customizable for
different goals and scenarios.
- The changes improve the user experience of the kernel syntax examples
by adding more semantic skills and demonstrating how to use the planner
skill to create a plan for a complex task.
These changes do not fix any open issues, but they are related to the
ongoing development and improvement of the planner skill and the kernel
framework. They also improve the test coverage and code quality of the
planner skill, which is a key feature of the semantic kernel framework.
### Motivation and Context
This sample continues in the spirit of prior samples in the samples/apps
folder with a goal of teaching developers how the concepts of memory and
embeddings can be integrated.
### Description
This sample includes a frontend app that allows the developer to enter
the address of a publicly available Github repository, which is
downloaded to the temp directory of the machine hosting the
KernelHttpService sample application (can be the same machine).
Once downloaded the developer is able to have a conversation with the
repository and see the impact of the relevance slider on the responses.
---------
Co-authored-by: Craig Presti <[email protected]>
Co-authored-by: teresaqhoang <[email protected]>
Co-authored-by: markwallace-microsoft <[email protected]>
Co-authored-by: Tao Chen <[email protected]>
Co-authored-by: Mark Wallace <[email protected]>
Co-authored-by: Devis Lucato <[email protected]>
Co-authored-by: Devis Lucato <[email protected]>
Co-authored-by: Adrian Bonar <[email protected]>
### Motivation and Context
This set of code changes is required to improve the performance and
usability of the OpenAI completion backend by refactoring the kernel
retry mechanism and adding a new http retry delegating handler.
Specifically, it addresses the following problems:
1. The existing retry mechanism for kernel requests was using a custom
interface that made it difficult to customize and maintain the retry
logic. By refactoring it to use a delegating handler factory, we can
simplify the configuration of semantic skills and improve the
consistency and flexibility of the retry logic.
2. The existing retry handler did not take advantage of the Retry-After
value from the response headers to determine the backoff duration, which
can improve the efficiency and reliability of the requests. By adding a
new handler that does this, we can reduce the number of unnecessary
retries and improve the response times for the requests.
### Description
#### Kernel
- Added a new abstraction for creating HTTP retry handlers, the
`IDelegatingHandlerFactory` interface, which allows using the built-in
`HttpClient` retry logic and injecting custom retry policies.
- Added a new class `DefaultHttpRetryHandlerFactory` that implements a
configurable retry policy based on the `KernelConfig.HttpRetryConfig`
settings. This factory is used by default when creating a kernel, unless
a different factory is specified.
- Added a new class `NullHttpRetryHandlerFactory` that creates a no-op
retry handler, useful for testing or disabling retries.
- Added support for cancellation tokens and retry handlers in the OpenAI
services classes, such as `AzureTextCompletion`, `AzureTextEmbeddings`,
and `OpenAITextCompletion`. This allows the callers to cancel the
requests and handle transient failures more gracefully.
- Added unit tests for the `DefaultHttpRetryHandler` class, which is
responsible for handling HTTP retries. The tests cover various scenarios
such as retrying on different status codes, retrying on different
exception types, and respecting the retry configuration parameters.
- Removed the unused `IRetryMechanism` and `PassThroughWithoutRetry`
classes, and the `Example08_RetryMechanism.cs` file.
- Refactored the `KernelConfig` class to expose the `HttpRetryConfig`
and the `HttpHandlerFactory` properties.
- Refactored the `Kernel` class to use the `HttpHandlerFactory` instead
of the `RetryMechanism` for invoking the pipeline functions.
- Updated the `KernelBuilder` sample to show how to use a custom retry
handler factory.
- Updated the documentation and the code style accordingly.
#### Kernel-Syntax-Examples
This pull request adds two new classes to the Reliability namespace that
implement different retry policies for HTTP requests. The first class,
`RetryThreeTimesWithBackoff`, retries a request three times with an
exponential backoff if it encounters a 429 (Too Many Requests) or 401
(Unauthorized) status code. The second class,
`RetryThreeTimesWithRetryAfterBackoff`, also retries three times, but
uses the value of the Retry-After header to determine the backoff
duration. Both classes use Polly to implement the retry logic and log
the outcome of each attempt using the ILogger interface.
The pull request also modifies the `ConsoleLogger` class to filter out
log messages from the System namespace with a level lower than Warning.
This is to reduce the noise from the HttpClient and DelegatingHandler
classes.
This pull request introduces several improvements and features related
to the HTTP retry logic and the OpenAI services. The main changes are:
Quality of life changes for development in the repository using VSCode.
- Fixes the program and cwd paths in the launch.json file for the
KernelSyntaxExamples project
- Adds comments and clarifies the arguments for the R# check and cleanup
tasks in the tasks.json file
- Adds a new task to run the Semantic-Kernel tests with code coverage
enabled and output the results in lcov format
- Removes some trailing whitespace in the Directory.Packages.props file
### Motivation and Context
The Semantic Kernel naming convention of Skills and Functions can cause
confusion with the naming of the Azure Function sample project.
### Description
This PR renames the api-azure-function folder and
SemanticKernelFunction.csproj file to `KernelHttpServer`. All references
have been updated to point to the new folder.
### Motivation and Context
This PR adds a retry mechanism for kernel execution, to handle cases
where the AI service might throw an exception or return an error. It
also adds a cancellation token parameter to the retry mechanism, to
allow callers to cancel the operation if needed. Additionally, it
updates the samples to use the new features and fixes some paths in the
tasks.json file.
<!--
1. Why are these changes required?
These changes are required to improve the robustness and usability of
the kernel execution, by providing a way to handle errors and abort the
operation if necessary.
2. What problems do they solve?
They solve the problems of having to handle errors manually, and having
to wait for the operation to finish even if the caller no longer needs
the result.
3. What scenarios do they contribute to?
They contribute to scenarios where the caller may encounter errors or
timeouts from the AI service, or may want to cancel the operation due to
user input or other reasons.
4. If they fix an open issue, please link to the issue here.
N/A
-->
### Description
The main change in this PR is the addition of a new interface,
IRetryMechanism, which defines a method for executing an action with
retry logic and a cancellation token. The Kernel class now uses an
instance of this interface to execute the kernel functions, wrapping the
invocation in a try-catch block and using the logger to log any errors.
The default implementation of IRetryMechanism is
PassThroughWithoutRetry, which simply executes the action without any
retry logic or cancellation support. However, users can provide their
own implementations of IRetryMechanism to customize the retry behavior,
such as the RetryThreeTimes and RetryThreeTimesWithBackoff classes in
the samples.
The PR also updates the samples to use the new retry mechanism and
cancellation token, by passing an instance of IRetryMechanism and a
CancellationToken to the Kernel.Builder method. The samples demonstrate
how to use different retry strategies for different scenarios, such as
throttling or transient errors, and how to cancel the operation if
needed. Additionally, the PR fixes some paths in the tasks.json file,
which were pointing to the wrong folder for the kernel syntax examples
project.
### Contribution Checklist
<!-- Before submitting this PR, please make sure: -->
- [X] The code builds clean without any errors or warnings
- [X] The PR follows SK Contribution Guidelines
(https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
- [X] The code follows the .NET coding conventions
(https://learn.microsoft.com/dotnet/csharp/fundamentals/coding-style/coding-conventions)
verified with `dotnet format`
- [X] All unit tests pass, and I have added new tests where possible
- [X] I didn't break anyone 😄
### Up Next
These changes are to get the repo back to a previous state. Things will
change here as we look to make the RetryMechanism more generic, enabling
users to configure timeouts, headers, etc. Additonally, there is desire
to make this configurable per function rather than per kernel instance.
<!-- Thank you for your contribution to the semantic-kernel repo! -->