Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mpaepper/content-chatbot
Build a chatbot or Q&A bot of your website's content
https://github.com/mpaepper/content-chatbot
deep-learning llm machine-learning
Last synced: 13 days ago
JSON representation
Build a chatbot or Q&A bot of your website's content
- Host: GitHub
- URL: https://github.com/mpaepper/content-chatbot
- Owner: mpaepper
- Created: 2023-03-21T20:21:50.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-01-28T19:55:24.000Z (10 months ago)
- Last Synced: 2024-10-18T12:57:45.071Z (24 days ago)
- Topics: deep-learning, llm, machine-learning
- Language: Python
- Homepage: https://www.paepper.com/blog/posts/build-q-and-a-bot-of-your-website-using-langchain/
- Size: 294 KB
- Stars: 518
- Watchers: 4
- Forks: 51
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
This repo reached the front page of hacker news on March 22nd 2023, see the discussion here.
## Your website content -> chatbot / Q&A agent
Turn your website content into a question answering bot which can cite your document sources.
Alternatively, use it in an interactive chatbot style fashion.
All this can be achieved with a tool called langchain which in turn uses the OpenAI API.
This simple repository showcases how to apply it on your own website content.
To do so, there are three scripts:
* create_embeddings.py: this is the main script which loops your website's sitemap.xml to create embeddings (vectors representing the semantics of your data) of your content
* ask_question.py: after you have the embeddings (a file called `faiss_store.pkl` was created), this script can be used to directly ask a question. It will answer the question and return the URLs of your website which were used as the source.
* start_chat_app.py: starts a simple chat interface where you can ask a question and then follow-up on the answer. If the bot is uncertain, it will indicate so. Note that you can tune the query in this script to be more relevant for your content. In my case I mentioned it to be specific to machine learning and technical topics.To install the dependencies, simply run `pip install -r requirements.txt`.
### Create your embeddings
This is the most important step and you will need to obtain an OpenAI API key to use it.
Once you have the `$api_key`, you can run `export OPENAI_API_KEY='$api_key'` in your terminal.
Then simply run `python create_embeddings.py --sitemap https://path/to/your/sitemap.xml --filter https://path/to/your/blog/posts`.
This will create your embeddings in a file called `faiss_store.pkl`. You need to point your website's sitemap.xml to the script and you can filter for URL's to start with filter. If you want to include all pages of your site, you can just set `--filter https://`.
For more details about this, please check this blog post.
### Answering a question while getting the answer source documents
With the embeddings set up, ask a question like this: `python ask_question.py "How to detect objects in images?"`
Answer:
Object detection in images can be done using algorithms such as R-CNN, Fast R-CNN, and data augmentation techniques such as shifting, rotations, elastic deformations, and gray value variations.
Sources:
https://www.paepper.com/blog/posts/deep-learning-on-medical-images-with-u-net/
https://www.paepper.com/blog/posts/end-to-end-object-detection-with-transformers/### Starting a chatbot on your content
With the embeddings set up, start a chatbot like this: `python start_chat_app.py`. Then when it's running, ask your questions and follow-ups.
## Zendesk Content Embedding
This repository includes an enhancement to the LangChain chatbot project, introducing the `create_embeddings` for Zendesk feature. This functionality utilizes the Zendesk API to retrieve website content and construct a Faiss knowledge base for improved chatbot responses.
### How it Works
The `create_embeddings` script performs the following steps:
1. **Zendesk API Integration:** Retrieves articles using the Zendesk API.
2. **Text Cleaning:** Parses HTML content, extracting and cleaning text for embedding.
3. **Text Splitting:** Breaks down the content into smaller chunks for efficient embedding processing.
4. **Embedding Creation:** Utilizes OpenAI Embeddings to create embeddings for the text chunks.
5. **Faiss Knowledge Base Construction:** Constructs a Faiss store with the generated embeddings, facilitating efficient similarity search.### Usage
- **Zendesk API Credentials:** To create a Faiss knowledge base from Zendesk content, please obtain and configure your Zendesk API credentials.
### Running the Script
**Execute the Script:** Run the `create_embeddings.py` script to generate the Faiss store.
Example:
```bash
python create_embeddings.py -m zendesk -z "https://your.zendesk.api/" #replace the link