Commit Graph
546 Commits
Author SHA1 Message Date
Eduard van Valkenburg fbb26b5cf6 Python: further improvements to checks and docs in dev_setup (#6445)
### 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.
-->
Added a section on documentation to the DEV_SETUP
Added a check for the copyright row to pre-commit
Closes #5629

### 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
- [x] I didn't break anyone 😄
2024-05-31 13:06:41 +00:00
dependabot[bot]andEvan Mattson 377287f4a7 Python: Bump pyarrow from 15.0.2 to 16.1.0 in /python (#6290)
Bumps [pyarrow](https://github.com/apache/arrow) from 15.0.2 to 16.1.0.
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/apache/arrow/commit/7dd1d34074af176d9e861a360e135ae57b21cf96"><code>7dd1d34</code></a>
MINOR: [Release] Update versions for 16.1.0</li>
<li><a
href="https://github.com/apache/arrow/commit/ca3e9d1b6fbf9a1e2d2fe34a387041132ecddd3e"><code>ca3e9d1</code></a>
MINOR: [Release] Update .deb/.rpm changelogs for 16.1.0</li>
<li><a
href="https://github.com/apache/arrow/commit/63a42871f206edf9889f1617eac29b11514df316"><code>63a4287</code></a>
MINOR: [Release] Update CHANGELOG.md for 16.1.0</li>
<li><a
href="https://github.com/apache/arrow/commit/58742877144a4f728c99682cae52898ccab5f954"><code>5874287</code></a>
<a
href="https://redirect.github.com/apache/arrow/issues/41594">GH-41594</a>:
[Go] Support reading <code>date64</code> type &amp; properly validate
list-like ty...</li>
<li><a
href="https://github.com/apache/arrow/commit/81940c69e6843c22c2fa61ad05c668c3241b3016"><code>81940c6</code></a>
<a
href="https://redirect.github.com/apache/arrow/issues/41431">GH-41431</a>:
[C++][Parquet][Dataset] Fix repeated scan on encrypted dataset (<a
href="https://redirect.github.com/apache/arrow/issues/41">#41</a>...</li>
<li><a
href="https://github.com/apache/arrow/commit/be62f6c5717d960282c70f6150725b306919a672"><code>be62f6c</code></a>
<a
href="https://redirect.github.com/apache/arrow/issues/41577">GH-41577</a>:
[Java][Packaging] Add org.apache.arrow.memory.core to
--add-opens=j...</li>
<li><a
href="https://github.com/apache/arrow/commit/6cfebb947e9c91b3a823e5dc7a1672d1b0a0141e"><code>6cfebb9</code></a>
<a
href="https://redirect.github.com/apache/arrow/issues/41562">GH-41562</a>:
[C++][Parquet] Decoding: Fix num_value handling in
ByteStreamSplitD...</li>
<li><a
href="https://github.com/apache/arrow/commit/dcfeceb93f29b343cedbee4a2f93cbdbc4eed8e7"><code>dcfeceb</code></a>
<a
href="https://redirect.github.com/apache/arrow/issues/41140">GH-41140</a>:
[C#] Account for offset and length in union arrays (<a
href="https://redirect.github.com/apache/arrow/issues/41165">#41165</a>)</li>
<li><a
href="https://github.com/apache/arrow/commit/b28633cfe5263ac977598f058b53d76f95d3d1fc"><code>b28633c</code></a>
MINOR: [Release] Manually commit fix to avoid cherry-pick conflict for
changi...</li>
<li><a
href="https://github.com/apache/arrow/commit/ac8af222dd2e5800e2c6cbf45a5bdbb2309deed4"><code>ac8af22</code></a>
<a
href="https://redirect.github.com/apache/arrow/issues/41566">GH-41566</a>:
[CI][Packaging] macOS wheel for Catalina fails to build on macOS
ar...</li>
<li>Additional commits viewable in <a
href="https://github.com/apache/arrow/compare/go/v15.0.2...go/v16.1.0">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=pyarrow&package-manager=pip&previous-version=15.0.2&new-version=16.1.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Evan Mattson <[email protected]>
2024-05-31 08:45:20 +00:00
Eduard van Valkenburg 7ce352b9e3 Python: Pydantic settings config (#6392)
### 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.
-->
The initial implementation of Pydantic Settings was not optimal yet,
more optimized now.

### Description

Added a KernelBaseSettings class in kernel_pydantic
Rebased all settings off that
Added single create method to KernelBaseSettings:
- sets model_config.env_prefix to cls.end_prefix allowing us to set the
env_prefix as a classvar on each subclass and it works
- if env_file_path is set, set that in model_config
- strip all None values out of inputted values, then instantiate

This also allows us to pass the settings that are supplied to the
settings class, for overriding env settings.

<!-- 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
- [x] I didn't break anyone 😄
2024-05-30 09:38:28 +00:00
Eduard van ValkenburgandEvan Mattson 7cb651a809 Python: fix for add_function with conflicts (#6437)
### 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.
-->
Small change in the logic and detection and log.warning for when the
prompt and template and template_format are not the same, when using
kernel.add_function

Fixes #6412 

### 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
- [x] I didn't break anyone 😄

Co-authored-by: Evan Mattson <[email protected]>
2024-05-29 18:21:14 +00:00
Daniele Antonio MaggioandEvan Mattson 5d25f6a8dd Python: fix: Remove wrong response_format override in AzureChatPromptExecutionSettings class (#6424)
### Motivation and Context

This change is required to fix #5997 


### Description

The change is removing the wrong `response_format` override in
`AzureChatPromptExecutionSettings` class. The PR is also adding a unit
test covering the case where `response format` is defined.

The changes were successfully tested against an `Azure OpenAI` instance
with a `gpt-4o` deployment by specifying an
`AzureChatPromptExecutionSettings` like follows:

```python 
execution_settings =  AzureChatPromptExecutionSettings(
        service_id=service_id,
        ai_model_id=ai_model_id,
        max_tokens=1000,
        temperature=0.2,
        response_format={"type": "json_object"},
    )
```

### 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: Evan Mattson <[email protected]>
2024-05-29 15:52:50 +00:00
Eduard van Valkenburg e03b3fa168 Python: Run notebooks as tests (#6430)
### 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.
-->
Run notebooks as tests, working for all gettings started notebooks.
Also updated learn resources samples test, this can now easily be
extended with other sample scripts.

Closes: #4637
Partially closes: #4638

### 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
- [x] I didn't break anyone 😄
2024-05-29 15:50:55 +00:00
Evan Mattson 246b84357f Python: Bump Python version to 1.0.3 for a release. (#6432)
### Motivation and Context

Bump Python version to 1.0.3 for a release.

<!-- 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

Bump Python version to 1.0.3 for a release.

<!-- 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 😄
2024-05-28 16:51:05 -04:00
Evan Mattson 94c89ed7f8 Python: Fix doc string for allow_dangerously_set_content (#6431)
### Motivation and Context

Fix doc string for allow_dangerously_set_content

<!-- 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

Fix doc string for allow_dangerously_set_content

<!-- 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 😄
2024-05-28 16:00:00 -04:00
Stefano LottiniandEvan Mattson f7f5abca30 Python: (Astra DB) Explicit projection when reading from Astra DB (#6246)
### Motivation and Context

In view of upcoming changes in the Astra DB Data API, this PR explicitly
sets a projection every time a `find` command is executed, in order to
ensure all necessary fields of the document are returned by the API.

### Description

Added an else branch in the `astra_client.py` to ensure there always is
a "projection" field in the body for the `find` command. This ensures
that `$vector` is returned by the API even in case of Astra DB rolling
out an exclude-it-by-default policy in the future.

### Contribution Checklist

- [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: Evan Mattson <[email protected]>
2024-05-28 19:38:42 +00:00
Evan Mattson 895a580303 Python: Fix schema building for complex types (#6394)
### Motivation and Context

The schema building for complex types worked in some regard, but it
didn't work for all cases. There needs to be better checks on complex
types, if they have __args__ and if so, recurse to the base class type,
and also grab the type that is specified in the list like
list[CustomClass], list[str] or even Union[int, bool].

<!-- 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

This PR improves the parsing/building of complex types. Added
integration tests to cover more types in the hope that this doesn't lead
to any more issues.
- Closes #6388 

<!-- 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
- [X] I didn't break anyone 😄
2024-05-28 18:03:39 +00:00
Eduard van ValkenburgandEvan Mattson 172e93113e Python: updated samples (#6411)
### 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.
-->
Updated samples for MS Learn, with tags.

### 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
- [x] I didn't break anyone 😄

---------

Co-authored-by: Evan Mattson <[email protected]>
2024-05-28 15:46:18 +00:00
Eduard van Valkenburg 9e99933a27 Python: new pre-commit actions and pre-commit as GHA (#6376)
### 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.
-->

- Added static code checking to pre-commit (check-ast and
nbqa-check-ast)
- Added Bandit security checking to pre-commit
- Added pre-commit step to python-lint workflow, if it works, can delete
seperate mypy, ruff and black tests

### 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
- [x] I didn't break anyone 😄
2024-05-28 15:28:04 +00:00
dependabot[bot]andEvan Mattson d8674bd272 Python: Bump ruff from 0.4.4 to 0.4.5 in /python (#6417)
Bumps [ruff](https://github.com/astral-sh/ruff) from 0.4.4 to 0.4.5.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/astral-sh/ruff/releases">ruff's
releases</a>.</em></p>
<blockquote>
<h2>v0.4.5</h2>
<h2>Changes</h2>
<h3>Ruff's language server is now in Beta</h3>
<p><code>v0.4.5</code> marks the official Beta release of <code>ruff
server</code>, an integrated language server built into Ruff. <code>ruff
server</code> supports the same feature set as <code>ruff-lsp</code>,
powering linting, formatting, and code fixes in Ruff's editor
integrations -- but with superior performance and no installation
required. We'd love your feedback!</p>
<p>You can enable <code>ruff server</code> in the <a
href="https://github.com/astral-sh/ruff-vscode?tab=readme-ov-file#enabling-the-rust-based-language-server">VS
Code extension</a> today.</p>
<p>To read more about this exciting milestone, check out our <a
href="https://astral.sh/blog/ruff-v0.4.5">blog post</a>!</p>
<h3>Rule changes</h3>
<ul>
<li>[<code>flake8-future-annotations</code>] Reword
<code>future-rewritable-type-annotation</code> (<code>FA100</code>)
message (<a
href="https://redirect.github.com/astral-sh/ruff/pull/11381">#11381</a>)</li>
<li>[<code>pycodestyle</code>] Consider soft keywords for
<code>E27</code> rules (<a
href="https://redirect.github.com/astral-sh/ruff/pull/11446">#11446</a>)</li>
<li>[<code>pyflakes</code>] Recommend adding unused import bindings to
<code>__all__</code> (<a
href="https://redirect.github.com/astral-sh/ruff/pull/11314">#11314</a>)</li>
<li>[<code>pyflakes</code>] Update documentation and deprecate
<code>ignore_init_module_imports</code> (<a
href="https://redirect.github.com/astral-sh/ruff/pull/11436">#11436</a>)</li>
<li>[<code>pyupgrade</code>] Mark quotes as unnecessary for
non-evaluated annotations (<a
href="https://redirect.github.com/astral-sh/ruff/pull/11485">#11485</a>)</li>
</ul>
<h3>Formatter</h3>
<ul>
<li>Avoid multiline quotes warning with <code>quote-style =
preserve</code> (<a
href="https://redirect.github.com/astral-sh/ruff/pull/11490">#11490</a>)</li>
</ul>
<h3>Server</h3>
<ul>
<li>Support Jupyter Notebook files (<a
href="https://redirect.github.com/astral-sh/ruff/pull/11206">#11206</a>)</li>
<li>Support <code>noqa</code> comment code actions (<a
href="https://redirect.github.com/astral-sh/ruff/pull/11276">#11276</a>)</li>
<li>Fix automatic configuration reloading (<a
href="https://redirect.github.com/astral-sh/ruff/pull/11492">#11492</a>)</li>
<li>Fix several issues with configuration in Neovim and Helix (<a
href="https://redirect.github.com/astral-sh/ruff/pull/11497">#11497</a>)</li>
</ul>
<h3>CLI</h3>
<ul>
<li>Add <code>--output-format</code> as a CLI option for <code>ruff
config</code> (<a
href="https://redirect.github.com/astral-sh/ruff/pull/11438">#11438</a>)</li>
</ul>
<h3>Bug fixes</h3>
<ul>
<li>Avoid <code>PLE0237</code> for property with setter (<a
href="https://redirect.github.com/astral-sh/ruff/pull/11377">#11377</a>)</li>
<li>Avoid <code>TCH005</code> for <code>if</code> stmt with
<code>elif</code>/<code>else</code> block (<a
href="https://redirect.github.com/astral-sh/ruff/pull/11376">#11376</a>)</li>
<li>Avoid flagging <code>__future__</code> annotations as required for
non-evaluated type annotations (<a
href="https://redirect.github.com/astral-sh/ruff/pull/11414">#11414</a>)</li>
<li>Check for ruff executable in 'bin' directory as installed by 'pip
install --target'. (<a
href="https://redirect.github.com/astral-sh/ruff/pull/11450">#11450</a>)</li>
<li>Sort edits prior to deduplicating in quotation fix (<a
href="https://redirect.github.com/astral-sh/ruff/pull/11452">#11452</a>)</li>
<li>Treat escaped newline as valid sequence (<a
href="https://redirect.github.com/astral-sh/ruff/pull/11465">#11465</a>)</li>
<li>[<code>flake8-pie</code>] Preserve parentheses in
<code>unnecessary-dict-kwargs</code> (<a
href="https://redirect.github.com/astral-sh/ruff/pull/11372">#11372</a>)</li>
<li>[<code>pylint</code>] Ignore <code>__slots__</code> with dynamic
values (<a
href="https://redirect.github.com/astral-sh/ruff/pull/11488">#11488</a>)</li>
<li>[<code>pylint</code>] Remove <code>try</code> body from branch
counting (<a
href="https://redirect.github.com/astral-sh/ruff/pull/11487">#11487</a>)</li>
<li>[<code>refurb</code>] Respect operator precedence in
<code>FURB110</code> (<a
href="https://redirect.github.com/astral-sh/ruff/pull/11464">#11464</a>)</li>
</ul>
<h3>Documentation</h3>
<ul>
<li>Add <code>--preview</code> to the README (<a
href="https://redirect.github.com/astral-sh/ruff/pull/11395">#11395</a>)</li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md">ruff's
changelog</a>.</em></p>
<blockquote>
<h2>0.4.5</h2>
<h3>Ruff's language server is now in Beta</h3>
<p><code>v0.4.5</code> marks the official Beta release of <code>ruff
server</code>, an integrated language server built into Ruff.
<code>ruff server</code> supports the same feature set as
<code>ruff-lsp</code>, powering linting, formatting, and
code fixes in Ruff's editor integrations -- but with superior
performance and
no installation required. We'd love your feedback!</p>
<p>You can enable <code>ruff server</code> in the <a
href="https://github.com/astral-sh/ruff-vscode?tab=readme-ov-file#enabling-the-rust-based-language-server">VS
Code extension</a> today.</p>
<p>To read more about this exciting milestone, check out our <a
href="https://astral.sh/blog/ruff-v0.4.5">blog post</a>!</p>
<h3>Rule changes</h3>
<ul>
<li>[<code>flake8-future-annotations</code>] Reword
<code>future-rewritable-type-annotation</code> (<code>FA100</code>)
message (<a
href="https://redirect.github.com/astral-sh/ruff/pull/11381">#11381</a>)</li>
<li>[<code>pycodestyle</code>] Consider soft keywords for
<code>E27</code> rules (<a
href="https://redirect.github.com/astral-sh/ruff/pull/11446">#11446</a>)</li>
<li>[<code>pyflakes</code>] Recommend adding unused import bindings to
<code>__all__</code> (<a
href="https://redirect.github.com/astral-sh/ruff/pull/11314">#11314</a>)</li>
<li>[<code>pyflakes</code>] Update documentation and deprecate
<code>ignore_init_module_imports</code> (<a
href="https://redirect.github.com/astral-sh/ruff/pull/11436">#11436</a>)</li>
<li>[<code>pyupgrade</code>] Mark quotes as unnecessary for
non-evaluated annotations (<a
href="https://redirect.github.com/astral-sh/ruff/pull/11485">#11485</a>)</li>
</ul>
<h3>Formatter</h3>
<ul>
<li>Avoid multiline quotes warning with <code>quote-style =
preserve</code> (<a
href="https://redirect.github.com/astral-sh/ruff/pull/11490">#11490</a>)</li>
</ul>
<h3>Server</h3>
<ul>
<li>Support Jupyter Notebook files (<a
href="https://redirect.github.com/astral-sh/ruff/pull/11206">#11206</a>)</li>
<li>Support <code>noqa</code> comment code actions (<a
href="https://redirect.github.com/astral-sh/ruff/pull/11276">#11276</a>)</li>
<li>Fix automatic configuration reloading (<a
href="https://redirect.github.com/astral-sh/ruff/pull/11492">#11492</a>)</li>
<li>Fix several issues with configuration in Neovim and Helix (<a
href="https://redirect.github.com/astral-sh/ruff/pull/11497">#11497</a>)</li>
</ul>
<h3>CLI</h3>
<ul>
<li>Add <code>--output-format</code> as a CLI option for <code>ruff
config</code> (<a
href="https://redirect.github.com/astral-sh/ruff/pull/11438">#11438</a>)</li>
</ul>
<h3>Bug fixes</h3>
<ul>
<li>Avoid <code>PLE0237</code> for property with setter (<a
href="https://redirect.github.com/astral-sh/ruff/pull/11377">#11377</a>)</li>
<li>Avoid <code>TCH005</code> for <code>if</code> stmt with
<code>elif</code>/<code>else</code> block (<a
href="https://redirect.github.com/astral-sh/ruff/pull/11376">#11376</a>)</li>
<li>Avoid flagging <code>__future__</code> annotations as required for
non-evaluated type annotations (<a
href="https://redirect.github.com/astral-sh/ruff/pull/11414">#11414</a>)</li>
<li>Check for ruff executable in 'bin' directory as installed by 'pip
install --target'. (<a
href="https://redirect.github.com/astral-sh/ruff/pull/11450">#11450</a>)</li>
<li>Sort edits prior to deduplicating in quotation fix (<a
href="https://redirect.github.com/astral-sh/ruff/pull/11452">#11452</a>)</li>
<li>Treat escaped newline as valid sequence (<a
href="https://redirect.github.com/astral-sh/ruff/pull/11465">#11465</a>)</li>
<li>[<code>flake8-pie</code>] Preserve parentheses in
<code>unnecessary-dict-kwargs</code> (<a
href="https://redirect.github.com/astral-sh/ruff/pull/11372">#11372</a>)</li>
<li>[<code>pylint</code>] Ignore <code>__slots__</code> with dynamic
values (<a
href="https://redirect.github.com/astral-sh/ruff/pull/11488">#11488</a>)</li>
<li>[<code>pylint</code>] Remove <code>try</code> body from branch
counting (<a
href="https://redirect.github.com/astral-sh/ruff/pull/11487">#11487</a>)</li>
<li>[<code>refurb</code>] Respect operator precedence in
<code>FURB110</code> (<a
href="https://redirect.github.com/astral-sh/ruff/pull/11464">#11464</a>)</li>
</ul>
<h3>Documentation</h3>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/astral-sh/ruff/commit/550aa871d32b53a2f042fb0e7fea1080eadfa11d"><code>550aa87</code></a>
Bump version to <code>v0.4.5</code> (<a
href="https://redirect.github.com/astral-sh/ruff/issues/11502">#11502</a>)</li>
<li><a
href="https://github.com/astral-sh/ruff/commit/3c22a3bdccf703e42fc2778db5857bb688422c8c"><code>3c22a3b</code></a>
Minor edits to <code>ruff server</code> docs (<a
href="https://redirect.github.com/astral-sh/ruff/issues/11500">#11500</a>)</li>
<li><a
href="https://github.com/astral-sh/ruff/commit/6263923915b5678fd496f7646ef8d2eca9b23607"><code>6263923</code></a>
Update documentation for <code>ruff server</code> with new migration
guide (<a
href="https://redirect.github.com/astral-sh/ruff/issues/11499">#11499</a>)</li>
<li><a
href="https://github.com/astral-sh/ruff/commit/94abea4b0822f99f97e01d9adadddc82acd8d8b8"><code>94abea4</code></a>
<code>ruff server</code>: Fix multiple issues with Neovim and Helix (<a
href="https://redirect.github.com/astral-sh/ruff/issues/11497">#11497</a>)</li>
<li><a
href="https://github.com/astral-sh/ruff/commit/519a65007fe2ff714103fb023aacb49a71551a7f"><code>519a650</code></a>
Mark quotes as unnecessary for non-evaluated annotations (<a
href="https://redirect.github.com/astral-sh/ruff/issues/11485">#11485</a>)</li>
<li><a
href="https://github.com/astral-sh/ruff/commit/573facd2bad5d43abed7c9da903f9cf243d29d58"><code>573facd</code></a>
Fix automatic configuration reloading for text and notebook documents
(<a
href="https://redirect.github.com/astral-sh/ruff/issues/11492">#11492</a>)</li>
<li><a
href="https://github.com/astral-sh/ruff/commit/3cb2e677aa0b88075f248ea44c5d2e844b82a0a7"><code>3cb2e67</code></a>
<code>ruff.applyFormat</code> now formats an entire notebook document
(<a
href="https://redirect.github.com/astral-sh/ruff/issues/11493">#11493</a>)</li>
<li><a
href="https://github.com/astral-sh/ruff/commit/f0046ab28e67c5d6b3ce5951817f715333b4538d"><code>f0046ab</code></a>
Move <code>has_comments</code> to <code>CommentRanges</code> (<a
href="https://redirect.github.com/astral-sh/ruff/issues/11495">#11495</a>)</li>
<li><a
href="https://github.com/astral-sh/ruff/commit/5bb9720a10618ed9cecc401df231e360710780ee"><code>5bb9720</code></a>
Avoid multiline quotes warning with <code>quote-style = preserve</code>
(<a
href="https://redirect.github.com/astral-sh/ruff/issues/11490">#11490</a>)</li>
<li><a
href="https://github.com/astral-sh/ruff/commit/9ff18bf9d34846e2b6182d72609ba32131e2b356"><code>9ff18bf</code></a>
Simplify Neovim docs for the LSP setup (<a
href="https://redirect.github.com/astral-sh/ruff/issues/11489">#11489</a>)</li>
<li>Additional commits viewable in <a
href="https://github.com/astral-sh/ruff/compare/v0.4.4...v0.4.5">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=ruff&package-manager=pip&previous-version=0.4.4&new-version=0.4.5)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Evan Mattson <[email protected]>
2024-05-28 13:31:55 +00:00
Sin-Woo BangandEduard van Valkenburg 63f1f8bac9 Python: Fix typo (#6409)
### 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 typo

### Description

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

Fix typo

### 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: Eduard van Valkenburg <[email protected]>
2024-05-27 16:22:10 +00:00
StefanandEvan Mattson 65515468f8 Python: Fix typos. (#6381)
### 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! -->

Fixed a bunch of typos.

### 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: Evan Mattson <[email protected]>
2024-05-24 16:01:51 +00:00
Evan Mattson 5a050990fa Python: Remove assert on non-required api_key (#6384)
### Motivation and Context

The ACS admin key isn't required as the user can pass in either azure
credentials or token credentials. Right now there is an assert on the
api_key not being null that is blocking.

<!-- 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

Remove the assert on the api_key. Closes #6369

<!-- 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
- [X] I didn't break anyone 😄
2024-05-24 14:51:52 +00:00
StefanandEvan Mattson a9d7d5d90f Python: Refactoring. Use get_function and get_plugin. (#6382)
### 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.
-->

Refactoring some of the code following [this
advice](https://github.com/microsoft/semantic-kernel/pull/6371#discussion_r1611138252)
from the maintainers.

### Description

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

Look up kernel functions and plugins with the `get_function` and
`get_plugin` method. Removed the unused `DEFAULT_CHAT_SYSTEM_PROMPT`

### 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: Evan Mattson <[email protected]>
2024-05-24 06:02:18 +00:00
Stefan 76039ed4bd Python: Log exception in planner. (#6371)
### 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! -->

The planner code catches an exception and does nothing with it. I added
an error log so it's not silently failing.

### 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 😄
2024-05-23 20:19:38 +00:00
Evan Mattson 43b7d40d8b Python: Bump Python version to 1.0.2 for a release (#6380)
### Motivation and Context

Bump Python version to 1.0.2 for a release

<!-- 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

Bump Python version to 1.0.2 for a release

<!-- 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
- [X] I didn't break anyone 😄
2024-05-23 14:12:27 -04:00
Evan Mattson 0c9517359a Python: Fix schema handling. Fix function result return for type list. (#6370)
### Motivation and Context

Building the tools json payload from the kernel parameter metadata
wasn't properly including an object of type `array`.

<!-- 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

Correctly include the object type `array` so that the tool call doesn't
return a bad request. Add unit tests.
- Closes #6367 
- Closes #6360
- Fixes the FunctionResult return for a type string -- if the
FunctionResult is of type KernelContent then return the first element of
the list, otherwise return the complete list.
- Fix the kernel function from method to include the proper type_object
for the return parameter so that the schema can be created properly.
- Add retry logic for a sometimes flaky function calling stepwise
planner integration test.
- Add a check during function calling that makes sure the model is
returning the proper number of arguments based on how many function
arguments are required.

<!-- 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
- [X] I didn't break anyone 😄
2024-05-23 18:00:29 +00:00
Evan Mattson e98cd182fe Python: Fix doc strings (#6378)
### Motivation and Context

Fix docstrings so the docs tool can pass.

<!-- 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

Fix docstrings so the docs tool can pass.

<!-- 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
- [X] I didn't break anyone 😄
2024-05-23 12:29:23 -04:00
Evan Mattson f304114060 Python: Bump Python version to 1.0.1 for a release. (#6368)
### Motivation and Context

Bump Python version to 1.0.1 for a release.

<!-- 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

Bump Python version to 1.0.1 for a release.

<!-- 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
- [X] I didn't break anyone 😄
2024-05-22 16:08:13 +00:00
Evan Mattson d66fdcfe5c Python: Add cross language tests (#6318)
### Motivation and Context

As we move towards v1 and beyond it's essential that we have a way to
make sure we are staying in line with the other SK SDKs. Previous to
this we didn't have a way to capture request bodies and payloads and
make sure they confirm to the proper SK standards.

<!-- 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

This PR introduces a number of integration tests that exercise various
aspects of the SK SDK like prompts, prompt templates, functions, and the
kernel.

*TODO*: update the OpenAPI tests with a more JSON specific response that
we can check against.

<!-- 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
- [X] I didn't break anyone 😄
2024-05-22 15:42:41 +00:00
Eduard van ValkenburgandEvan Mattson 9d56f4276d Python: Improve test coverage (#6366)
### 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.
-->

Working through improving test coverage

Small changes introduced:

- ai_service_selector: select_ai_service method, now has extra optional
variable for type_, when not set the behavior is the same as before,
otherwise allows any type of AI service present to be selected,
including embeddings (which was not possible)

### 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 😄

---------

Co-authored-by: Evan Mattson <[email protected]>
2024-05-22 15:26:29 +00:00
Eduard van Valkenburg eccad335ae Python: split kernel into kernel extensions for relevant pieces (#6361)
### 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.
-->
In order to keep better track of related pieces within the Kernel,
including easier unit testing, this PR splits the kernel into pieces
that are self-contained, but abstract.

### Description

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

Changed:
- Kernel, now imports the new ones.
- KernelFiltersExtension, moved to filters folder, in line with the
rest.

### 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 😄
2024-05-22 15:03:34 +00:00
Eduard van Valkenburg 8f97c28c73 Python: updated pyproject and lock (#6363)
### 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.
-->
replace a bunch of other package update PRs
Removed obsolete package specification for py<3.10

### 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
- [x] I didn't break anyone 😄
2024-05-22 14:46:12 +00:00
Eduard van Valkenburg c35651f242 Python: update for kernel function decorator defaults (#6351)
### 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.
-->
There was an issue when you create a function with multiple arguments,
some with a default.

### Description

<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->
Improved the parsing of the function, using py3.10 specific features.
Closes #6311 

### 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 😄
2024-05-22 13:22:51 +00:00
Evan Mattson 6158c5b432 Python: Fix FC stepwise planner. (#6357)
### Motivation and Context

The FC stepwise planner was breaking when trying to process the function
call result because if a filter is not configured, then the context will
be None. We need to only try to extract the FC result if the context is
not none, otherwise it will already be present in the chat history.

<!-- 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

Check that the FC result context is not None, if so, then extract the FC
result, otherwise proceed as the FC result is in the chat history. Fixes
#6350.
- Removes some extranous logging from json schema addition.

<!-- 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
- [X] I didn't break anyone 😄
2024-05-21 22:56:10 +00:00
Evan Mattson 8a5fc1c0ac Python: Separate set and __setitem__ strings (#6356)
### Motivation and Context

Separate set and __setitem__ doc strings

<!-- 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

Separate set and __setitem__ doc strings

<!-- 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
- [X] I didn't break anyone 😄
2024-05-21 16:31:01 -04:00
Evan Mattson 82aede879d Python: Try to fix a doc building issue. (#6354)
### Motivation and Context

The docs tool is breaking because two methods share the same signatures
and the beginnings of the docstring. 
<!-- 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

Try to differentiate the docstrings by a char to see if it fixes the
docs generation.

<!-- 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
- [X] I didn't break anyone 😄
2024-05-21 19:21:10 +00:00
Eduard van Valkenburg 81cdde24fc Python: upgraded all files to 310 plus format and removed from future (#6353)
### 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.
-->
Now that we only support 310 and up, we could unify all files, to use
the new style typing and annotations.

### 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
- [x] I didn't break anyone 😄
2024-05-21 16:33:08 +00:00
Evan Mattson 2b96abfb2f Python: Bump Python version to v1.0.0 (#6345)
### Motivation and Context

Bump Python version to v1.0.0

<!-- 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

Bump Python version to v1.0.0

<!-- 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
- [X] I didn't break anyone 😄
2024-05-20 20:02:15 -04:00
Eduard van ValkenburgandEvan Mattson 25813502a6 Python: fix for fc stepwise (#6337)
### 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 #6333 

### 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
- [x] I didn't break anyone 😄

Co-authored-by: Evan Mattson <[email protected]>
2024-05-20 22:09:54 +00:00
Evan Mattson 517a0f8ed2 Python: Add json schema handling. Add experimental tag to OpenAPI and Memory Connectors. (#6335)
### Motivation and Context

The Python code base could handle some primitive types for the schema
for tool call objects and kernel parameter metadata. However, it
couldn't properly handle the more complex JSON schemas for tool call
objects.

<!-- 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

This PR introduces:
- JSON schema handling for KernelParameterMetadata and tool call
objects.
- Updates to the tool call utils method to properly recurse on the
KernelParameterMetadata's stucture.
- Adds unit tests for this code.
- Add experimental_class/experimental_functions to various parts of the
code base like Memory Connectors and OpenAPI plugin.
- Fixes #6310 
- Fixes #6280

<!-- 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
- [X] I didn't break anyone 😄
2024-05-20 21:56:30 +00:00
ec93cb45eb Python: Adds a memory connector for Azure Cosmos DB for NoSQL (#6195)
### Motivation and Context

Azure Cosmos DB is adding Vector Similarity APIs to the NoSQL project,
and would like Semantic Kernel users to be able to leverage them.

This adds a Memory Connector implementation for Azure Cosmos DB's,
including support for the new vector search functionality coming soon in
Cosmos DB.

<!-- 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: Eduard van Valkenburg <[email protected]>
Co-authored-by: Evan Mattson <[email protected]>
2024-05-18 12:32:30 +00:00
Evan Mattson 49980638ed Python: Bump version to 1.0.0rc1. (#6321)
### Motivation and Context

Python: Bump version to 1.0.0rc1.

<!-- 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

Python: Bump version to 1.0.0rc1.

<!-- 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
- [X] I didn't break anyone 😄
2024-05-17 18:32:18 -04:00
Eduard van Valkenburg a894aebaa9 Python: implement filters (#5681)
### 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.
-->
This pull request includes significant changes across multiple files,
mainly related to the addition of hooks and the modification of function
invocations in the `semantic_kernel` module. The changes also include
the addition of a new sample and a YAML file, and modifications to the
`__init__.py` files.

Removals:

*
[`python/semantic_kernel/events`](diffhunk://#diff-ebda9504832b19ab83239a92c9a6d5f8c744deff9fef86071c13956ec92bb010L1-L11):
Removed the previously used events.

New Exceptions:

*
[`python/semantic_kernel/exceptions/kernel_exceptions.py`](diffhunk://#diff-450aaa5595a8b22cd6ee212eb79b7d6b0d4e9c1072063ef32018a3e7d3fdf21dR41-R48):
Added new exception classes `OperationCancelledException` and
`HookInvalidSignatureError`.
[[1]](diffhunk://#diff-450aaa5595a8b22cd6ee212eb79b7d6b0d4e9c1072063ef32018a3e7d3fdf21dR41-R48)
[[2]](diffhunk://#diff-450aaa5595a8b22cd6ee212eb79b7d6b0d4e9c1072063ef32018a3e7d3fdf21dR57-R58)

Fixes: #3038 
Fixes: #6276

### 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 😄
2024-05-17 21:05:56 +00:00
Evan Mattson 33f278c477 Python: Bump python version to 0.9.9b1 for release. (#6299)
### Motivation and Context

Bump python version to 0.9.9b1 for release.

<!-- 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

Bump python version to 0.9.9b1 for release.

<!-- 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
- [X] I didn't break anyone 😄
2024-05-16 18:18:22 +00:00
Evan Mattson d9aa617ec8 Python: Create an experimental class and function decorator. (#6298)
### Motivation and Context

There may be classes or functions inside of SK Python that should be
deemed as experimental. Currently in Python there is no out-of-the-box
way to get the decorator.

<!-- 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

As there is a name clash with using `experimental` as the decorator
name, we are introducing two decorators: one `experimental_class` and
one `experimental_function`. The note that "This {function | class} is
experimental and may change in the future" is included in the docstring
and a bool `is_experimental` on the class is added.

<!-- 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
- [X] I didn't break anyone 😄
2024-05-16 18:16:12 +00:00
Eduard van ValkenburgandEvan Mattson 2530367c17 Python: improved plugins docstrings (#6287)
### 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: #6254

### 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: Evan Mattson <[email protected]>
2024-05-16 15:41:23 +00:00
Eduard van ValkenburgandEvan Mattson cc7f7d2f69 Python: renamed complete to get_ (#6288)
### 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.
-->
To get back in sync with dotnet, renamed: 
- complete to get_text_contents
- complete_chat to get_chat_message_contents
- complete_stream to get_streaming_text_contents
- complete_chat_stream to get_streaming_chat_message_content

### 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 😄

Co-authored-by: Evan Mattson <[email protected]>
2024-05-16 15:39:58 +00:00
Eduard van Valkenburg a5a38b8fc1 Python: added function_name and plugin_name properties to FC and FCR (#6286)
### 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 #6258

### 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
- [x] I didn't break anyone 😄
2024-05-16 14:40:59 +00:00
Eduard van Valkenburg 08bcc803ef Python: Unsafe input handling (#6003)
### 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.
-->
Implements dealing with unsafe content, by doing HTML parsing on
variables and function results.

Closes: #5889

### Description

<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->
Adds parameter `allow_dangerously_set_content` to:
- InputVariable
- PromptTemplateConfig
- PromptTemplateBase

The behavior is that if the flag is set to True on the template itself
(KernelPromptTemplate, Jinja2PromptTemplate or HandlebarsPromptTemplate)
the behavior is the same, no encoding is done on inputs.

Otherwise:
- variables are encoded by default, this can be switched off using the
InputVariables class for that variable.
- function output is encoded by default, this can be switched off using
the flag in the PromptTemplateConfig, this is not yet possible to do on
a per function basis.

### 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 😄
2024-05-16 13:02:54 +00:00
Evan Mattson 46f5ea15a2 Python: Introduce Pydantic settings (#6193)
### Motivation and Context

SK Python is tightly coupled to the use of a `.env` file to read all
secrets, keys, endpoints, and more. This doesn't scale well for users
who wish to be able to use environment variables with their SK
Applications. By introducing Pydantic Settings, it is possible to use
both environment variables as well as have a fall-back to a `.env` file
(via a `env_file_path` parameter), if desired.

By introducing Pydantic Settings, we are removing the requirement to
have to create Text/Embedding/Chat completion objects with an `api_key`
or other previously required information (in the case of
AzureChatCompletion that means an `endpoint`, an `api_key`, a
`deployment_name`, and an `api_version`). When the AI connector is
created, the Pydantic settings are loaded either via env vars or the
fall-back `.env` file, and that means the user can create a chat
completion object like:

```python
chat_completion = OpenAIChatCompletion(service_id="test")
```

or, to optionally override the `ai_model_id` env var:

```python
chat_completion = OpenAIChatCompletion(service_id="test", ai_model_id="gpt-4-1106")
```
Note: we have left the ability to specific an `api_key`/`org_id` for
`OpenAIChatCompletion` or a `deployment_name`, `endpoint`, `base_url`,
and `api_version` for `AzureChatCompletion` as before, but if your
settings are configured to use env vars/.env file then there is no need
to pass this information.

<!-- 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

The PR introduces the use of Pydantic settings and removes the use of
the python-dotenv library.
- Closes #1779 
- Updates notebooks, samples, code and tests to remove the explicit
config of api_key or other previous .env files values.
- Adds new unit test config using monkeypatch to simulate env variables
for testing
- All unit and integration tests passing

<!-- 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 😄
2024-05-16 11:44:40 +00:00
Evan Mattson 142aef82b1 Python: OpenAPI plugin enhance (#6279)
### Motivation and Context

Python's OpenAPI manager `run_openapi_operation` was hard-coded to use
certain parameters that would ultimately be built up to make an API
request. This didn't allow the model to know which parameters were
actually defined as required in the OpenAPI spec and would cause errors
during function calling.

<!-- 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

This PR does a quite major overhaul on the openapi manager, with the
caveat that the code is going to be refactored / cleaned up in a next
iteration (we're pressed for time right now). In the
`_create_function_from_operation` method, the `rest_operation_params`
are now built up from the operation which means we included the required
parameters and will have them during function calling. This allows us to
properly build up the url, headers, request body and paths to make the
API call.
- The concept samples were updated and are functioning with this latest
code.
- function calling was tested with the AzureKeyVault OpenAPI example and
the model was able to automatically create a secret in a test key vault.
- Old unit tests were removed. Note: in the next iteration new unit
tests for all of the new functionality will be added.
- In the next iteration, the entire `openapi_manager.py` file will be
broken apart to separate files for classes/moels to clean it up.
- Closes #6261 

<!-- 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 😄
2024-05-16 03:47:55 +00:00
ecbc15b586 Python: fix class type (#6183)
### Motivation and Context

It should be "ChatMessageContent" type instead of "FunctionCallContent"
type.

### 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: Yan Zhang <[email protected]>
Co-authored-by: Evan Mattson <[email protected]>
Co-authored-by: Eduard van Valkenburg <[email protected]>
2024-05-15 19:24:26 +00:00
Eduard van Valkenburg ce87f9107c Python: handle failing tool call gracefully (#6268)
### 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.
-->
When a function that was called using tool calling fails, it shouldn't
drop the whole flow, this fixes that.

Fix #6260 

### Description

<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->
Creates a function result content item with the failing function and the
error message, allowing the model to figure out if it wants to recall
with different params.

### 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 😄
2024-05-15 17:43:04 +00:00
Eduard van Valkenburg 32c4694033 Python: add test to show using a lambda func (#6215)
### 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.
-->
the question arose whether a lambda function can work, it does, with the
right syntax, added as a test.

### 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
- [x] I didn't break anyone 😄
2024-05-14 17:02:16 +00:00
dependabot[bot]andEvan Mattson 83827a2c86 Python: Bump transformers from 4.40.1 to 4.40.2 in /python (#6239)
Bumps [transformers](https://github.com/huggingface/transformers) from
4.40.1 to 4.40.2.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/huggingface/transformers/releases">transformers's
releases</a>.</em></p>
<blockquote>
<h2>v4.40.2</h2>
<h1>Fix torch fx for LLama model</h1>
<ul>
<li>Fix for Neuron (<a
href="https://redirect.github.com/huggingface/transformers/issues/30259">#30259</a>)</li>
<li>Fix copies for DBRX - neuron fix (<a
href="https://redirect.github.com/huggingface/transformers/issues/30610">#30610</a>)</li>
</ul>
<p>Thanks <a
href="https://github.com/michaelbenayoun"><code>@​michaelbenayoun</code></a>
!</p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/huggingface/transformers/commit/4fdf58afb72b0754da30037fc800b6044e7d9c99"><code>4fdf58a</code></a>
v4.40.2</li>
<li><a
href="https://github.com/huggingface/transformers/commit/6530a989c6714ee11b11bff09f03c0b30823291b"><code>6530a98</code></a>
Fix copies for DBRX - neuron fix (<a
href="https://redirect.github.com/huggingface/transformers/issues/30610">#30610</a>)</li>
<li><a
href="https://github.com/huggingface/transformers/commit/bb98e7ce58c796b3627c7ac673787437adca085b"><code>bb98e7c</code></a>
Fix for Neuron (<a
href="https://redirect.github.com/huggingface/transformers/issues/30259">#30259</a>)</li>
<li>See full diff in <a
href="https://github.com/huggingface/transformers/compare/v4.40.1...v4.40.2">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=transformers&package-manager=pip&previous-version=4.40.1&new-version=4.40.2)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Evan Mattson <[email protected]>
2024-05-14 14:17:07 +00:00
Evan Mattson 1692207639 Python: allow openapi runner to use a custom client (#6226)
### Motivation and Context

A custom client was used to get the openapi spec but it wasn't passed
down into the openapi runner.

<!-- 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

Pass the custom client into the open api runner if desired. Fix param
parsing and samples.

<!-- 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
- [X] I didn't break anyone 😄
2024-05-13 22:49:27 +00:00