Skip to main content

kb-bot.core

The core library of kb-bot. This handles indexing of content, and chatting with the bot.

Getting Started

pip install kb-bot.core

Preparing the KB

import os
from kb_bot import KBBot
from kb_bot.scraper import WebScraper
from kb_bot.db import TiDBProvider
from kb_bot.chunkers import SemanticChunker
from kb_bot.embedding import OpenAIEmbedClient
from kb_bot.llm import OpenAI

# Configure env variables TIDB_DATABASE, TIDB_USERNAME, TIDB_PASSWORD, TIDB_HOST, TIDB_PORT
tidb = TiDBProvider()
tidb.connect()

embed_client = OpenAIEmbedClient(
    api_key=os.environ.get('OPENAI_API_KEY')
)

scraper = WebScraper(
    urls=["https://www.pingcap.com/blog/"],
    follow_links=True,
    restrict_navigation_css=".tmpl-archive.tmpl-archive-blog",
    restrict_css=".tmpl-single-post__content",
    ignore_css=".tmpl-archive-sidebar",
    chunker=SemanticChunker(
        embedding_client=embed_client
    ),
    db_provider=tidb,
    group="<user user id or project id according to your need>",
    embedding_client=embed_client
)

scraper.crawl()

Chat with the bot

bot = KBBot(
    db_provider=tidb,
    embedding_client=embed_client,
    group="new-user-id",
    llm_client=OpenAI(
        api_key=os.environ.get('OPENAI_API_KEY')
    ),
    history=[],
    tasks_prompt="<Additional instructions to bot>"
)

response = bot.chat(message="what are the benefits of vector search ?")
print(response)

TODO

  • Add support for multiple llm(s)
  • Implement Agentic Chunker
  • Add test cases

Metadata

Release files for kb-bot.core 0.1.21

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

Source distribution (sdist)

Source distribution for kb-bot.core 0.1.21
File Size Uploaded Provenance Actions
kb_bot_core-0.1.21.tar.gz 10.4 kB Without provenance Details for kb_bot_core-0.1.21.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for kb-bot.core 0.1.21
File Interpreter ABI Platform Actions
kb_bot.core-0.1.21-py3-none-any.whl Python 3 none any Details for kb_bot.core-0.1.21-py3-none-any.whl

Total release size: 21.0 kB

Release files / kb_bot_core-0.1.21.tar.gz

Download URL kb_bot_core-0.1.21.tar.gz
Size 10.4 kB
Tags Source
SHA-256 checksum
How to use checksums
a95bef72955bd80dae80644ea299403fd1e1831de5d5574061f48c1956e58718
BLAKE2b-256 checksum
How to use checksums
3db21080c8dd98bd693b43c5fd4a47df37bedda825f9b6a04e3038040b42a08b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.5

Release files / kb_bot.core-0.1.21-py3-none-any.whl

Download URL kb_bot.core-0.1.21-py3-none-any.whl
Size 10.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b104bd82d9c15bf4ded478d2a49582a4d39dfc4f0080893aa7614b466962c17e
BLAKE2b-256 checksum
How to use checksums
1151571150be8b12b59bfa2bfd10e178b886ee3e065c3507be86f30b38142caa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.5

Security for kb-bot.core 0.1.21

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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