Skip to content

Commit d43fe29

Browse files
authored
Add SharePoint delta tool call. (#42623)
* Add SharePoint delta tool call. * Add CodeIterpreter tests and Improve code interpreter. * Generate code from the main branch.
1 parent ae93966 commit d43fe29

18 files changed

+472
-30
lines changed

sdk/ai/azure-ai-agents/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
- Added delete operation for `ThreadMessages`.
1111
- Add `RunStepDetailsActivity`, describing MCP function parameters.
1212
- Add `RunStepDeltaCustomBingGroundingToolCall`, describing `BingCustomSearchTool` updates in streaming scenario.
13+
- Add `RunStepDeltaMicrosoftFabricToolCall`, describing `FabricTool` updates in streaming scenario.
14+
- Add `RunStepDeltaSharepointToolCall`, describing `SharepointTool` updates in streaming scenario.
15+
- Improve code interpreter tool to take the list of `VectorStoreDataSource` as an input for enterprise file search.
1316

1417
### Bugs Fixed
1518

@@ -18,6 +21,7 @@
1821
### Sample updates
1922

2023
- The file search samples were updated to demonstrate retrieving text associated with citations.
24+
- The SharePoint tool sample was updated to demonstrate retrieving text associated with citations and render references correctly.
2125
- Added samples for file search citation with streaming.
2226
- Bing Grounding and Bing Custom Search samples were fixed to correctly present references.
2327

sdk/ai/azure-ai-agents/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -876,7 +876,7 @@ Here is an example:
876876
<!-- SNIPPET:sample_agents_browser_automation.create_agent_with_browser_automation -->
877877

878878
```python
879-
connection_id = os.environ["AZURE_PLAYWRIGHT_CONNECTION_ID"]
879+
connection_id = project_client.connections.get(os.environ["AZURE_PLAYWRIGHT_CONNECTION_NAME"]).id
880880

881881
# Initialize Browser Automation tool and add the connection id
882882
browser_automation = BrowserAutomationTool(connection_id=connection_id)
@@ -911,7 +911,7 @@ Here is an example:
911911
<!-- SNIPPET:sample_agents_fabric.create_agent_with_fabric_tool -->
912912

913913
```python
914-
conn_id = os.environ["FABRIC_CONNECTION_ID"]
914+
conn_id = project_client.connections.get(os.environ["FABRIC_CONNECTION_NAME"]).id
915915

916916
print(conn_id)
917917

sdk/ai/azure-ai-agents/apiview-properties.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@
152152
"azure.ai.agents.models.RunStepDeltaMicrosoftFabricToolCall": "Azure.AI.Agents.RunStepDeltaMicrosoftFabricToolCall",
153153
"azure.ai.agents.models.RunStepDeltaOpenAPIObject": "Azure.AI.Agents.RunStepDeltaOpenAPIObject",
154154
"azure.ai.agents.models.RunStepDeltaOpenAPIToolCall": "Azure.AI.Agents.RunStepDeltaOpenAPIToolCall",
155+
"azure.ai.agents.models.RunStepDeltaSharepointToolCall": "Azure.AI.Agents.RunStepDeltaSharepointToolCall",
155156
"azure.ai.agents.models.RunStepDeltaToolCallObject": "Azure.AI.Agents.RunStepDeltaToolCallObject",
156157
"azure.ai.agents.models.RunStepDetailsActivity": "Azure.AI.Agents.RunStepDetailsActivity",
157158
"azure.ai.agents.models.RunStepError": "Azure.AI.Agents.RunStepError",

sdk/ai/azure-ai-agents/assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"AssetsRepo": "Azure/azure-sdk-assets",
33
"AssetsRepoPrefixPath": "python",
44
"TagPrefix": "python/ai/azure-ai-agents",
5-
"Tag": "python/ai/azure-ai-agents_3c8c500083"
5+
"Tag": "python/ai/azure-ai-agents_cf22042479"
66
}

sdk/ai/azure-ai-agents/azure/ai/agents/models/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@
161161
RunStepDeltaMicrosoftFabricToolCall,
162162
RunStepDeltaOpenAPIObject,
163163
RunStepDeltaOpenAPIToolCall,
164+
RunStepDeltaSharepointToolCall,
164165
RunStepDeltaToolCall,
165166
RunStepDeltaToolCallObject,
166167
RunStepDetails,
@@ -403,6 +404,7 @@
403404
"RunStepDeltaMicrosoftFabricToolCall",
404405
"RunStepDeltaOpenAPIObject",
405406
"RunStepDeltaOpenAPIToolCall",
407+
"RunStepDeltaSharepointToolCall",
406408
"RunStepDeltaToolCall",
407409
"RunStepDeltaToolCallObject",
408410
"RunStepDetails",

