A modern .NET 10 Blazor Web Application that enables intelligent conversations with your custom documents using semantic search and vector embeddings.
- .NET 10 SDK
- Visual Studio 2022 or VS Code
- GitHub Models API Token (free tier available)
-
Add your documents
- Place PDF files in
wwwroot/Data/directory - Example PDFs included:
Example_Emergency_Survival_Kit.pdf,Example_GPS_Watch.pdf
- Place PDF files in
-
Configure GitHub Models Token
- Right-click project in Solution Explorer → "Manage User Secrets"
- Add:
{ "GitHubModels:Token": "YOUR-GITHUB-TOKEN" } - Get token here
-
Run the application
dotnet run
- Open
https://localhost:5001and start chatting!
- Open
Data Flow:
- User embeds message to vector representation
- Semantic search finds top 5 relevant document chunks in SQLite
- AI receives message + context chunks
- Response with citations displayed to user
Ingestion Pipeline:
- PDFs loaded from
/wwwroot/Data/ - Split into semantic chunks
- Embedded to 1536-dimensional vectors
- Stored in SQLite vector database
| Component | Purpose |
|---|---|
Chat.razor |
Main chat interface |
ChatHeader/Input/MessageList.razor |
UI components |
SemanticSearch.cs |
Vector similarity search |
DataIngestor.cs |
Document ingestion & embedding |
PDFDirectorySource.cs |
PDF loader |
IngestedChunk/Document.cs |
Data models |
{
"AiModels": {
"ChatModel": "gpt-4o-mini",
"EmbeddingModel": "text-embedding-3-small",
"Endpoint": "https://models.inference.ai.azure.com"
}
}| Model | Speed | Cost | Best For |
|---|---|---|---|
| gpt-4o-mini | ⚡ Fast | $ Low | Current (default) |
| gpt-4o | Fast | $$ Medium | General use |
| o1 | Slow | $$$ High | Complex reasoning |
| o1-mini | Medium | $$ Medium | Balanced reasoning |
| llama-2-70b | Fast | $ Free | Budget option |
To switch models: Edit AiModels:ChatModel in appsettings.json
✅ Semantic Search - Find relevant info using meaning, not keywords
✅ Auto Tool Calling - AI decides when to search documents
✅ Citations - Exact quotes with document sources
✅ Copy & Listen - One-click copy and text-to-speech
✅ Edit Questions - Modify and re-ask instantly
✅ Multi-turn Chat - Full conversation context
✅ Configurable Models - Easy model switching
✅ Local Vector DB - Fast, private search
✅ API keys in User Secrets (not in source control)
✅ Semantic search limits AI to ingested documents
✅ System prompt prevents out-of-context responses
✅ Vector DB local (no cloud content storage)
AIChatBotS/
├── Components/Pages/Chat/
│ ├── Chat.razor, ChatHeader.razor, ChatInput.razor
│ └── ChatMessageList.razor, ChatMessageItem.razor
├── Services/
│ ├── SemanticSearch.cs
│ └── Ingestion/
│ ├── DataIngestor.cs, PDFDirectorySource.cs
│ └── IngestedChunk.cs, IngestedDocument.cs
├── wwwroot/Data/ (Add PDFs here)
├── Program.cs
├── appsettings.json
└── README.md
// Implement IIngestionSource interface
// Add to Program.cs:
await DataIngestor.IngestDataAsync(app.Services, new YourCustomSource());- System Prompt: Edit
Chat.razorSystemPromptconstant - Button Actions: Edit
ChatMessageItem.razor - Embedding Model: Change
EmbeddingModelinappsettings.json
- ❌ Chat not working → Verify GitHub token in User Secrets
- ❌ No results → Ensure PDFs are in
wwwroot/Data/ - ❌ Model errors → Check model supports tool calling
- ❌ Slow responses → Consider
gpt-4o-minifor speed
Built with ❤️ using .NET 10 and Blazor