NLWebNet 0.1.0-alpha.3

This is a prerelease version of NLWebNet.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package NLWebNet --version 0.1.0-alpha.3
                    
NuGet\Install-Package NLWebNet -Version 0.1.0-alpha.3
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="NLWebNet" Version="0.1.0-alpha.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="NLWebNet" Version="0.1.0-alpha.3" />
                    
Directory.Packages.props
<PackageReference Include="NLWebNet" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add NLWebNet --version 0.1.0-alpha.3
                    
#r "nuget: NLWebNet, 0.1.0-alpha.3"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package NLWebNet@0.1.0-alpha.3
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=NLWebNet&version=0.1.0-alpha.3&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=NLWebNet&version=0.1.0-alpha.3&prerelease
                    
Install as a Cake Tool

NLWebNet

.NET Build and Test NuGet Version NuGet Downloads License: MIT .NET 9 MSTest

A .NET implementation of the NLWeb protocol for building natural language web interfaces. This project provides both a reusable library and a demo application showcasing the NLWeb standard.

โš ๏ธ PROOF OF CONCEPT - NOT PRODUCTION READY

This is an experimental implementation created for testing and evaluation purposes only. While functional, this library is not intended for production use and should be considered a proof of concept to demonstrate NLWeb protocol capabilities in .NET environments.

Use cases:

  • ๐Ÿงช Protocol evaluation and experimentation
  • ๐Ÿ“š Learning and understanding NLWeb concepts
  • ๐Ÿ”ฌ Research and development prototyping
  • ๐ŸŽฏ Testing integration patterns with AI services

Not recommended for:

  • โŒ Production applications
  • โŒ Critical business systems
  • โŒ Public-facing services
  • โŒ Applications requiring enterprise support

๐Ÿ“‹ Overview

NLWeb is a protocol for creating conversational interfaces to web content and data. It enables natural language querying with three main modes:

  • List: Returns ranked search results
  • Summarize: Provides AI-generated summaries with supporting results
  • Generate: Full RAG (Retrieval-Augmented Generation) responses

This implementation follows the official NLWeb specification and includes Model Context Protocol (MCP) support for enhanced AI integration.

๐Ÿ—๏ธ Repository Structure

NLWebNet/
โ”œโ”€โ”€ src/NLWebNet/              # ๐Ÿ“ฆ Core library (future NuGet package)
โ”‚   โ”œโ”€โ”€ Models/                # Request/response data models
โ”‚   โ”œโ”€โ”€ Services/              # Business logic interfaces and implementations
โ”‚   โ”œโ”€โ”€ Endpoints/             # Minimal API endpoints (/ask, /mcp)
โ”‚   โ”œโ”€โ”€ MCP/                   # Model Context Protocol integration
โ”‚   โ”œโ”€โ”€ Extensions/            # DI and middleware extensions
โ”‚   โ”œโ”€โ”€ Middleware/            # Request processing middleware
โ”‚   โ”œโ”€โ”€ Middleware/            # ASP.NET Core middleware
โ”‚   โ””โ”€โ”€ Extensions/            # Dependency injection extensions
โ”œโ”€โ”€ samples/                   # ๐ŸŽฏ Sample applications and usage examples
โ”‚   โ”œโ”€โ”€ Demo/                  # ๐ŸŽฎ .NET 9 Blazor Web App demo application  
โ”‚   โ””โ”€โ”€ AspireHost/            # ๐Ÿ—๏ธ .NET Aspire orchestration host  
โ”‚   โ”œโ”€โ”€ Components/            # Modern Blazor components
โ”‚   โ”‚   โ”œโ”€โ”€ Layout/            # Layout components (MainLayout, etc.)
โ”‚   โ”‚   โ””โ”€โ”€ Pages/             # Page components (Home, NLWebDemo, Error)
โ”‚   โ”œโ”€โ”€ wwwroot/               # Static assets (app.css, favicon, etc.)
โ”‚   โ””โ”€โ”€ Properties/            # Launch settings and configuration
โ”œโ”€โ”€ doc/                       # ๐Ÿ“š Documentation
โ””โ”€โ”€ tests/                     # ๐Ÿงช Unit and integration tests
    โ””โ”€โ”€ NLWebNet.Tests/        # ๐Ÿ“‹ xUnit test project

๐Ÿ”„ NLWeb Protocol Flow

