Skip to content

Add SPE Agent with Retrieval from existing source#253

Open
pemtaira-msft wants to merge 1 commit into
microsoft:mainfrom
pemtaira-msft:user/pemtaira/add-spe-retrieval-integ
Open

Add SPE Agent with Retrieval from existing source#253
pemtaira-msft wants to merge 1 commit into
microsoft:mainfrom
pemtaira-msft:user/pemtaira/add-spe-retrieval-integ

Conversation

@pemtaira-msft

Copy link
Copy Markdown
Collaborator

Originally from: https://github.com/yratna/SPEAgentWithRetrieval

This has been updated to work with SPE, not sharepoint.

Originally from: https://github.com/yratna/SPEAgentWithRetrieval

This has been updated to work with SPE, not sharepoint.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new .NET 8 console sample (“SPEAgentWithRetrieval”) that demonstrates retrieval-augmented generation over SharePoint Embedded (SPE) content using the Microsoft 365 Copilot Retrieval API for grounding and Azure AI Foundry for response generation.

Changes:

  • Introduces a new solution with a console entrypoint and a reusable Core library (retrieval, Foundry chat completion, auth/token acquisition).
  • Adds end-to-end sample documentation, example configuration, and helper scripts for app registration fixes.
  • Adds throttling retry handling for Retrieval API calls and basic console UX for interactive Q&A.

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 14 comments.

Show a summary per file
File Description
AI/agent-with-retrieval-sample-app/SPEAgentWithRetrieval.sln Adds solution containing console app + Core library projects.
AI/agent-with-retrieval-sample-app/SPEAgentWithRetrieval.csproj Adds .NET 8 console project and references Core library.
AI/agent-with-retrieval-sample-app/SPEAgentWithRetrieval.Core/SPEAgentWithRetrieval.Core.csproj Adds Core library project and NuGet dependencies.
AI/agent-with-retrieval-sample-app/SPEAgentWithRetrieval.Core/Services/TokenProvider.cs Implements auth/token acquisition using Azure Identity credentials and token caching.
AI/agent-with-retrieval-sample-app/SPEAgentWithRetrieval.Core/Services/IRetrievalService.cs Defines retrieval abstraction for grounding content.
AI/agent-with-retrieval-sample-app/SPEAgentWithRetrieval.Core/Services/IFoundryService.cs Defines abstraction for Foundry chat response generation.
AI/agent-with-retrieval-sample-app/SPEAgentWithRetrieval.Core/Services/IChatService.cs Defines orchestration abstraction for chat flow.
AI/agent-with-retrieval-sample-app/SPEAgentWithRetrieval.Core/Services/FoundryService.cs Implements chat completions via Azure AI Foundry inference endpoint.
AI/agent-with-retrieval-sample-app/SPEAgentWithRetrieval.Core/Services/CopilotRetrievalService.cs Implements Microsoft Graph Copilot Retrieval API calls scoped to SPE container type.
AI/agent-with-retrieval-sample-app/SPEAgentWithRetrieval.Core/Services/ChatService.cs Orchestrates retrieval + response synthesis and returns sources.
AI/agent-with-retrieval-sample-app/SPEAgentWithRetrieval.Core/Models/Configuration.cs Adds options models for Foundry, Microsoft 365, and chat settings.
AI/agent-with-retrieval-sample-app/SPEAgentWithRetrieval.Core/Models/ChatModels.cs Adds request/response/source models for the chat pipeline.
AI/agent-with-retrieval-sample-app/README.md Adds setup, architecture, troubleshooting, and usage documentation for the sample.
AI/agent-with-retrieval-sample-app/Program.cs Adds console host wiring, DI registration, and main chat loop UI.
AI/agent-with-retrieval-sample-app/fix-azure-app-registration.sh Adds bash automation for adjusting app registration auth platforms.
AI/agent-with-retrieval-sample-app/fix-azure-app-registration.ps1 Adds PowerShell automation for adjusting app registration auth platforms.
AI/agent-with-retrieval-sample-app/appsettings.example.json Adds example configuration template for Foundry, Graph scopes, and chat settings.
AI/agent-with-retrieval-sample-app/.gitignore Ensures appsettings and related sensitive configs are not committed.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +9 to +12
<ItemGroup>
<PackageReference Include="Azure.AI.Projects" Version="1.0.0-beta.2" />
<PackageReference Include="Azure.Identity" Version="1.14.2" />
<PackageReference Include="System.Text.Json" Version="8.0.5" />
Comment on lines +40 to +44
TokenCachePersistenceOptions = new TokenCachePersistenceOptions
{
Name = "SPEAgentAuthCache",
UnsafeAllowUnencryptedStorage = true
},
Comment on lines +63 to +67
TokenCachePersistenceOptions = new TokenCachePersistenceOptions
{
Name = "SPEAgentAuthCache",
UnsafeAllowUnencryptedStorage = true // For development only
},
Comment on lines +14 to +18
private readonly Microsoft365Options _microsoft365Options;
private readonly ChatSettingsOptions _chatSettings;
private readonly ILogger<CopilotRetrievalService> _logger;
private readonly ITokenProvider _tokenProvider;

// HTTP 429 or, for the SPE datasource, as an HTTP 500 whose body carries "code":"429".
// Retry a few times with exponential backoff before giving up.
const int maxAttempts = 4;
using var httpClient = new HttpClient();
public bool UseUserAuthentication { get; set; } = true;
public bool UseDeviceCodeAuth { get; set; } = false;
public string[] Scopes { get; set; } = { "https://graph.microsoft.com/FileStorageContainer.Selected" };
public bool AllowAnonymousRequests { get; set; } = false; // For development only - allows requests without authentication
Comment on lines +49 to +52
logger.LogInformation("Azure AI Chat Agent with SharePoint RAG started");

System.Console.WriteLine("=== Azure AI Chat Agent with SharePoint RAG ===");
System.Console.WriteLine("Ask questions about your Microsoft 365 content!");

```bash
git clone <your-repo-url>
cd SPEAgentWithRetrieval

### Bash Script (macOS/Linux)
```bash
./fix-azure-app-registration.sh

### PowerShell Script (Windows/Cross-platform)
```powershell
./fix-azure-app-registration.ps1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants