Repository navigation
Python: Invoke the model one more time after auto invoke has exhausted #13236
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
base: main
Are you sure you want to change the base?
Changes from all commits
4383883
1ee45c0
af604d9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -99,9 +99,7 @@ async def get_chat_message_contents( | |
| Returns: | ||
| A list of chat message contents representing the response(s) from the LLM. | ||
| """ | ||
| from semantic_kernel.connectors.ai.function_calling_utils import ( | ||
| merge_function_results, | ||
| ) | ||
| from semantic_kernel.connectors.ai.function_calling_utils import merge_function_results | ||
|
|
||
| # Create a copy of the settings to avoid modifying the original settings | ||
| settings = copy.deepcopy(settings) | ||
|
|
@@ -210,9 +208,7 @@ async def get_streaming_chat_message_contents( | |
| Yields: | ||
| A stream representing the response(s) from the LLM. | ||
| """ | ||
| from semantic_kernel.connectors.ai.function_calling_utils import ( | ||
| merge_streaming_function_results, | ||
| ) | ||
| from semantic_kernel.connectors.ai.function_calling_utils import merge_streaming_function_results | ||
|
|
||
| # Create a copy of the settings to avoid modifying the original settings | ||
| settings = copy.deepcopy(settings) | ||
|
|
@@ -316,6 +312,13 @@ async def get_streaming_chat_message_contents( | |
|
|
||
| if any(result.terminate for result in results if result is not None): | ||
| break | ||
| else: | ||
| # Do a final call, without function calling when the max has been reached. | ||
| self._reset_function_choice_settings(settings) | ||
| async for streaming_chat_message_contents in self._inner_get_streaming_chat_message_contents( | ||
| chat_history, settings | ||
| ): | ||
| yield streaming_chat_message_contents | ||
|
Comment on lines
+315
to
+321
|
||
|
|
||
| async def get_streaming_chat_message_content( | ||
| self, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the final non function calling call,
_inner_get_streaming_chat_message_contentsis invoked without passingfunction_invoke_attempt, so derived connectors will default it to0. That can produce duplicatefunction_invoke_attemptvalues across attempts and may break consumers that group, dedupe, or combine streaming messages by attempt. Pass an explicit attempt index for this final call, for examplesettings.function_choice_behavior.maximum_auto_invoke_attempts.