sequenceDiagram
    participant Client
    participant NLWebNet
    participant DataBackend
    participant LLM as AI Service
    
    Client->>NLWebNet: POST /ask
    Note over Client,NLWebNet: query, mode, site, streaming, etc.
    
    NLWebNet->>NLWebNet: Generate query_id (if not provided)
    NLWebNet->>NLWebNet: Process/decontextualize query
    
    alt mode = "list"
        NLWebNet->>DataBackend: Search query
        DataBackend-->>NLWebNet: Ranked results
    else mode = "summarize"
        NLWebNet->>DataBackend: Search query
        DataBackend-->>NLWebNet: Ranked results
        NLWebNet->>LLM: Generate summary
        LLM-->>NLWebNet: Summary text
    else mode = "generate"
        NLWebNet->>DataBackend: Search query
        DataBackend-->>NLWebNet: Context documents
        NLWebNet->>LLM: Generate RAG response
        LLM-->>NLWebNet: Generated response
    end
    
    NLWebNet-->>Client: JSON response with results
    Note over Client,NLWebNet: query_id, results[], summary?, etc.

๐ŸŽฏ API Endpoints

/ask - Primary NLWeb Endpoint

Natural language query interface supporting all NLWeb protocol features.

Required Parameters:

  • query - Natural language query string

Optional Parameters:

  • site - Target site/domain subset
  • prev - Comma-separated previous queries for context
  • decontextualized_query - Pre-processed query (skips decontextualization)
  • streaming - Enable streaming responses (default: true)
  • query_id - Custom query identifier (auto-generated if not provided)
  • mode - Query mode: list (default), summarize, or generate

/mcp - Model Context Protocol Endpoint

MCP-compatible interface with additional methods:

  • list_tools - Available tools
  • list_prompts - Available prompts
  • call_tool - Execute tools
  • get_prompt - Retrieve prompt templates

๐Ÿ›๏ธ Architecture Overview

graph TB
    subgraph "NLWebNet Library"
        API[Minimal APIs<br>/ask, /mcp]
        MW[Middleware<br>Pipeline]
        EXT[Extensions<br>DI & Config]
        SVC[Business Logic<br>Services]
        MCP[MCP Integration]
        MODELS[Data Models]
    end
      subgraph "Demo Application"
        BLAZOR[.NET 9 Blazor Web App UI]
        DEMO[Modern Blazor Components]
    end
    
    subgraph "External Services"
        AI[AI/LLM Service<br>Azure OpenAI, etc.]
        DATA[Data Backend<br>Search Index, DB, etc.]
    end
    
    CLIENT[HTTP Clients<br>Web, Mobile, etc.] --> API
    BLAZOR --> API
    API --> MW
    MW --> SVC
    SVC --> MCP
    SVC --> AI
    SVC --> DATA
    
    DEMO --> BLAZOR
    
    classDef library fill:#e1f5fe
    classDef demo fill:#f3e5f5
    classDef external fill:#fff3e0
    
    class API,MW,SVC,MCP,MODELS library
    class BLAZOR,DEMO demo
    class AI,DATA external

๐Ÿš€ Quick Start

๐Ÿ“‹ Note: This library is provided for testing and evaluation purposes only. Please review the development status above before integrating into any project.

Using the Library in Your Project

  1. Add the NLWebNet library to your ASP.NET Core project:
// Program.cs
using NLWebNet;

// Add NLWebNet services
builder.Services.AddNLWebNet(options =>
{
    // Configure options
    options.DefaultMode = NLWebNet.Models.QueryMode.List;
    options.EnableStreaming = true;
});

// Later in the pipeline configuration
app.UseNLWebNet();     // Add NLWebNet middleware (optional)
app.MapNLWebNet();     // Map NLWebNet minimal API endpoints

Prerequisites

  • .NET 9.0 SDK
  • Visual Studio 2022 or VS Code

Running the Demo

  1. Clone the repository

    git clone https://github.com/jongalloway/NLWebNet.git
    cd NLWebNet
    
  2. Build the solution

    dotnet build
    
  3. Run the demo application

    cd demo
    dotnet run
    
  4. Open your browser

    • Demo UI: http://localhost:5037
    • OpenAPI Spec: http://localhost:5037/openapi/v1.json
  5. Test the demo features

    • Home Page: Overview and navigation to demo features
    • Interactive Demo (/nlweb): UI for testing NLWeb queries
      • Query input with natural language questions
      • Mode selection (List, Summarize, Generate)
      • Streaming toggle option
      • Note: Core NLWeb functionality is under development - currently shows placeholder responses
    • API Documentation: OpenAPI specification for /ask and /mcp endpoints
      • Note: API endpoints are planned but not yet implemented

