Skip to content

Python: Implement Function calling for Chat - #2356

Merged
Gina Triolo (gitri-ms) merged 49 commits into
microsoft:mainfrom
eavanvalkenburg:function_calling
Oct 12, 2023
Merged

Gina Triolo (gitri-ms) merged 49 commits into
microsoft:mainfrom
eavanvalkenburg:function_calling

Conversation

@eavanvalkenburg

@eavanvalkenburg Eduard van Valkenburg (eavanvalkenburg) commented Aug 8, 2023 •

Copy link
Copy Markdown
Member

Motivation and Context

I built support for function calling into SK!

Related to/fixes:

Description

This implementation builds on top of all the existing pieces, but did require some major work, so feel free to comment on where that is or is not appropriate.

  • Added a ChatMessage class to capture the relevant pieces of function calling (name and content)
  • Added a complete_chat_with_functions_async into OpenAIChatCompletions class
  • Added a function_call field to ChatRequestSettings class
  • Added several helper functions and smaller changes
  • Added a sample with updated core_skill that uses function calling to demonstrate
  • Added a second sample that shows how to use function_calling with non-sk functions.

Contribution Checklist

@lemillermicrosoft

Copy link
Copy Markdown
Member

Handful of checks are not yet passing, so will turn this one to draft for now. Please feel free to re-open when things are resolved.

@lemillermicrosoft
Lee Miller (lemillermicrosoft) marked this pull request as draft August 25, 2023 17:41
@eavanvalkenburg
Eduard van Valkenburg (eavanvalkenburg) force-pushed the function_calling branch 2 times, most recently from 40b8ec0 to 10c93fa Compare August 26, 2023 11:25
@eavanvalkenburg

Eduard van Valkenburg (eavanvalkenburg) commented Aug 26, 2023 •

Copy link
Copy Markdown
Member Author

Gina Triolo (@gitri-ms) I got a hanging push earlier, naming is now updated.
Abby Harrison (@awharrison-28) added in the implementation of the chat_messages incl tests from #2442

@eavanvalkenburg

Copy link
Copy Markdown
Member Author

Lee Miller (@lemillermicrosoft) fixed all tests

@eavanvalkenburg
Eduard van Valkenburg (eavanvalkenburg) marked this pull request as ready for review August 27, 2023 17:52

@gitri-ms Gina Triolo (gitri-ms) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just one tiny thing to fix, then LGTM!

@eavanvalkenburg Eduard van Valkenburg (eavanvalkenburg) changed the title Python: WIP: Implement Function calling for Chat Python: Implement Function calling for Chat Aug 30, 2023

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Left some comments, I think we should remove changes to the template config where they are not required and lean on the skill collection for supplying available functions.

@lemillermicrosoft

Copy link
Copy Markdown
Member

Also, right now, having trouble getting it to work.

image

@gitri-ms
Gina Triolo (gitri-ms) marked this pull request as draft August 30, 2023 20:22
@gitri-ms Gina Triolo (gitri-ms) added PR: ready for review All feedback addressed, ready for reviews and removed PR: paused PR temporarily parked labels Oct 5, 2023
@gitri-ms
Gina Triolo (gitri-ms) added this pull request to the merge queue Oct 12, 2023
Merged via the queue into microsoft:main with commit 85ee34b Oct 12, 2023
SOE-YoungS pushed a commit to SOE-YoungS/semantic-kernel that referenced this pull request Nov 1, 2023
### 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.
-->
I built support for function calling into SK!

Related to/fixes: 
- microsoft#2315 
- microsoft#2175 
- microsoft#1450 

### Description

<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->
This implementation builds on top of all the existing pieces, but did
require some major work, so feel free to comment on where that is or is
not appropriate.

- Added a `ChatMessage` class to capture the relevant pieces of function
calling (name and content)
- Added a `complete_chat_with_functions_async` into
OpenAIChatCompletions class
- Added a `function_call` field to ChatRequestSettings class
- Added several helper functions and smaller changes
- Added a sample with updated core_skill that uses function calling to
demonstrate
- Added a second sample that shows how to use function_calling with
non-sk functions.

### 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: Abby Harrison <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: ready for review All feedback addressed, ready for reviews python Pull requests for the Python Semantic Kernel

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

OpenAI Chat Service classes should support function calling and other API updates

7 participants