Code Monkey home page Code Monkey logo

website-to-knowledge-base's Introduction

AI-Powered Knowledge Base

Turn.any.website.into.an.llm-powered.knowledge.base.mp4

YouTube Demo

This repository contains an AI-powered knowledge base that utilizes the LLMs model to answer questions based on a given website's content and provide sources as links to the relevant pages.

The system:

  1. Loads the website's content using a sitemap
  2. Split each web page into chunks
  3. Embed each chunk using a LLM (for now OpenAI) and store them in the **Chroma vector database
  4. Then it embeds the user query and run a similarity search using the Chroma database
  5. Finally it loads the similarity search results as context for a LLM (for now ChatGPT) to find relevant answers and citing the sources

It also provides a Streamlit-based web interface for an easy-to-use experience.

Files

  • knowledge_base.py: The main module that creates the KnowledgeBase class. This class is responsible for loading and processing the website content, creating the document index, and querying the LLM model for answers.
  • app.py: A Streamlit web application that provides a user interface for querying the AI-powered knowledge base.

Installation

  1. Clone the repository:
git clone [email protected]:bitswired/website-to-knowledge-base.git
  1. Instal the project with poetry:
poetry install

Usage

Knowledge Base

To use the KnowledgeBase class, follow these steps:

  1. Import the KnowledgeBase class:
from knowledge_base import KnowledgeBase
  1. Instantiate the KnowledgeBase with the appropriate sitemap URL and pattern (optional):
kb = KnowledgeBase(
    sitemap_url="https://nextjs.org/sitemap.xml",
    pattern="docs/api-refe",
    chunk_size=8000,
    chunk_overlap=3000,
)
  1. Ask a question:
result = kb.ask("How do I deploy my Next.js app?")
print(result)

Web Application

To run the Streamlit web application, execute the following command in your terminal:

streamlit run app.py

The web app will open in your default browser. Enter the URL to the website's sitemap, an optional filter pattern for the URLs, and your question. The AI-powered knowledge base will return an answer based on the content of the website.

Requirements

License

This project is licensed under the MIT License.

website-to-knowledge-base's People

Contributors

jimzer avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.