Skip to main content

chatbot

Wrapper around LangChain functions, specifying:

  • A two-step chunk lookup process: title search followed by content search

  • Use of HuggingFace to obtain a local embeddings model

  • Use of NVIDIA or Bedrock for a remote LLM (Llama/Claude)

  • Use of Qdrant (server, memory or disk) as a vector store

  • A LangGraph as follows:

And adding:

  • Support for a meta-graph of document relationships to aid retrieval

  • Support for keywords in addition to titles for chunk lookup

Getting started

Configuration

Within a .env.development file (.env for production), specify values for the following, according to the stated constraints:

Variable Description Required Default
MAX_RETRIES Number of times to retry the chat API if it is not responsive Yes 3
QDRANT_PATH On-disk or remote location to persist vector store collections No -
EMBEDDINGS_MODEL_NAME Model used to vectorise documents in the vector store Yes sentence-transformers/all-mpnet-base-v2
LLM_MODEL_NAME Name of the model. Models starting with <provider>. are assumed to be hosted on Bedrock (AWS). Others are assumed to be hosted by NVIDIA. Yes eu.anthropic.claude-haiku-4-5-20251001-v1:0 (AWS Bedrock)
NVIDIA_API_KEY Key for NVIDIA-hosted models Yes (if using an NVIDIA model) -
AWS_BEARER_TOKEN_BEDROCK Key for Bedrock-hosted models Yes (if using a Bedrock model) -
AWS_REGION Region for Bedrock-hosted models Yes (if using a Bedrock model) eu-west-2
LLM__EXPLANATION_OF_TERMS Optional explanatory text to help the LLM interpret retrieved information (e.g., term definitions, context notes). Injected into the system prompt for retrieval tasks. No -
Model Provider ID
Llama 3.1 8B instruct (default) NVIDIA meta/llama-3.1-8b-instruct
Claude 4.5 Haiku AWS Bedrock eu.anthropic.claude-haiku-4-5-20251001-v1:0

Local installation

Add the following to the pyproject.toml of a consuming project in the monorepo:

[tool.uv.sources]
chatbot = { path = "../path/to/lib", editable = true }
[dependency-groups]
dev = [
    "chatbot",
    ...
]

Usage

from chatbot.knowledge_based import KnowledgeBase
from chatbot.chatbot import Chatbot
KnowledgeBase().load_web_documents(documents, classes)
Chatbot().retrieve_and_generate(message)

Testing

  1. Install dependencies

    uv sync
    
  2. Run tests: uv run pytest tests

License

This project uses the CC BY-NC-ND 4.0 license (see LICENSE).

Metadata

Release files for londonaicentre-chatbot 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for londonaicentre-chatbot 1.0.1
File Size Uploaded
londonaicentre_chatbot-1.0.1.tar.gz 30.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for londonaicentre-chatbot 1.0.1
File Interpreter ABI Platform
londonaicentre_chatbot-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 52.0 kB

Release files / londonaicentre_chatbot-1.0.1.tar.gz

Download URL londonaicentre_chatbot-1.0.1.tar.gz
Size 30.4 kB
Tags Source
SHA-256 checksum
How to use checksums
6b5df479c7be11b8bb8ace24c74da4707d7ce642d222401038d9d375e518d6a7
BLAKE2b-256 checksum
How to use checksums
a6808c5704165922ebc4ef2fc3b8089cf2506049643d99cfc2805f6de81917e9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Amazon Linux","version":"2023","id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / londonaicentre_chatbot-1.0.1-py3-none-any.whl

Download URL londonaicentre_chatbot-1.0.1-py3-none-any.whl
Size 21.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b09424d5de87ce5ebe2b1b48d376d64d81629af9470cdbebaf07b7d79452e3f2
BLAKE2b-256 checksum
How to use checksums
a9daeffd4388ba4ed6aa8a9f7dd598f7907f4b30b9fbb2b29065e6dcfd5f6f6b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Amazon Linux","version":"2023","id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page