Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python: Fix function calling concept example. #6477

Merged
merged 2 commits into from
May 31, 2024

Conversation

moonbox3
Copy link
Contributor

Motivation and Context

A function calling plugin example is failing due to an incorrect chat completion base method. Additionally, if one specifies to enable function calling with auto invoke set to False, and they don't provide a kernel, then there is no error thrown.

Description

This PR:

  • Fixes the concept example that shows three different ways to handle function calling.
  • Fixes Python: The openai_function_calling_with_custom_plugin.py sample has several bugs #6453
  • Adjusts the error checks for the kernel and arguments in the open_ai_chat_completion_base: manual function calling doesn't require arguments, so don't throw if they aren't provided; however, it does require a kernel, which is used to configure the tools for the settings, so this check has to be by itself.
  • Add a unit test to exercise slightly different behavior.

Contribution Checklist

@moonbox3 moonbox3 requested a review from a team as a code owner May 31, 2024 20:23
@markwallace-microsoft markwallace-microsoft added the python Pull requests for the Python Semantic Kernel label May 31, 2024
@markwallace-microsoft
Copy link
Member

markwallace-microsoft commented May 31, 2024

Py3.10 Test Coverage

Python 3.10 Test Coverage Report •
FileStmtsMissCoverMissing
semantic_kernel/connectors/ai/open_ai/services
   open_ai_chat_completion_base.py2199656%97, 101, 121, 146–150, 174, 178, 182, 198–203, 220–248, 251–262, 277–284, 295–303, 319–326, 347, 355, 361–364, 376–379, 410, 449, 454, 459–464, 468–475, 479–491, 513, 523–534
TOTAL609878687% 

Python 3.10 Unit Test Overview

Tests Skipped Failures Errors Time
1403 1 💤 0 ❌ 0 🔥 22.642s ⏱️

Copy link
Member

@eavanvalkenburg eavanvalkenburg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to start adding these sample to sample tests? In a similar approach as the learn resources ones, but perhaps with individual tests to account for more complex things!

@moonbox3
Copy link
Contributor Author

Would it be possible to start adding these sample to sample tests? In a similar approach as the learn resources ones, but perhaps with individual tests to account for more complex things!

Yes, let's do it. I am going to start adding OpenAPI unit tests now, as we don't have any. I will start adding some of these concept examples as more tests.

@moonbox3 moonbox3 enabled auto-merge May 31, 2024 20:36
@moonbox3 moonbox3 added this pull request to the merge queue May 31, 2024
Merged via the queue into microsoft:main with commit bf42fed May 31, 2024
23 checks passed
@moonbox3 moonbox3 deleted the fix_function_calling_args branch May 31, 2024 20:59
Bryan-Roe added a commit to Bryan-Roe/semantic-kernel that referenced this pull request Jun 1, 2024
### Motivation and Context

A function calling plugin example is failing due to an incorrect chat
completion base method. Additionally, if one specifies to enable
function calling with auto invoke set to False, and they don't provide
a
kernel, then there is no error thrown.

<!-- 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:
- Fixes the concept example that shows three different ways to handle
function calling.
- Fixes microsoft#6453
- Adjusts the error checks for the kernel and arguments in the
open_ai_chat_completion_base: manual function calling doesn't require
arguments, so don't throw if they aren't provided; however, it does
require a kernel, which is used to configure the tools for the
settings,
so this check has to be by itself.
- Add a unit test to exercise slightly different behavior.

<!-- 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/CONT
RIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBU
TING.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 😄
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
python Pull requests for the Python Semantic Kernel
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Python: The openai_function_calling_with_custom_plugin.py sample has several bugs
4 participants