sdk/ai/azure-ai-agents/azure/ai/agents/models/_models.py

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5112,7 +5112,7 @@ class RunStepDeltaToolCall(_Model):
51125112
RunStepDeltaCodeInterpreterToolCall, RunStepDeltaConnectedAgentToolCall,
51135113
RunStepDeltaDeepResearchToolCall, RunStepDeltaMicrosoftFabricToolCall,
51145114
RunStepDeltaFileSearchToolCall, RunStepDeltaFunctionToolCall, RunStepDeltaMcpToolCall,
5115-
RunStepDeltaOpenAPIToolCall
5115+
RunStepDeltaOpenAPIToolCall, RunStepDeltaSharepointToolCall
51165116
51175117
:ivar index: The index of the tool call detail in the run step's tool_calls array. Required.
51185118
:vartype index: int
@@ -6071,6 +6071,46 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
60716071
super().__init__(*args, type="openapi", **kwargs)
60726072

60736073

6074+
class RunStepDeltaSharepointToolCall(RunStepDeltaToolCall, discriminator="sharepoint_grounding"):
6075+
"""Represents the SharePoint tool call in a streaming run step.
6076+
6077+
:ivar index: The index of the tool call detail in the run step's tool_calls array. Required.
6078+
:vartype index: int
6079+
:ivar id: The ID of the tool call, used when submitting outputs to the run. Required.
6080+
:vartype id: str
6081+
:ivar type: The object type, which is always 'sharepoint_grounding'. Required. Default value is
6082+
"sharepoint_grounding".
6083+
:vartype type: str
6084+
:ivar sharepoint_grounding: SharePoint tool input and output. Required.
6085+
:vartype sharepoint_grounding: dict[str, str]
6086+
"""
6087+
6088+
type: Literal["sharepoint_grounding"] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore
6089+
"""The object type, which is always 'sharepoint_grounding'. Required. Default value is
6090+
\"sharepoint_grounding\"."""
6091+
sharepoint_grounding: Dict[str, str] = rest_field(visibility=["read", "create", "update", "delete", "query"])
6092+
"""SharePoint tool input and output. Required."""
6093+
6094+
@overload
6095+
def __init__(
6096+
self,
6097+
*,
6098+
index: int,
6099+
id: str, # pylint: disable=redefined-builtin
6100+
sharepoint_grounding: Dict[str, str],
6101+
) -> None: ...
6102+
6103+
@overload
6104+
def __init__(self, mapping: Mapping[str, Any]) -> None:
6105+
"""
6106+
:param mapping: raw JSON to initialize the model.
6107+
:type mapping: Mapping[str, Any]
6108+
"""
6109+
6110+
def __init__(self, *args: Any, **kwargs: Any) -> None:
6111+
super().__init__(*args, type="sharepoint_grounding", **kwargs)
6112+
6113+
60746114
class RunStepDeltaToolCallObject(RunStepDeltaDetail, discriminator="tool_calls"):
60756115
"""Represents an invocation of tool calls as part of a streaming run step.
60766116
@@ -6601,7 +6641,7 @@ class RunStepSharepointToolCall(RunStepToolCall, discriminator="sharepoint_groun
66016641
:ivar type: The object type, which is always 'sharepoint_grounding'. Required. Default value is
66026642
"sharepoint_grounding".
66036643
:vartype type: str
6604-
:ivar share_point: Reserved for future use. Required.
6644+
:ivar share_point: SharePoint tool input and output. Required.
66056645
:vartype share_point: dict[str, str]
66066646
"""
66076647