Using the Library

โš ๏ธ For testing and evaluation only - not recommended for production use

Install the NuGet package:

dotnet add package NLWebNet

Or via Package Manager Console:

Install-Package NLWebNet

Configure in your ASP.NET Core application:

// Program.cs
using NLWebNet;

builder.Services.AddNLWebNet(options =>
{
    options.DefaultMode = QueryMode.List;
    options.EnableStreaming = true;
});

app.MapNLWebNet();

Testing NLWeb Features

The demo application at http://localhost:5037 provides comprehensive testing of all NLWeb protocol features:

Interactive Demo Pages:

  • Home Page (/): Project overview and navigation to demo features
  • NLWeb Demo (/nlweb): Advanced query interface with tabbed sections:
    • Query Tab: Interactive form with all NLWeb parameters (query, mode, site, etc.)
    • Streaming Tab: Real-time streaming response demonstration
    • API Test Tab: Raw HTTP request/response testing
  • API Test (/api-test): Comprehensive API testing interface with request configuration
  • MCP Demo (/mcp-demo): Model Context Protocol demonstration with tools and prompts

Query Modes Supported:

  • List Mode: Returns ranked search results with relevance scoring
  • Summarize Mode: AI-generated summaries with supporting results
  • Generate Mode: Full RAG responses with context-aware answers
  • Streaming: Real-time response delivery with Server-Sent Events

API Testing:

  • Direct HTTP calls to /ask endpoint with various parameters
  • MCP protocol testing via /mcp endpoint with tool and prompt support
  • OpenAPI specification available at /openapi/v1.json
  • Comprehensive manual testing guides in /doc/manual-testing-guide.md

Example API Usage:

# List mode query
curl -X GET "http://localhost:5037/ask?query=find+recent+updates&mode=list"

# POST request with full parameters
curl -X POST "http://localhost:5037/ask" \
  -H "Content-Type: application/json" \
  -d '{"query": "find recent updates", "mode": "list", "site": "docs", "streaming": false}'

# Streaming summarize query  
curl -X POST "http://localhost:5037/ask" \
  -H "Content-Type: application/json" \
  -d '{"query": "what are the main features?", "mode": "summarize", "streaming": true}'

# MCP tool listing
curl -X POST "http://localhost:5037/mcp" \
  -H "Content-Type: application/json" \
  -d '{"method": "list_tools"}'

โš™๏ธ Configuration

NLWebNet uses standard ASP.NET Core configuration patterns for managing settings and external service credentials.

Non-Secret Configuration (appsettings.json)

Configure basic NLWebNet settings in your appsettings.json:

{
  "NLWebNet": {
    "DefaultMode": "List",
    "EnableStreaming": true,
    "DefaultTimeoutSeconds": 30,
    "MaxResultsPerQuery": 50
  },
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "NLWebNet": "Debug"
    }
  }
}

Secret Configuration (User Secrets)

For sensitive data like API keys, use ASP.NET Core User Secrets in development:

  1. Initialize user secrets for your project:

    dotnet user-secrets init
    
  2. Set AI service credentials (example for Azure OpenAI):

    dotnet user-secrets set "AzureOpenAI:ApiKey" "your-api-key-here"
    dotnet user-secrets set "AzureOpenAI:Endpoint" "https://your-resource.openai.azure.com/"
    dotnet user-secrets set "AzureOpenAI:DeploymentName" "gpt-4"
    
  3. Set data backend credentials (example for Azure Search):

    dotnet user-secrets set "AzureSearch:ApiKey" "your-search-api-key"
    dotnet user-secrets set "AzureSearch:ServiceName" "your-search-service"
    dotnet user-secrets set "AzureSearch:IndexName" "your-index-name"
    

Production Configuration

For production deployments, use:

  • Azure Key Vault - For secrets in Azure environments
  • Environment Variables - For containerized deployments
  • Configuration Providers - Custom providers for other cloud platforms

Example environment variables for production:

NLWebNet__DefaultMode=List
NLWebNet__EnableStreaming=true
AzureOpenAI__ApiKey=your-production-api-key
AzureSearch__ApiKey=your-production-search-key

Configuration in Code

Access configuration in your application:

// Program.cs
using NLWebNet;

builder.Services.AddNLWebNet(options =>
{
    // Bind from configuration
    builder.Configuration.GetSection("NLWebNet").Bind(options);
});

