Skip to content

nashtech-garage/ntg-agent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

155 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NTG Agent

This project aims to practice building a chatbot in C#

Build Quality Gate Status SonarCloud Coverage Security Rating Vulnerabilities

High level architecture

NTG Agent - High level architecture

Technologies and frameworks

  • .NET 10
  • .NET Aspire
  • Blazor
  • Microsoft Agent Framework
  • LightRAG
  • Support multiple LLMs: GitHub Models, Open AI, Azure Open AI etc.
  • SQL Server

Documentation

Details about the project can be referenced at DeepWiki: https://deepwiki.com/nashtech-garage/ntg-agent

Getting started

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
  1. Create a GitHub fine-grained personal access token with models:read permission.

  2. 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-run to preview without writing, --help for 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>"
  3. 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
  4. Open the Aspire Dashboard URL printed at startup. Resources you'll see:

    • sqlserver — SQL Server 2022 container with a persistent volume
    • db-migrate-admin, db-migrate-orchestrator — one-shot EF migrations (finished)
    • ntg-agent-mcp-server, ntg-agent-orchestrator — backend services
    • ntg-agent-webclient — end-user chat UI (default admin account: admin@ntgagent.com / Ntg@123)
    • ntg-agent-admin — admin dashboard
  5. 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)

Dev shortcuts (ntg)

./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 browser

Adding 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` automatically

Each 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.

Using other LLM models

NTG Agent supports multiple LLM model providers: GitHub Model, Azure Open AI, Google Gemini

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/

How authentication work

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).

Knowledge providers

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 the NTG.Agent.LightRag project. The Orchestrator only provides two small EF-backed stores (agent port reservations, document ingestion status).

Azure AI Document Intelligence Configuration (Optional)

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>"
    }
  }
}
  • IsEnabled defaults to false. Set it to true only when you have a valid Azure subscription and resource configured.
  • When IsEnabled is false, 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.

Contributing

By contributing, you agree that your contributions will be licensed under Apache-2.0 license.

About

A sample Chatbot in C# using Microsoft Agent Framework

Topics

Resources

License

Stars

96 stars

Watchers

1 watching

Forks

Releases

No releases published

Contributors