Wrapper around LangChain functions
Project description
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 | - |
Recommended models
| 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
-
Install dependencies
uv sync -
Run tests:
uv run pytest tests
License
This project uses the CC BY-NC-ND 4.0 license (see LICENSE).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file londonaicentre_chatbot-1.0.1.tar.gz.
File metadata
- Download URL: londonaicentre_chatbot-1.0.1.tar.gz
- Upload date:
- Size: 30.4 kB
- Tags: Source
- Uploaded using 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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6b5df479c7be11b8bb8ace24c74da4707d7ce642d222401038d9d375e518d6a7
|
|
| MD5 |
96b5312529378b66457c00c2a290e5f3
|
|
| BLAKE2b-256 |
a6808c5704165922ebc4ef2fc3b8089cf2506049643d99cfc2805f6de81917e9
|
File details
Details for the file londonaicentre_chatbot-1.0.1-py3-none-any.whl.
File metadata
- Download URL: londonaicentre_chatbot-1.0.1-py3-none-any.whl
- Upload date:
- Size: 21.6 kB
- Tags: Python 3
- Uploaded using 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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b09424d5de87ce5ebe2b1b48d376d64d81629af9470cdbebaf07b7d79452e3f2
|
|
| MD5 |
b2227aaaa3d476dbf261802b9988ff44
|
|
| BLAKE2b-256 |
a9daeffd4388ba4ed6aa8a9f7dd598f7907f4b30b9fbb2b29065e6dcfd5f6f6b
|