Skip to main content

Core framework for NLWeb - Natural Language Web interface with config-driven provider architecture

Project description

nlweb-core

Core framework for NLWeb - Natural Language Web interface with config-driven provider architecture.

Overview

nlweb-core provides the foundational framework for building natural language interfaces to web services. It implements:

  • Config-driven provider architecture for LLMs, embeddings, and vector databases
  • Dynamic module loading based on configuration
  • Unified interfaces for retrieval, ranking, and LLM operations
  • HTTP server with Server-Sent Events (SSE) streaming support
  • NLWeb Protocol v0.5 implementation

Installation

pip install nlweb-core

Note: You also need to install provider packages. See examples below.

Provider Packages

nlweb-core uses a plugin architecture. Install provider packages separately:

Bundle Packages (recommended for getting started)

# All retrieval providers
pip install nlweb-retrieval

# All LLM and embedding providers
pip install nlweb-models

Individual Provider Packages (coming soon)

# Azure-specific providers
pip install nlweb-azure-vectordb nlweb-azure-models

Quick Start

1. Create a configuration file

Create config.yaml:

# LLM Configuration
llm:
  provider: openai
  import_path: nlweb_models.llm.openai_client
  class_name: OpenAIClient
  api_key_env: OPENAI_API_KEY
  models:
    high: gpt-4
    low: gpt-3.5-turbo

# Embedding Configuration
embedding:
  provider: openai
  import_path: nlweb_models.embedding.openai_embedding
  class_name: get_openai_embeddings
  api_key_env: OPENAI_API_KEY
  model: text-embedding-3-small

# Retrieval Configuration
retrieval:
  provider: elasticsearch
  import_path: nlweb_retrieval.elasticsearch_client
  class_name: ElasticsearchClient
  api_endpoint_env: ELASTICSEARCH_URL
  index_name: my_index

2. Set environment variables

export OPENAI_API_KEY=your_key_here
export ELASTICSEARCH_URL=http://localhost:9200

3. Use in your application

import nlweb_core

# Initialize with your config
nlweb_core.init(config_path="./config.yaml")

# Use the framework
from nlweb_core.simple_server import run_server
run_server()

Configuration

The config file supports three main sections:

LLM Configuration

  • provider: Provider name (used for identification)
  • import_path: Python module path to provider
  • class_name: Class or function name to import
  • api_key_env: Environment variable containing API key
  • models: Model IDs for high/low tiers

Embedding Configuration

  • provider: Provider name
  • import_path: Python module path
  • class_name: Class or function name
  • model: Embedding model ID

Retrieval Configuration

  • provider: Provider name
  • import_path: Python module path
  • class_name: Client class name
  • api_endpoint_env: Environment variable for endpoint URL
  • index_name: Index/collection name

Architecture

nlweb-core provides orchestration layers:

  • retriever.py: Vector database operations
  • llm.py: LLM provider dispatch
  • embedding.py: Embedding generation
  • ranking.py: LLM-based result ranking
  • simple_server.py: HTTP server with SSE streaming

All provider-specific code lives in separate packages.

License

MIT License - Copyright (c) 2025 Microsoft Corporation

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nlweb_core-0.6.3.tar.gz (88.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nlweb_core-0.6.3-py3-none-any.whl (98.0 kB view details)

Uploaded Python 3

File details

Details for the file nlweb_core-0.6.3.tar.gz.

File metadata

  • Download URL: nlweb_core-0.6.3.tar.gz
  • Upload date:
  • Size: 88.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for nlweb_core-0.6.3.tar.gz
Algorithm Hash digest
SHA256 21a6b4f526f6c32fda56fd1df443d3261b81b28ed27a793ce11759a8cdb3b51d
MD5 d7e9236ad1333c1dad8c8e32b9037664
BLAKE2b-256 787e345c8075779bf9f74167dce15f29a837e6c85d2cabc1f46a1fdb13c202de

See more details on using hashes here.

File details

Details for the file nlweb_core-0.6.3-py3-none-any.whl.

File metadata

  • Download URL: nlweb_core-0.6.3-py3-none-any.whl
  • Upload date:
  • Size: 98.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for nlweb_core-0.6.3-py3-none-any.whl
Algorithm Hash digest
SHA256 6f3b6fd707c72a96a82ee5c099b24c38d5ca14267447bc13a05250260da15e20
MD5 7a05c589c9bf4d4742b9d55046b452bf
BLAKE2b-256 d8130f52a40d6dce3a7071a22a79f1f5633eb27c8aa6e6a1b0d6ce34f77e20e7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page