@@ -6611,7 +6651,7 @@ class RunStepSharepointToolCall(RunStepToolCall, discriminator="sharepoint_groun
66116651
share_point: Dict[str, str] = rest_field(
66126652
name="sharepoint_grounding", visibility=["read", "create", "update", "delete", "query"]
66136653
)
6614-
"""Reserved for future use. Required."""
6654+
"""SharePoint tool input and output. Required."""
66156655

66166656
@overload
66176657
def __init__(

sdk/ai/azure-ai-agents/azure/ai/agents/models/_patch.py

Lines changed: 48 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1431,31 +1431,68 @@ class CodeInterpreterTool(Tool[CodeInterpreterToolDefinition]):
14311431
14321432
:param file_ids: A list of file IDs to interpret.
14331433
:type file_ids: list[str]
1434+
:param data_sources: The list of data sources for the enterprise file search.
1435+
:type data_sources: list[VectorStoreDataSource]
1436+
:raises: ValueError if both file_ids and data_sources are provided.
14341437
"""
14351438

1436-
def __init__(self, file_ids: Optional[List[str]] = None):
1437-
if file_ids is None:
1438-
self.file_ids = set()
1439-
else:
1439+
_INVALID_CONFIGURATION = "file_ids and data_sources are mutually exclusive."
1440+
1441+
def __init__(
1442+
self,
1443+
file_ids: Optional[List[str]] = None,
1444+
data_sources: Optional[List[VectorStoreDataSource]] = None,
1445+
):
1446+
if file_ids and data_sources:
1447+
raise ValueError(CodeInterpreterTool._INVALID_CONFIGURATION)
1448+
self.file_ids = set()
1449+
if file_ids:
14401450
self.file_ids = set(file_ids)
1451+
self.data_sources: Dict[str, VectorStoreDataSource] = {}
1452+
if data_sources:
1453+
self.data_sources = {ds.asset_identifier: ds for ds in data_sources}
14411454

14421455
def add_file(self, file_id: str) -> None:
14431456
"""
14441457
Add a file ID to the list of files to interpret.
14451458
14461459
:param file_id: The ID of the file to interpret.
14471460
:type file_id: str
1461+
:raises: ValueError if data_sources are provided.
14481462
"""
1463+
if self.data_sources:
1464+
raise ValueError(CodeInterpreterTool._INVALID_CONFIGURATION)
14491465
self.file_ids.add(file_id)
14501466

1467+
def add_data_source(self, data_source: VectorStoreDataSource) -> None:
1468+
"""
1469+
Add a data source to the list of data sources to interpret.
1470+
1471+
:param data_source: The new data source.
1472+
:type data_source: VectorStoreDataSource
1473+
:raises: ValueError if file_ids are provided.
1474+
"""
1475+
if self.file_ids:
1476+
raise ValueError(CodeInterpreterTool._INVALID_CONFIGURATION)
1477+
self.data_sources[data_source.asset_identifier] = data_source
1478+
14511479
def remove_file(self, file_id: str) -> None:
14521480
"""
14531481
Remove a file ID from the list of files to interpret.
14541482
14551483
:param file_id: The ID of the file to remove.
14561484
:type file_id: str
14571485
"""
1458-
self.file_ids.remove(file_id)
1486+
self.file_ids.discard(file_id)
1487+
1488+
def remove_data_source(self, asset_identifier: str) -> None:
1489+
"""
1490+
Remove The asset from data_sources.
1491+
1492+
:param asset_identifier: The asset identifier to remove.
1493+
:type asset_identifier: str
1494+
"""
1495+
self.data_sources.pop(asset_identifier, None)
14591496

14601497
@property
14611498
def definitions(self) -> List[CodeInterpreterToolDefinition]:
@@ -1473,9 +1510,13 @@ def resources(self) -> ToolResources:
14731510
14741511
:rtype: ToolResources
14751512
"""
1476-
if not self.file_ids:
1513+
if not self.file_ids and not self.data_sources:
14771514
return ToolResources()
1478-
return ToolResources(code_interpreter=CodeInterpreterToolResource(file_ids=list(self.file_ids)))
1515+
if self.file_ids:
1516+
return ToolResources(code_interpreter=CodeInterpreterToolResource(file_ids=list(self.file_ids)))
1517+
return ToolResources(
1518+
code_interpreter=CodeInterpreterToolResource(data_sources=list(self.data_sources.values()))
1519+
)
14791520

14801521
def execute(self, tool_call: Any) -> Any:
14811522
pass

sdk/ai/azure-ai-agents/azure_ai_agents_tests.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ AZURE_AI_AGENTS_TESTS_DEEP_RESEARCH_MODEL=
2121
AZURE_AI_AGENTS_TESTS_BING_CUSTOM_CONNECTION_ID=
2222
AZURE_AI_AGENTS_TESTS_BING_CONFIGURATION_NAME=
2323
AZURE_AI_AGENTS_TESTS_FABRIC_CONNECTION_ID=
24+
AZURE_AI_AGENTS_TESTS_SHAREPOINT_CONNECTION_ID=

sdk/ai/azure-ai-agents/cspell.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"oupfoo",
1717
"abcdabcdabcda",
1818
"abcdefghijklm",
19+
"azureai"
1920
],
2021
"ignorePaths": [
2122
"*.csv",

sdk/ai/azure-ai-agents/samples/agents_tools/sample_agents_browser_automation.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,8 @@
2222
page of your Azure AI Foundry portal.
2323
2) MODEL_DEPLOYMENT_NAME - The deployment name of the AI model, as found under the "Name" column in
2424
the "Models + endpoints" tab in your Azure AI Foundry project.
25-
3) AZURE_PLAYWRIGHT_CONNECTION_ID - The ID of the Azure Playwright Workspaces connection, in the format of:
26-
/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.MachineLearningServices/workspaces/{workspace-name}/connections/{connection-name}
27-
You can also get the connection ID programmatically from AIProjectClient, using the call
28-
`project_client.connections.get("<playwright-connection-name>").id`.
25+
3) AZURE_PLAYWRIGHT_CONNECTION_NAME - The name of a connection to the Azure Playwright Workspace as it is
26+
listed in Azure AI Foundry connected resources.
2927
"""
3028

3129
import os
@@ -41,7 +39,7 @@
4139
project_client = AIProjectClient(endpoint=os.environ["PROJECT_ENDPOINT"], credential=DefaultAzureCredential())
4240

4341
# [START create_agent_with_browser_automation]
44-
connection_id = os.environ["AZURE_PLAYWRIGHT_CONNECTION_ID"]
42+
connection_id = project_client.connections.get(os.environ["AZURE_PLAYWRIGHT_CONNECTION_NAME"]).id
4543

4644
# Initialize Browser Automation tool and add the connection id
4745
browser_automation = BrowserAutomationTool(connection_id=connection_id)

0 commit comments

Comments
 (0)