This project aims to practice building a chatbot in C#
- .NET 10
- .NET Aspire
- Blazor
- Microsoft Agent Framework
- LightRAG
- Support multiple LLMs: GitHub Models, Open AI, Azure Open AI etc.
- SQL Server
Details about the project can be referenced at DeepWiki: https://deepwiki.com/nashtech-garage/ntg-agent
Run the project locally with .NET Aspire.
The AppHost orchestrates everything: it starts a SQL Server container, runs EF migrations for Admin and Orchestrator, then launches all 5 services with service discovery and config wiring. No local SQL Server install required.
Prerequisites: .NET 10 SDK, Docker (used by Aspire to run the SQL Server container), and the dotnet-ef global tool:
dotnet tool install --global dotnet-ef-
Create a GitHub fine-grained personal access token with models:read permission.
-
Set AppHost user-secrets once per developer. Use the helper script (recommended) or set them manually.
Helper script — prompts for any value not already provided via env var or
.env, auto-generates the LightRAG keys if missing, and writes everything to user-secrets:./scripts/init-apphost-user-secrets.sh
Resolution per value: exported env var → interactive prompt (TTY only) →
$REPO_ROOT/.env→ default. Non-interactive example (skips all prompts):GITHUB_TOKEN=ghp_xxx ./scripts/init-apphost-user-secrets.sh
Useful flags:
--dry-runto preview without writing,--helpfor details.Manual equivalent — if you prefer not to run the script:
cd NTG.Agent.AppHost dotnet user-secrets set "Parameters:sql-sa-password" "Admin123_Strong!" dotnet user-secrets set "Parameters:github-token" "<your GitHub token>" dotnet user-secrets set "Parameters:google-api-key" "<google CSE api key, or placeholder>" dotnet user-secrets set "Parameters:google-search-engine-id" "<google CSE id, or placeholder>" dotnet user-secrets set "Parameters:lightrag-pg-password" "<postgres password>" dotnet user-secrets set "Parameters:lightrag-api-key" "<32+ char random string>" dotnet user-secrets set "Parameters:lightrag-embedding-api-key" "<Azure OpenAI key for LightRAG>"
-
Run the AppHost:
dotnet run --project NTG.Agent.AppHost
Or use the dev shortcut, which also opens the Aspire dashboard in your browser automatically (see Dev shortcuts below):
./ntg run
-
Open the Aspire Dashboard URL printed at startup. Resources you'll see:
sqlserver— SQL Server 2022 container with a persistent volumedb-migrate-admin,db-migrate-orchestrator— one-shot EF migrations (finished)ntg-agent-mcp-server,ntg-agent-orchestrator— backend servicesntg-agent-webclient— end-user chat UI (default admin account:admin@ntgagent.com/Ntg@123)ntg-agent-admin— admin dashboard
-
In the Admin dashboard, open Agent Management > Agent Default and set the GitHub Model provider using the token from step 1:
- Provider Name:
GitHub Model - Provider Endpoint:
https://models.github.ai/inference - Provider API Key: your GitHub token
- Model Name:
openai/gpt-4.1(or another model your token supports)
- Provider Name:
./ntg is a small launcher for the commands you run all the time, so you don't have to
memorize or retype them. No installation required (pure bash).
./ntg # interactive menu of available commands
./ntg help # list commands with descriptions
./ntg run # dotnet run the AppHost AND auto-open the Aspire dashboard
./ntg ports # show which project ports are in use
./ntg lightrag-dashboard # pick a running agent and open its LightRAG WebUI in the browserAdding your own shortcut is meant to be trivial:
./ntg new <name> # creates scripts/dev-commands/<name>.sh from a template
# edit that file: update the "# desc:" line and add your commands
./ntg <name> # run it — it also shows up in `./ntg` and `./ntg help` automaticallyEach command is a standalone bash file in scripts/dev-commands/; the filename is the
command name and its # desc: header is the menu description. Files starting with _ are
hidden helpers.
NTG Agent supports multiple LLM model providers: GitHub Model, Azure Open AI, Google Gemini
Setup Gemini API: Create your API key in Google AI Studio https://aistudio.google.com/api-keys The Provider Endpoint: https://generativelanguage.googleapis.com/v1beta/
To get started easily, we use the shared cookies approach. In NTG.Agent.Admin, we add YARP as a BFF (Backend for Frontend), which forwards API requests to NTG.Agent.Orchestrator. Currently, it only works for Blazor WebAssembly. Cookies are not included when the request is made from the server (Blazor).
Document knowledge (upload, search, RAG) is served by a pluggable provider behind
IKnowledgeService / IKnowledgeProvisioner (in NTG.Agent.Common). The Orchestrator
selects the provider from configuration, so backends can be swapped without code changes:
{
"Knowledge": {
"Provider": "LightRag"
}
}LightRag(default) — one LightRAG container per agent, implemented in theNTG.Agent.LightRagproject. The Orchestrator only provides two small EF-backed stores (agent port reservations, document ingestion status).
Azure AI Document Intelligence enables file upload in the chat, allowing users to attach documents (PDFs, images, Office files, etc.) and ask questions about their content. This feature is entirely optional — the chat works normally without it.
To set it up, follow the official guide to create an Azure AI Document Intelligence resource: Create a Document Intelligence resource
Once you have the resource endpoint and API key, add the following to your user secrets or appsettings.Development.json in the NTG.Agent.Orchestrator project:
{
"Azure": {
"DocumentIntelligence": {
"IsEnabled": true,
"Endpoint": "https://<your-resource-name>.cognitiveservices.azure.com/",
"ApiKey": "<your-api-key>"
}
}
}IsEnableddefaults tofalse. Set it totrueonly when you have a valid Azure subscription and resource configured.- When
IsEnabledisfalse, the file upload button is hidden in the chat UI and no OCR processing is performed. - The API key is sensitive — use user secrets in development and environment variables or Azure Key Vault in production. Do not commit it to source control.
- Give us a star
- Reporting a bug
- Participate discussions
- Propose new features
- Submit pull requests. If you are new to GitHub, consider to learn how to contribute to a project through forking
By contributing, you agree that your contributions will be licensed under Apache-2.0 license.
