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: Implement AI request settings #4097

Merged
merged 45 commits into from
Jan 3, 2024

Conversation

eavanvalkenburg
Copy link
Member

@eavanvalkenburg eavanvalkenburg commented Dec 8, 2023

Motivation and Context

This PR implements the new approach to AI Request settings as described here: https://github.com/microsoft/semantic-kernel/blob/main/docs/decisions/0008-support-generic-llm-request-settings.md and completes #3312

Description

Does this:

  • Creates AI Request Settings with service_id (referring to the registered AI services in a kernel) and extension_data, a dict that can hold any number of settings
  • has several methods:
    • from_ai_request_settings -> constructor to create a new request_settings object based on another, supports creating specific ai_request_settings from generic ones.
    • update_from_ai_request_settings -> updating the fields of a request setting from another ones.
    • prepare_settings_dict -> method that is used when actually creating the dict that get's passed to the handler of the AI service.
  • Created subclasses like OpenAIChatRequestSettings which has all the required fields of a OpenAI Chat completion, same for OpenAIText, AzureChat, GooglePalm, HuggingFace, etc.
  • added get_request_settings_class to ai_services to return the class used for the settings for that service.

The goal is that when running, this settings object get's updated and a single operations (called prepare_settings_dict) is used to return a dict that can be passed to the api call directly, thereby reducing the need for custom logic everywhere, this will also negate the need for things like complete_chat_with_functions_async and others. So also removed complete_chat_..._async methods from openai and azure openai.

It has also changed the prompt_template_config with the generic type for the AIRequestSettings or subclasses, and some other changes.

Contribution Checklist

@eavanvalkenburg eavanvalkenburg requested a review from a team as a code owner December 8, 2023 09:01
@eavanvalkenburg eavanvalkenburg marked this pull request as draft December 8, 2023 09:01
@shawncal shawncal added the python Pull requests for the Python Semantic Kernel label Dec 8, 2023
@moonbox3
Copy link
Contributor

moonbox3 commented Dec 9, 2023

What an awesome PR. Thank you for doing this. I love the direction we're heading and how much you're simplifying config related items.

@moonbox3
Copy link
Contributor

moonbox3 commented Dec 9, 2023

Have we gone through all Kernel examples and updated them with these new settings? Does the example chat_gpt_api_function_calling need any update regarding the prompt template config.

@eavanvalkenburg eavanvalkenburg force-pushed the ai_request_settings branch 2 times, most recently from e29e8c4 to 6cf6f1d Compare December 11, 2023 13:25
@eavanvalkenburg eavanvalkenburg force-pushed the ai_request_settings branch 4 times, most recently from e96557d to dc24883 Compare December 12, 2023 19:16
@eavanvalkenburg eavanvalkenburg marked this pull request as ready for review December 12, 2023 19:41
@eavanvalkenburg eavanvalkenburg force-pushed the ai_request_settings branch 2 times, most recently from 6e969ce to addcc5a Compare December 13, 2023 10:45
@eavanvalkenburg eavanvalkenburg marked this pull request as draft December 13, 2023 10:46
@moonbox3 moonbox3 mentioned this pull request Dec 13, 2023
4 tasks
@eavanvalkenburg eavanvalkenburg force-pushed the ai_request_settings branch 4 times, most recently from e54242f to 8ae7a07 Compare December 18, 2023 13:03
@eavanvalkenburg eavanvalkenburg marked this pull request as ready for review December 18, 2023 13:44
@eavanvalkenburg eavanvalkenburg force-pushed the ai_request_settings branch 4 times, most recently from 692c4ab to b8effc1 Compare December 21, 2023 13:42
@eavanvalkenburg eavanvalkenburg force-pushed the ai_request_settings branch 2 times, most recently from 6249156 to b7b0eeb Compare January 3, 2024 19:15
@moonbox3 moonbox3 added this pull request to the merge queue Jan 3, 2024
@moonbox3 moonbox3 removed this pull request from the merge queue due to a manual request Jan 3, 2024
@moonbox3 moonbox3 added this pull request to the merge queue Jan 3, 2024
Merged via the queue into microsoft:main with commit b91529a Jan 3, 2024
26 checks passed
@eavanvalkenburg eavanvalkenburg deleted the ai_request_settings branch January 4, 2024 14:42
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.

None yet

5 participants