Skip to content

Commit 7401b45

Browse files
authored
.Net: Add Retrieval API Plugin to CAPs. (#12653)
### Motivation and Context Adds Retrieval API Plugin sample to the Copilot Agent Plugins (CAPs) samples. <!-- 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. --> ### Description This PR adds Retrieval API Plugin sample to the Copilot Agent Plugins (CAPs) samples. The PR also updates the CAPs demo to include the new plugin. <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [x] The code builds clean without any errors or warnings - [ ] 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 - [ ] All unit tests pass, and I have added new tests where possible - [x] I didn't break anyone 😄
1 parent ba031e6 commit 7401b45

File tree

3 files changed

+202
-2
lines changed

3 files changed

+202
-2
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"$schema": "https://developer.microsoft.com/json-schemas/copilot/plugin/v2.1/schema.json",
3+
"schema_version": "v2.1",
4+
"name_for_human": "OData Service for namespace microsoft.graph",
5+
"description_for_human": "This OData service is located at https://graph.microsoft.com/beta",
6+
"description_for_model": "This OData service is located at https://graph.microsoft.com/beta",
7+
"contact_email": "[email protected]",
8+
"namespace": "Retrieval",
9+
"capabilities": {
10+
"conversation_starters": [
11+
{
12+
"text": "Invoke action retrieval"
13+
}
14+
]
15+
},
16+
"functions": [
17+
{
18+
"name": "copilot_retrieval",
19+
"description": "Invoke action retrieval"
20+
}
21+
],
22+
"runtimes": [
23+
{
24+
"type": "OpenApi",
25+
"auth": {
26+
"type": "None"
27+
},
28+
"spec": {
29+
"url": "retrieval-openapi.yml"
30+
},
31+
"run_for_functions": [
32+
"copilot_retrieval"
33+
]
34+
}
35+
]
36+
}
Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
openapi: 3.0.4
2+
info:
3+
title: OData Service for namespace microsoft.graph - Subset
4+
description: This OData service is located at https://graph.microsoft.com/beta
5+
version: beta
6+
servers:
7+
- url: https://graph.microsoft.com/beta
8+
paths:
9+
/copilot/retrieval:
10+
post:
11+
tags:
12+
- copilot.copilotRoot.Actions
13+
summary: Invoke action retrieval
14+
operationId: copilot_retrieval
15+
requestBody:
16+
description: Action parameters
17+
content:
18+
application/json:
19+
schema:
20+
type: object
21+
properties:
22+
queryString:
23+
type: string
24+
dataSource:
25+
title: retrievalDataSource
26+
enum:
27+
- sharePoint
28+
- oneDriveBusiness
29+
- externalItem
30+
- mail
31+
- calendar
32+
- teams
33+
- people
34+
- sharePointEmbedded
35+
- unknownFutureValue
36+
type: string
37+
filterExpression:
38+
type: string
39+
nullable: true
40+
resourceMetadata:
41+
type: array
42+
items:
43+
type: string
44+
nullable: true
45+
maximumNumberOfResults:
46+
maximum: 2147483647
47+
minimum: -2147483648
48+
type: number
49+
format: int32
50+
nullable: true
51+
required: true
52+
responses:
53+
2XX:
54+
description: Success
55+
content:
56+
application/json:
57+
schema:
58+
$ref: '#/components/schemas/microsoft.graph.retrievalResponse'
59+
deprecated: true
60+
x-ms-deprecation:
61+
removalDate: '2025-12-31T00:00:00.0000000+00:00'
62+
date: '2024-02-23T00:00:00.0000000+00:00'
63+
version: 2024-12/PrivatePreview:retrievalAPI
64+
components:
65+
schemas:
66+
microsoft.graph.retrievalResponse:
67+
title: retrievalResponse
68+
required:
69+
- '@odata.type'
70+
type: object
71+
properties:
72+
retrievalHits:
73+
type: array
74+
items:
75+
$ref: '#/components/schemas/microsoft.graph.retrievalHit'
76+
'@odata.type':
77+
type: string
78+
microsoft.graph.retrievalHit:
79+
title: retrievalHit
80+
required:
81+
- '@odata.type'
82+
type: object
83+
properties:
84+
extracts:
85+
type: array
86+
items:
87+
$ref: '#/components/schemas/microsoft.graph.retrievalExtract'
88+
resourceMetadata:
89+
$ref: '#/components/schemas/microsoft.graph.searchResourceMetadataDictionary'
90+
resourceType:
91+
title: retrievalEntityType
92+
enum:
93+
- site
94+
- list
95+
- listItem
96+
- drive
97+
- driveItem
98+
- externalItem
99+
- unknownFutureValue
100+
type: string
101+
sensitivityLabel:
102+
$ref: '#/components/schemas/microsoft.graph.searchSensitivityLabelInfo'
103+
webUrl:
104+
type: string
105+
nullable: true
106+
'@odata.type':
107+
type: string
108+
microsoft.graph.retrievalExtract:
109+
title: retrievalExtract
110+
required:
111+
- '@odata.type'
112+
type: object
113+
properties:
114+
text:
115+
type: string
116+
nullable: true
117+
'@odata.type':
118+
type: string
119+
microsoft.graph.searchResourceMetadataDictionary:
120+
title: searchResourceMetadataDictionary
121+
required:
122+
- '@odata.type'
123+
type: object
124+
properties:
125+
'@odata.type':
126+
type: string
127+
microsoft.graph.searchSensitivityLabelInfo:
128+
title: searchSensitivityLabelInfo
129+
required:
130+
- '@odata.type'
131+
type: object
132+
properties:
133+
color:
134+
type: string
135+
nullable: true
136+
readOnly: true
137+
displayName:
138+
type: string
139+
nullable: true
140+
readOnly: true
141+
isEncrypted:
142+
type: boolean
143+
nullable: true
144+
readOnly: true
145+
priority:
146+
maximum: 2147483647
147+
minimum: -2147483648
148+
type: number
149+
format: int32
150+
nullable: true
151+
readOnly: true
152+
sensitivityLabelId:
153+
type: string
154+
nullable: true
155+
readOnly: true
156+
tooltip:
157+
type: string
158+
nullable: true
159+
readOnly: true
160+
'@odata.type':
161+
type: string
162+
description: "Represents a sensitivityLabel.\nThis model is shared with the CCS retrieval API and search where it is already unhidden."