// Configure AI services
builder.Services.Configure<AzureOpenAIOptions>(
    builder.Configuration.GetSection("AzureOpenAI"));

// Configure data backend
builder.Services.Configure<AzureSearchOptions>(
    builder.Configuration.GetSection("AzureSearch"));

๐Ÿš€ Deployment

NLWebNet supports multiple deployment options for different environments:

๐Ÿณ Docker Deployment

# Quick start with Docker Compose
git clone https://github.com/jongalloway/NLWebNet.git
cd NLWebNet
docker-compose up --build

โ˜๏ธ Azure Cloud Deployment

# Deploy to Azure Container Apps
./scripts/deploy/deploy-azure.sh -g myResourceGroup -t container-apps

# Deploy to Azure App Service
./scripts/deploy/deploy-azure.sh -g myResourceGroup -t app-service

โš™๏ธ Kubernetes Deployment

# Deploy to any Kubernetes cluster
kubectl apply -f k8s/

๐Ÿ“ฆ Container Registry

Pre-built images available soon. For now, build locally:

./scripts/deploy/build-docker.sh -t latest

๐Ÿ“– Complete Deployment Guide - Comprehensive instructions for all deployment scenarios.

๐Ÿ› ๏ธ Development Status

This is a proof of concept implementation of the NLWeb protocol, available as an alpha prerelease package for testing and evaluation purposes only.

โš ๏ธ EXPERIMENTAL SOFTWARE - NOT PRODUCTION READY

โœ… Completed (Phases 1-11) - For Testing & Evaluation:

  • Core Library: Complete NLWeb protocol implementation with Minimal API endpoints
  • Data Models: Request/response models with validation and JSON serialization
  • Business Logic: Service layer with Microsoft.Extensions.AI integration
  • NuGet Package: Published as alpha prerelease at nuget.org/packages/NLWebNet
  • CI/CD Pipeline: Automated build, test, validation, and publishing to NuGet.org
  • Documentation: Comprehensive README, API documentation, and usage examples

๐ŸŽฏ Intended Use Cases:

  • Protocol evaluation and experimentation
  • Learning NLWeb concepts and implementation patterns
  • Research and development prototyping
  • Testing integration with AI services and data backends

โŒ Not Suitable For:

  • Production applications or critical business systems
  • Public-facing services or enterprise applications
  • Applications requiring commercial support or SLAs
  • MCP Integration: Full Model Context Protocol support with tools and prompts
  • Demo Application: Modern .NET 9 Blazor Web App with interactive components
  • Testing: 39 unit tests with 100% pass rate plus comprehensive manual testing guides
  • Configuration: CORS, AI services, and multi-environment support
  • Documentation: XML documentation, README, and API usage examples
  • CI/CD: GitHub Actions workflow for build, test, and validation
  • NuGet Package: Fully functional package with working extension methods (0.1.0-alpha.3)
  • API Exposure: Extension methods accessible via using NLWebNet; (Microsoft pattern)
  • End-to-End Validation: Complete package installation and functionality testing
  • Package Metadata: Enhanced NuGet metadata with title, copyright, repository type for professional presentation

๐Ÿ“‹ Next Steps (Phase 11):

  • Enhanced package metadata and improved Package Manager display
  • Health check integration
  • Performance monitoring hooks
  • Rate limiting support
  • Docker containerization
  • Azure deployment templates

๐Ÿค Contributing

This project follows the NLWeb specification. Contributions are welcome!

  1. Review the implementation plan
  2. Check open issues
  3. Submit pull requests with tests

๐Ÿ“„ License

This project is licensed under the MIT License.

๐Ÿท๏ธ Version

Current version: 0.1.0-alpha.3 (Prerelease - enhanced metadata and improved Package Manager display)

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.0-alpha.5 130 6/24/2025
0.1.0-alpha.4 87 6/21/2025
0.1.0-alpha.3 46 6/21/2025
0.1.0-alpha.2 64 6/20/2025
0.1.0-alpha.1 58 6/20/2025

Alpha release 0.1.0-alpha.3: Enhanced NuGet package metadata with copyright notice, repository type, and improved package title for better Package Manager display. Complete NLWeb protocol implementation with Minimal API endpoints (/ask, /mcp), Model Context Protocol integration, streaming support, and comprehensive testing. This is a proof-of-concept prerelease for testing and evaluation purposes only - not recommended for production use.