This repository contains the core of the STACKIT RAG template. It consists of the following python packages:
With the exception of the RAG Core lib
all of these packages contain an API definition and are easy to adjust for your specific use case.
Each of the packages defines the replaceable parts(1.3 Replaceable Parts, 2.3 Replaceable Parts, 3.3 Replaceable Parts), expected types and offer a brief description.
ⓘ INFO: If you replace parts it is important to keep the name of the component, otherwise the replacing-logic will not work.
This repository also contains a Dockerfile
that is used to ensure proper linting and testing of the packages.
For an example on how to use the packages, please consult the use case example repository
The rag-core-api contains a default implementation of a RAG. For a default use case, no adjustments should be required.
The following endpoints are provided by the backend:
/chat/{session_id}
: The endpoint for chatting./evaluate
: Will start the evaluation of the RAG using the provided question-answer pairs./information_pieces/remove
: Endpoint to remove documents from the vector database./information_pieces/upload
: Endpoint to upload documents into the vector database. These documents need to have been parsed. For simplicity, a LangChain Documents like format is used.
All required python libraries can be found in the pyproject.toml file. In addition to python libraries, the following system packages are required:
build-essential
make
This endpoint is used for chatting.
Will start the evaluation of the RAG using the provided question-answer pairs.
The file containing the dataset can be set by changing the RAGAS_DATASET_FILENAME
environment variable, the default is test_data.json
.
This path can be either an absolute path, or a path relative to the current working directory.
By default OpenAI
is used by the evaluation. If you want to use the same LLM-class for the evaluation as is used for the chat you have to set the environment variable RAGA_USE_OPENAI
to false
and adjust the RAGAS_MODEL
environment variable to the model-name of your choice.
📝 NOTE: Due to quality problems with open-source LLMs, it is recommended to use OpenAI for the evaluation.
Endpoint to remove documents from the vector database.
Endpoint to upload documents into the vector database. These documents need to have been parsed. For simplicity, a LangChain Documents like format is used. Uploaded documents are required to contain the following metadata:
document_url
that points to a download link to the source document.- All documents of the type
IMAGE
require the content of the image encoded in base64 in thebase64_image
key.
The Admin API Library contains all required components for file management capabilities for RAG systems, handling all document lifecycle operations. It also includes a default dependency_container
, that is pre-configured and should fit most use-cases.
The following endpoints are provided by the admin-api-lib:
/delete_document/{identification}
: Deletes the file from storage (if applicable) and vector database. Theidentification
can be retrieved from the/all_documents_status
endpoint./document_reference/{identification}
: Returns the document./all_documents_status
: Return theidentification
and status of all available sources./upload_documents
: Endpoint to upload files./load_confluence
: Endpoint to load a confluence space
All required python libraries can be found in the pyproject.toml file. In addition to python libraries, the following system packages are required:
build-essential
make
Will delete the document from the connected storage system and will send a request to the backend
to delete all related Documents from the vector database.
Will return the source document stored in the connected storage system.
ⓘ INFO: Confluence pages are not stored in the connected storage system. They are only stored in the vector database and can't be retrieved using this endpoint.
Will return a list of all sources for the chat and their current status.
Files can be uploaded here. This endpoint will process the document in a background and will extract information using the document-extractor. The extracted information will be summarized using a LLM. The summary, as well as the unrefined extracted document, will be uploaded to the rag-core-api.
Loads all the content of a confluence space using the document-extractor. The extracted information will be summarized using LLM. The summary, as well as the unrefined extracted document, will be uploaded to the rag-core-api.
The Extractor Library contains components that provide document parsing capabilities for various file formats. It also includes a default dependency_container
, that is pre-configured and is a good starting point for most use-cases.
This API should not be exposed by ingress and only used for internally.
The following endpoints are provided by the extractor-api-lib:
/extract_from_file
: This endpoint extracts the information from files./extract_from_confluence
: This endpoint extracts the information from a confluence space.
All required python libraries can be found in the pyproject.toml file. In addition to python libraries, the following system packages are required:
build-essential
make
ffmpeg
poppler-utils
tesseract-ocr
tesseract-ocr-deu
tesseract-ocr-eng
This endpoint will extract the information from PDF,PTTX,WORD,XML files. It will load the files from the connected storage. The following types of information will be extracted:
TEXT
: plain textTABLE
: data in tabular form found in the document
The extract from confluence endpoint will extract the information from a confluence space. The following types of information will be extracted:
TEXT
: plain text
The rag-core-lib contains components of the rag-core-api
that are also useful for other services and therefore are packaged in a way that makes it easy to use.
Examples of included components:
- tracing for
LangChain
chains usingLangfuse
- settings for multiple LLMs and Langfuse
- factory for LLMs
ContentType
enum of the Documents.- ...
All required python libraries can be found in the pyproject.toml file. In addition to python libraries the following system packages are required:
build-essential
make