dotnet/samples/Demos/CopilotAgentPlugins/CopilotAgentPluginsDemoSample/DemoCommand.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,7 @@ private async Task AddCopilotAgentPluginAsync(Kernel kernel, IConfigurationRoot
364364
FunctionExecutionParameters = new()
365365
{
366366
{ "https://graph.microsoft.com/v1.0", new OpenApiFunctionExecutionParameters(authCallback: this._bearerAuthenticationProviderWithCancellationToken.AuthenticateRequestAsync, enableDynamicOperationPayload: false, enablePayloadNamespacing: true) { ParameterFilter = s_restApiParameterFilter} },
367+
{ "https://graph.microsoft.com/beta", new OpenApiFunctionExecutionParameters(authCallback: this._bearerAuthenticationProviderWithCancellationToken.AuthenticateRequestAsync, enableDynamicOperationPayload: false, enablePayloadNamespacing: true) { ParameterFilter = s_restApiParameterFilter} },
367368
{ "https://api.nasa.gov/planetary", new OpenApiFunctionExecutionParameters(authCallback: GetApiKeyAuthProvider("DEMO_KEY", "api_key", false), enableDynamicOperationPayload: false, enablePayloadNamespacing: true)}
368369
},
369370
};
@@ -500,8 +501,9 @@ private static void TrimPropertiesFromJsonNode(JsonNode jsonNode)
500501
{
501502
#pragma warning restore SKEXP0040
502503
if (("me_sendMail".Equals(context.Operation.Id, StringComparison.OrdinalIgnoreCase) ||
503-
("me_calendar_CreateEvents".Equals(context.Operation.Id, StringComparison.OrdinalIgnoreCase)) &&
504-
"payload".Equals(context.Parameter.Name, StringComparison.OrdinalIgnoreCase)))
504+
("me_calendar_CreateEvents".Equals(context.Operation.Id, StringComparison.OrdinalIgnoreCase) ||
505+
("copilot_retrieval".Equals(context.Operation.Id, StringComparison.OrdinalIgnoreCase)) &&
506+
"payload".Equals(context.Parameter.Name, StringComparison.OrdinalIgnoreCase))))
505507
{
506508
context.Parameter.Schema = TrimPropertiesFromRequestBody(context.Parameter.Schema);
507509
return context.Parameter;

0 commit comments

Comments
 (0)