Skip to content

Commit 6de3355

Browse files
KanchiShimonomoonbox3
authored andcommitted
Python: Include Bing Grounding Tool call results in invoke_stream responses (microsoft#12265)
### Motivation and Context According to the [Terms of Service for Grounding with Bing Search](https://www.microsoft.com/en-us/bing/apis/grounding-legal#use-and-display-requirements), the tool’s call results must be displayed in their original format. Currently, in the `AzureAIAgent` `invoke/invoke_stream` responses, search results are included in the `AnnotationContent`, but the search query itself is not. This PR updates the response of `invoke/invoke_stream` to include the Bing Grounding Tool’s call results, so that the Bing search query can also be displayed. ### Description - Fixe an issue where errors occurred when handling Bing Grounding Tool results in streaming mode - Update `invoke/invoke_stream` responses to include the Bing Grounding Tool call results ### 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]>
1 parent d08b225 commit 6de3355

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

python/semantic_kernel/agents/azure_ai/agent_content_generation.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -398,14 +398,13 @@ def generate_streaming_bing_grounding_content(
398398

399399
for index, tool in enumerate(step_details.tool_calls):
400400
if tool.type == "bing_grounding":
401-
bing_tool = cast(RunStepBingGroundingToolCall, tool)
402-
arguments = getattr(bing_tool, "bing_grounding", None)
401+
arguments = tool.get("bing_grounding", None)
403402
items.append(
404403
FunctionCallContent(
405-
id=bing_tool.id,
404+
id=tool.id,
406405
index=index,
407-
name=bing_tool.type,
408-
function_name=bing_tool.type,
406+
name=tool.type,
407+
function_name=tool.type,
409408
arguments=arguments,
410409
)
411410
)

0 commit comments

Comments
 (0)