diff --git a/libs/admin-api-lib/README.md b/libs/admin-api-lib/README.md new file mode 100644 index 00000000..3c114ae6 --- /dev/null +++ b/libs/admin-api-lib/README.md @@ -0,0 +1,96 @@ +# admin-api-lib + +Document lifecycle orchestration for the STACKIT RAG template. This library exposes a FastAPI-compatible admin surface that receives raw user content, coordinates extraction, summarisation, chunking, and storage, and finally hands normalized information pieces to the core RAG API. + +It powers the [`services/admin-backend`](https://github.com/stackitcloud/rag-template/tree/main/services/admin-backend) deployment and is the primary integration point for operators managing their document corpus. + +## Responsibilities + +1. **Ingestion** – Accept files or external sources from the admin UI or API clients. +2. **Extraction** – Call `extractor-api-lib` to obtain normalized information pieces. +3. **Enhancement** – Summarize and enrich content using LLMs and tracing hooks from `rag-core-lib`. +4. **Chunking** – Split content via recursive or semantic strategies before vectorization. +5. **Persistence** – Store raw assets in S3-compatible storage and push processed chunks to `rag-core-api`. +6. **Status tracking** – Keep track of upload progress and expose document status endpoints backed by KeyDB/Redis. + +## Feature highlights + +- Ready-to-wire dependency-injector container with sensible defaults for S3 storage, KeyDB status tracking, and background tasks. +- Pluggable chunkers (`recursive` vs `semantic`) and summariser implementations with shared retry/backoff controls. +- Rich Pydantic request/response models covering uploads, non-file sources, and document status queries. +- Thin endpoint implementations that can be swapped or extended while keeping the public API stable. +- Structured tracing (Langfuse) and logging that mirror the behaviour of the chat backend. + +## Installation + +```bash +pip install admin-api-lib +``` + +Requires Python 3.13 and `rag-core-lib`. + +## Module tour + +- `dependency_container.py` – Configures and wires dependency-injection providers. Override registrations here to customise behaviour. +- `api_endpoints/` & `impl/api_endpoints/` – Endpoints + abstractions for file uploads, source uploads, deletions, document status, and reference retrieval. +- `apis/` – Admin API abstractions and implementations. +- `chunker/` & `impl/chunker/` – Abstractions + default text/semantic chunkers and chunker type selection class. +- `extractor_api_client/` & `rag_backend_client/` – Generated OpenAPI clients to talk to the extractor and rag core API services. +- `file_services/` & `impl/file_services/` – Abstract and default S3 interface. +- `summarizer/` & `impl/summarizer/` – Interfaces and LangChain-based summariser that leverage shared retry logic. +- `information_enhancer/` & `impl/information_enhancer/` – Abstractions + page and summary enhancer. Enhancers are centralized with general enhancer. +- `impl/key_db/` – KeyDB/Redis client implementation for document status tracking. +- `impl/mapper/` – Mapper between extractor documents and langchain documents. +- `impl/settings/` – Configuration settings for dependency injection container components. +- `prompt_templates/` – Default summarisation prompt shipped with the template. +- `utils/` – Utility functions and classes. + +## Endpoints provided + +- `POST /upload_file` – Uploads user selected files +- `POST /upload_source` - Uploads user selected sources +- `DELETE /documents/{identification}` – Deletes a document from the system. +- `GET /document_reference/{identification}` – Retrieves a document reference. +- `GET /all_documents_status` – Retrieves the status of all documents. + +Refer to [`libs/README.md`](../README.md#2-admin-api-lib) for in-depth API documentation. + +## Configuration overview + +All settings are powered by `pydantic-settings`, so you can use environment variables or instantiate classes manually: + +- `S3_*` (`S3_ACCESS_KEY_ID`, `S3_SECRET_ACCESS_KEY`, `S3_ENDPOINT`, `S3_BUCKET`) – configure storage for raw uploads. +- `DOCUMENT_EXTRACTOR_HOST` – base URL of the extractor service. +- `RAG_API_HOST` – base URL of the rag-core API. +- `CHUNKER_CLASS_TYPE_CHUNKER_TYPE` – choose `recursive` (default) or `semantic` chunking. +- `CHUNKER_*` (`CHUNKER_MAX_SIZE`, `CHUNKER_OVERLAP`, `CHUNKER_BREAKPOINT_THRESHOLD_TYPE`, …) – fine-tune chunking behaviour. +- `SUMMARIZER_MAXIMUM_INPUT_SIZE`, `SUMMARIZER_MAXIMUM_CONCURRENCY`, `SUMMARIZER_MAX_RETRIES`, etc. – tune summariser limits and retry behaviour. +- `SOURCE_UPLOADER_TIMEOUT` – adjust how long non-file source ingestions wait before timing out. +- `USECASE_KEYVALUE_HOST` / `USECASE_KEYVALUE_PORT` – configure the KeyDB/Redis instance that persists document status. + +The Helm chart forwards these values through `adminBackend.envs.*`, keeping deployments declarative. Local development can rely on `.env` as described in the repository root README. + +## Typical usage + +```python +from admin_api_lib.main import app as perfect_admin_app +``` + +The admin frontend (`services/frontend` → Admin app) and automation scripts talk to these endpoints to manage the corpus. Downstream, `rag-core-api` receives the processed information pieces and stores them in the vector database. + +## Extending the library + +1. Implement a new interface (e.g., `Chunker`, `Summarizer`, `FileService`). +2. Register it in `dependency_container.py` or override via dependency-injector in your service. +3. Update or add API endpoints if you expose new capabilities. +4. Cover the new behaviour with pytest-based unit tests under `libs/admin-api-lib/tests`. + +Because components depend on interfaces defined here, downstream services can swap behavior without modifying the public API surface. + +## Contributing + +Ensure new endpoints or adapters remain thin and defer to [`rag-core-lib`](../rag-core-lib/) for shared logic. Run `poetry run pytest` and the configured linters before opening a PR. For further instructions see the [Contributing Guide](https://github.com/stackitcloud/rag-template/blob/main/CONTRIBUTING.md). + +## License + +Licensed under the project license. See the root [`LICENSE`](https://github.com/stackitcloud/rag-template/blob/main/LICENSE) file. diff --git a/libs/admin-api-lib/poetry.lock b/libs/admin-api-lib/poetry.lock index 61caab33..2cefc8b5 100644 --- a/libs/admin-api-lib/poetry.lock +++ b/libs/admin-api-lib/poetry.lock @@ -3190,8 +3190,8 @@ files = [ [[package]] name = "rag-core-lib" -version = "1.0.1" -description = "The perfect rag template" +version = "v3.2.1" +description = "The rag-core-lib contains the shared components of at least two of the rag libs." optional = false python-versions = "^3.13" groups = ["main"] diff --git a/libs/admin-api-lib/pyproject.toml b/libs/admin-api-lib/pyproject.toml index 70698040..e85f8950 100644 --- a/libs/admin-api-lib/pyproject.toml +++ b/libs/admin-api-lib/pyproject.toml @@ -4,10 +4,19 @@ build-backend = "poetry.core.masonry.api" [tool.poetry] name = "admin-api-lib" -version = "1.0.1" +version = "v3.2.1" description = "The admin backend is responsible for the document management. This includes deletion, upload and returning the source document." -authors = ["STACKIT Data and AI Consulting "] +authors = [ + "STACKIT GmbH & Co. KG ", +] +maintainers = [ + "Andreas Klos ", +] packages = [{ include = "admin_api_lib", from = "src" }] +readme = "README.md" +license = "Apache-2.0" +repository = "https://github.com/stackitcloud/rag-template" +homepage = "https://pypi.org/project/admin-api-lib" [tool.flake8] exclude= [".eggs", "./libs/*", "./src/admin_api_lib/models/*", "./src/admin_api_lib/rag_backend_client/*", "./src/admin_api_lib/extractor_api_client/*", ".git", ".hg", ".mypy_cache", ".tox", ".venv", ".devcontainer", "venv", "_build", "buck-out", "build", "dist", "**/__init__.py"] diff --git a/libs/extractor-api-lib/README.md b/libs/extractor-api-lib/README.md new file mode 100644 index 00000000..5bec73c2 --- /dev/null +++ b/libs/extractor-api-lib/README.md @@ -0,0 +1,94 @@ +# extractor-api-lib + +Content ingestion layer for the STACKIT RAG template. This library exposes a FastAPI extraction service that ingests raw documents (files or remote sources), extracts and converts (to internal representations) the information, and hands output to [`admin-api-lib`](../admin-api-lib/). + +## Responsibilities + +- Receive binary uploads and remote source descriptors from the admin backend. +- Route each request through the appropriate extractor (file, sitemap, Confluence, etc.). +- Convert extracted fragments into the shared `InformationPiece` schema expected by downstream services. + +## Feature highlights + +- **Broad format coverage** – PDFs, DOCX, PPTX, XML/EPUB, Confluence spaces, and sitemap-driven websites. +- **Consistent output schema** – Information pieces are returned in a unified structure with content type (`TEXT`, `TABLE`, `IMAGE`) and metadata. +- **Swappable extractors** – Dependency-injector container makes it easy to add or replace file/source extractors, table converters, etc. +- **Production-grade plumbing** – Built-in S3-compatible file service, LangChain loaders with retry/backoff, optional PDF OCR, and throttling controls for web crawls. + +## Installation + +```bash +pip install extractor-api-lib +``` + +Python 3.13 is required. OCR and computer-vision features expect system packages such as `ffmpeg`, `poppler-utils`, and `tesseract` (see `services/document-extractor/README.md` for the full list). + +## Module tour + +- `dependency_container.py` – Central dependency-injector wiring. Override providers here to plug in custom extractors, endpoints etc. +- `api_endpoints/` & `impl/api_endpoints/` – Thin FastAPI endpoint abstractions and implementations for file and source (like confluence & sitemaps) extractors. +- `apis/` – Extractor API abstractions and implementations. +- `extractors/` & `impl/extractors/` – Format-specific logic (PDF, DOCX, PPTX, XML, EPUB, Confluence, sitemap) packaged behind the `InformationExtractor`/`InformationFileExtractor` interfaces. +- `mapper/` & `impl/mapper/` – Abstractions and implementations to map langchain documents, internal and external information piece representations to each other. +- `file_services/` – Default S3-compatible storage adapter; replace it if you store files elsewhere. +- `impl/settings/` – Configuration settings for dependency injection container components. +- `table_converter/` & `impl/table_converter/` – Abstractions and implementations to convert `pandas.DataFrame` to markdown and vice versa. +- `impl/types/` - Enums for content-, extractor- and file types. +- `impl/utils/` – Helper functions for hashed datetime and sitemap crawling, header injection, and custom metadata parsing. + +## Endpoints provided + +- `POST /extract_from_file` – Downloads the file from S3, extracts its contents, and returns normalized `InformationPiece` records. +- `POST /extract_from_source` – Pulls from remote sources (Confluence, sitemap) using credentials and further optional kwargs. + +Both endpoints stream their results back to `admin-api-lib`, which takes care of enrichment and persistence. + +## How the file extraction endpoint works + +1. Download the file from S3 +2. Chose suitable file extractor based on the filename ending +3. Extract the content from the file +4. Map the internal representation to the external schema +5. Return the final output + +## How the source extraction endpoint works + +1. Chose suitable source extractor based on the source type +2. Pull the source content using the provided credentials and parameters +3. Extract the content from the source +4. Map the internal representation to the external schema +5. Return the final output + +## Configuration overview + +Two `pydantic-settings` models ship with this package: + +- **S3 storage** (`S3Settings`) – configure the built-in file service with `S3_ACCESS_KEY_ID`, `S3_SECRET_ACCESS_KEY`, `S3_ENDPOINT`, and `S3_BUCKET`. +- **PDF extraction** (`PDFExtractorSettings`) – adjust footer trimming or diagram export via `PDF_EXTRACTOR_FOOTER_HEIGHT` and `PDF_EXTRACTOR_DIAGRAMS_FOLDER_NAME`. + +Other extractors accept their parameters at runtime through the request payload (`ExtractionParameters`). For example, the admin backend forwards Confluence credentials, sitemap URLs, or custom headers when it calls `/extract_from_source`. This keeps the library stateless and makes it easy to plug in additional sources without redeploying. + +The Helm chart exposes the environment variables mentioned above under `documentExtractor.envs.*` so production deployments remain declarative. + +## Typical usage + +```python +from extractor_api_lib.main import app as perfect_extractor_app +``` + +`admin-api-lib` calls `/extract_from_file` and `/extract_from_source` to populate the ingestion pipeline. + +## Extending the library + +1. Implement `InformationFileExtractor` or `InformationExtractor` for your new format/source. +2. Register it in `dependency_container.py` (append to `file_extractors` list or `source_extractors` dict). +3. Update mapper or metadata handling if additional fields are required. +4. Add unit tests under `libs/extractor-api-lib/tests` using fixtures and fake storage providers. + +## Contributing + +Ensure new endpoints or adapters remain thin and defer to [`rag-core-lib`](../rag-core-lib/) for shared logic. Run `poetry run pytest` and the configured linters before opening a PR. For further instructions see the [Contributing Guide](https://github.com/stackitcloud/rag-template/blob/main/CONTRIBUTING.md). + +## License + +Licensed under the project license. See the root [`LICENSE`](https://github.com/stackitcloud/rag-template/blob/main/LICENSE) file. diff --git a/libs/extractor-api-lib/poetry.lock b/libs/extractor-api-lib/poetry.lock index 32ddc5c0..df3f4606 100644 --- a/libs/extractor-api-lib/poetry.lock +++ b/libs/extractor-api-lib/poetry.lock @@ -1102,25 +1102,21 @@ standard-no-fastapi-cloud-cli = ["email-validator (>=2.0.0)", "fastapi-cli[stand [[package]] name = "fasttext" -version = "0.9.2" +version = "0.9.3" description = "fasttext Python bindings" optional = false python-versions = "*" groups = ["main"] -files = [] -develop = false +files = [ + {file = "fasttext-0.9.3-cp39-cp39-macosx_14_0_arm64.whl", hash = "sha256:8b39f3ac5df43873648ea400cb75d4f7f9455730ac5105490b23b70f14e03ea7"}, + {file = "fasttext-0.9.3.tar.gz", hash = "sha256:eb03f2ef6340c6ac9e4398a30026f05471da99381b307aafe2f56e4cd26baaef"}, +] [package.dependencies] numpy = "*" pybind11 = ">=2.2" setuptools = ">=0.7.0" -[package.source] -type = "git" -url = "https://github.com/cfculhane/fastText" -reference = "4a4451337ae6b476b9c584b97776c8c3eb4b27c5" -resolved_reference = "4a4451337ae6b476b9c584b97776c8c3eb4b27c5" - [[package]] name = "filelock" version = "3.18.0" @@ -5087,4 +5083,4 @@ cffi = ["cffi (>=1.11)"] [metadata] lock-version = "2.1" python-versions = "^3.13" -content-hash = "d1e91c06b1bef49556b8e17fa9d920e9e0fde3b3828c489055fe2e0b2797779f" +content-hash = "8cafc0e5aa5d8040a4cd8784bf6caa156efe50cccd36095ae51d39abfd61641b" diff --git a/libs/extractor-api-lib/pyproject.toml b/libs/extractor-api-lib/pyproject.toml index 27b52762..707649b6 100644 --- a/libs/extractor-api-lib/pyproject.toml +++ b/libs/extractor-api-lib/pyproject.toml @@ -4,10 +4,19 @@ build-backend = "poetry.core.masonry.api" [tool.poetry] name = "extractor_api_lib" -version = "1.0.1" +version = "v3.2.1" description = "Extracts the content of documents, websites, etc and maps it to a common format." -authors = ["STACKIT Data and AI Consulting "] +authors = [ + "STACKIT GmbH & Co. KG ", +] +maintainers = [ + "Andreas Klos ", +] packages = [{ include = "extractor_api_lib", from = "src" }] +readme = "README.md" +license = "Apache-2.0" +repository = "https://github.com/stackitcloud/rag-template" +homepage = "https://pypi.org/project/extractor-api-lib" [[tool.poetry.source]] name = "pytorch_cpu" @@ -70,7 +79,7 @@ max-line-length = 120 python = "^3.13" wheel = "^0.45.1" botocore = "^1.38.10" -fasttext = {git = "https://github.com/cfculhane/fastText", rev = "4a4451337ae6b476b9c584b97776c8c3eb4b27c5"} +fasttext = "^0.9.3" pytesseract = "^0.3.10" fastapi = "^0.118.0" uvicorn = "^0.37.0" @@ -136,7 +145,7 @@ black = "^25.1.0" httpx = "^0.28.1" [tool.pytest.ini_options] -log_cli = 1 +log_cli = true log_cli_level = "DEBUG" pythonpath = "src" testpaths = "src/tests" diff --git a/libs/rag-core-lib/src/rag_core_lib/secret_provider/__init__.py b/libs/extractor-api-lib/src/extractor_api_lib/impl/file_services/__init__.py similarity index 100% rename from libs/rag-core-lib/src/rag_core_lib/secret_provider/__init__.py rename to libs/extractor-api-lib/src/extractor_api_lib/impl/file_services/__init__.py diff --git a/libs/rag-core-api/README.md b/libs/rag-core-api/README.md new file mode 100644 index 00000000..10e65388 --- /dev/null +++ b/libs/rag-core-api/README.md @@ -0,0 +1,96 @@ +# rag-core-api + +High-level API layer for the STACKIT [`RAG-Template`](https://github.com/stackitcloud/rag-template). It transforms its own primitives and those from [`rag-core-lib`](../rag-core-lib/) into a production-ready FastAPI surface, exposing chat, evaluation, and document-management endpoints used by [`services/rag-backend`](https://github.com/stackitcloud/rag-template/tree/main/services/rag-backend) and the MCP server of the `RAG-Template`. + +## Responsibilities + +- **Dependency Injection** – Compose the dependency-injector container to assemble LLMs, embeddings, vector stores, rerankers, and retrievers from [`rag-core-lib`](../rag-core-lib/). +- **API Exposure** – Expose production-ready FastAPI routers for chat, evaluation, and information piece management. +- **Chat Orchestration** – Provide default LangGraph chat orchestration and evaluation pipelines that downstream services can reuse or override. +- **Knowledge base integration** – Manages all interaction with the knowledge base (vector database). + +## Feature highlights + +- **Chat graph built on LangGraph** – Default `DefaultChatGraph` stitches together language detection, question rephrasing, retrieval (with reranking), answer generation, and Langfuse tracing. +- **Evaluation endpoint** – Ships a Langfuse + RAGAS evaluator so you can score QA datasets against your RAG stack without custom plumbing. +- **Pluggable components** – Replace embedder, vector database, reranker, prompts, or chains via dependency-injector overrides. The defaults target Qdrant + FlashRank but every interface is typed. +- **Consistent models** – Pydantic schemas in `rag_core_api.models` cover request/response payloads for chat, evaluation, and document ingestion. +- **Shared configuration** – Reuses [`rag-core-lib`](../rag-core-lib/) settings so LLMS, embeddings, retries, and Langfuse behave the same way across services. + +## Installation + +```bash +pip install rag-core-api +``` + +Requires Python 3.13 and `rag-core-lib`. + +## Where it fits in the RAG solution + +| Layer | Responsibilities | Package | +| --- | --- | --- | +| RAG primitives | LLMs, embeddings, retry, tracing (shared in multiple libs) | [`rag-core-lib`](../rag-core-lib/) | +| API assembly (this package) | Routers, dependency container, evaluators, graph wiring | `rag-core-api` | +| Service runtime | FastAPI application to customize the API offered by `rag-core-api` | [`services/rag-backend`](https://github.com/stackitcloud/rag-template/tree/main/services/rag-backend) | + +Other services (admin backend and MCP server) call the endpoints provided by this package to ingest, delete, and chat with information pieces. + +## Module tour + +- `dependency_container.py` – Configures dependency-injector providers. Override registrations here to swap providers or inject fakes for tests. +- `api_endpoints/` & `impl/api_endpoints/` – Thin endpoints + abstractions (`Chat`, `InformationPiecesUploader`, etc.) that map HTTP verbs to underlying logic. +- `api/` – Core API definitions, mostly created by API-specs and openapi generator. +- `embeddings/` & `impl/embeddings/` – Embedding classes + abstractions + embedder type definitions. +- `evaluator/` & `impl/evaluator/` – Langfuse + RAGAS evaluator used by `/evaluate` endpoint. +- `graph/` & `impl/graph/` – LangGraph graph + state definitions for chat flows, including language detection, rephrasing, retrieval etc. +- `reranking/` & `impl/reranking/` – Reranking logic for selecting most relevant documents. +- `retriever/` & `impl/retriever/` – Document retrieval logic. +- `impl/settings/` – Configuration settings for dependency injection container components. +- `mapper/` – Information piece 2 langchain documents mapper. +- `prompt_templates/` – Default LLM prompts for answering, rephrasing, and language detection. Override them via Langfuse or dependency injection. +- `embeddings/` – Thin wrappers that adapt embedder instances from `rag-core-lib` for retriever usage. They will be removed in v4. +- `utils/` – Shared utility functions and classes. +- `vector_databases/` & `impl/vector_databases/` – Interfaces plus default implementations (Qdrant, FlashRank). + +## Endpoints provided + +- `POST /chat/{session_id}` – Conversational RAG (streaming and non-streaming depending on transport). Handles language detection, retrieval, and answer generation. +- `POST /evaluate` – Runs RAGAS evaluation on supplied question/answer datasets; outputs Langfuse traces and aggregate metrics. +- `POST /information_pieces/upload` – Accepts pre-extracted (e.g., from `extractor-api-lib`) and processed (e.g., from `admin-api-lib`) documents for ingestion into the vector store. +- `POST /information_pieces/remove` – Removes stored information pieces by document identifier from the vector store. + +Refer to [`libs/README.md`](../README.md#1-rag-core-api) for in-depth API documentation. + +## Configuration overview + +`rag-core-api` consumes the same environment variables as `rag-core-lib` for provider selection (`RAG_CLASS_TYPE_LLM_TYPE`, `EMBEDDER_CLASS_TYPE_EMBEDDER_TYPE`, Langfuse keys, retry settings). Additional knobs include: + +- `QDRANT_URL`, `QDRANT_API_KEY`, `QDRANT_COLLECTION_NAME` – passed into the default `QdrantDatabase`. +- `FLASHRANK_MODEL_NAME` – tuner for FlashRank reranker. +- `RAGAS_DATASET_FILENAME`, `RAGAS_MODEL` – control evaluation dataset and LLM. + +The Helm chart supplies these values through `backend.envs.*`. Local development can rely on `.env` configuration (see repository root documentation). + +## Typical usage + +```python +from rag_core_api.main import app as perfect_rag_app +``` + +Delivers a full functional API. See [`services/rag-backend/main.py`](https://github.com/stackitcloud/rag-template/blob/main/services/rag-backend/main.py) and [`services/rag-backend/container.py`](https://github.com/stackitcloud/rag-template/blob/main/services/rag-backend/container.py), which compose the API with additional middleware, auth, and deployment-specific wiring. + +## Extending the library + +1. Subclass the relevant interface (e.g., `VectorDatabase`, `Retriever`, `Chat` endpoint). +2. Register your implementation in the dependency container. +3. Add pytest-based tests under `libs/rag-core-api/tests` that exercise the new component via the container. + +Because components depend on interfaces defined here, downstream services can swap behavior without modifying the public API surface. + +## Contributing + +Ensure new endpoints or adapters remain thin and defer to [`rag-core-lib`](../rag-core-lib/) for shared logic. Run `poetry run pytest` and the configured linters before opening a PR. For further instructions see the [Contributing Guide](https://github.com/stackitcloud/rag-template/blob/main/CONTRIBUTING.md). + +## License + +Licensed under the project license. See the root [`LICENSE`](https://github.com/stackitcloud/rag-template/blob/main/LICENSE) file. diff --git a/libs/rag-core-api/poetry.lock b/libs/rag-core-api/poetry.lock index 4b0a3212..cdbcee14 100644 --- a/libs/rag-core-api/poetry.lock +++ b/libs/rag-core-api/poetry.lock @@ -4252,8 +4252,8 @@ fastembed-gpu = ["fastembed-gpu (>=0.7,<0.8)"] [[package]] name = "rag-core-lib" -version = "1.0.1" -description = "The perfect rag template" +version = "v3.2.1" +description = "The rag-core-lib contains the shared components of at least two of the rag libs." optional = false python-versions = "^3.13" groups = ["main"] diff --git a/libs/rag-core-api/pyproject.toml b/libs/rag-core-api/pyproject.toml index bdb830ab..c0c253fe 100644 --- a/libs/rag-core-api/pyproject.toml +++ b/libs/rag-core-api/pyproject.toml @@ -4,10 +4,19 @@ build-backend = "poetry.core.masonry.api" [tool.poetry] name = "rag-core-api" -version = "1.0.1" -description = "The core of the rag-template." -authors = ["STACKIT Data and AI Consulting "] +version = "v3.2.1" +description = "The rag-core-api contains the API layer for the RAG template for document retrieval, question answering, knowledge base management in the vector database and more." packages = [{ include = "rag_core_api", from = "src" }] +authors = [ + "STACKIT GmbH & Co. KG ", +] +maintainers = [ + "Andreas Klos ", +] +readme = "README.md" +license = "Apache-2.0" +repository = "https://github.com/stackitcloud/rag-template" +homepage = "https://pypi.org/project/rag-core-api" [tool.poetry.dependencies] python = "^3.13" diff --git a/libs/rag-core-lib/README.md b/libs/rag-core-lib/README.md new file mode 100644 index 00000000..5bcc2aa0 --- /dev/null +++ b/libs/rag-core-lib/README.md @@ -0,0 +1,85 @@ +# rag-core-lib + +Foundation library for the STACKIT RAG template. It packages all reusable Retrieval-Augmented Generation (RAG) primitives—LLM factories, embedding providers, retry/backoff helpers, Langfuse instrumentation, and configuration models—so higher-level services and libs can stay thin and declarative. + +`rag-core-lib` sits at the bottom of the dependency pyramid: + +- `rag-core-api` builds the public FastAPI surface on top of it. +- `admin-api-lib` and `extractor-api-lib` reuse the same factories, tracing, and configuration system. +- Service deployments (see `services/*`) can replace components through dependency-injector in the dependency containers of the libs. These dependency containers that can be overridden live in the respective API libs ([`rag-core-api`](https://pypi.org/project/rag-core-api/), [`admin-api-lib`](https://pypi.org/project/admin-api-lib/), [`extractor-api-lib`](https://pypi.org/project/extractor-api-lib/)); [`rag-core-lib`](https://pypi.org/project/rag-core-lib/) itself is a pure building-block library with no injectable services to swap. + +## What you get + +- **Provider-agnostic LLM & embedding adapters** – OpenAI-compatible, STACKIT model serving, Ollama, plus fake implementations for tests. Selection happens through `RAGClassTypeSettings` / `EmbedderClassTypeSettings`. +- **Shared configuration models** – `pydantic-settings` based schemas for Langfuse, retry/backoff knobs, and feature flags. All values can be set via environment variables or Helm values. +- **LangChain/LangGraph utilities** – Reusable `AsyncRunnable` abstraction, default chat graph wiring, and structured tracing wrappers (`LangfuseTracedRunnable`). +- **Observability tooling** – Langfuse manager, structured logging hooks, and rate-limit aware retry decorator. +- **Safety & testing utilities** – Fake providers, deterministic defaults, and pytest helpers reused across the monorepo. + +## Installation + +```bash +pip install rag-core-lib +``` + +Python 3.13 is required. + +## Package map at a glance + +| Module | Purpose | +| --- | --- | +| `rag_core_lib.impl.settings.*` | Pydantic settings for LLM/embedding providers, Langfuse, retry decorator, and feature toggles. | +| `rag_core_lib.impl.llms.llm_factory` | Produces chat/completion models based on the selected provider (`stackit`, `ollama`, `fake`). | +| `rag_core_lib.impl.embeddings.*` | Embedding adapters with retry wrapping and provider-specific configuration. | +| `rag_core_lib.impl.tracers.*` | Langfuse-backed wrappers to trace LangChain/LangGraph runnables. | +| `rag_core_lib.impl.utils.retry_decorator` | Exponential backoff decorator shared by summarizers, embedders, and other outbound calls. | +| `rag_core_lib.runnables.*` | Asynchronous runnable abstractions used by chat graphs and admin workflows. | +| `rag_core_lib.tracers.*` | Abstractions for tracing runnables. | + +## Configuration & environment variables + +All settings derive from `pydantic-settings` models, so you can either build them in code or supply environment variables: + +- **LLM selection** – `RAG_CLASS_TYPE_LLM_TYPE` (`stackit`, `ollama`, `fake`). Provider-specific keys such as `STACKIT_VLLM_API_KEY` or `OLLAMA_BASE_URL` fill the matching settings models (`StackitVLLMSettings`, `OllamaLLMSettings`). +- **Embedding selection** – `EMBEDDER_CLASS_TYPE_EMBEDDER_TYPE` plus provider-specific variables (for example `STACKIT_EMBEDDER_MODEL`, `OLLAMA_EMBEDDER_MODEL`). +- **Langfuse** – `LANGFUSE_PUBLIC_KEY`, `LANGFUSE_SECRET_KEY`, and optional host/project settings configure tracing. +- **Retry defaults** – `RETRY_DECORATOR_MAX_RETRIES`, `RETRY_DECORATOR_BACKOFF_FACTOR`, and related keys feed `RetryDecoratorSettings`. Components can override them through their own settings models (e.g., `StackitEmbedderSettings`). + +When deploying through the provided Helm chart, the same keys are exposed under `shared.envs.*`, `backend.envs.*`, and `adminBackend.envs.*`. + +## Typical usage + +```python +# Assumptions: +# - STACKIT exposes an OpenAI-compatible endpoint, so the default provider works out of the box. +# - You have a STACKIT_VLLM_API_KEY available via environment variables or provide it explicitly below. + +from rag_core_lib.impl.llms.llm_factory import chat_model_provider +from rag_core_lib.impl.settings.stackit_vllm_settings import StackitVllmSettings + +# Build settings from env or manually override defaults +settings = StackitVllmSettings( + model="cortecs/Llama-3.3-70B-Instruct-FP8-Dynamic", + temperature=0.1, +) + +# Resolve the LangChain chat model (async or sync) +chat_llm = chat_model_provider(settings) + +response = chat_llm.invoke("Tell me about RAG pipelines") +print(response.content) +``` + +## Related packages + +- [`rag-core-api`](../rag-core-api/) – HTTP API layer that exposes chat, evaluation, and information piece endpoints. +- [`admin-api-lib`](../admin-api-lib/) – Document lifecycle orchestration built on top of this foundation. +- [`extractor-api-lib`](../extractor-api-lib/) – Content extraction service using shared retry, settings, and tracing primitives. + +## Contributing + +Follow the repository conventions (Black, isort, Flake8, pytest). When adding new providers or utilities, include typed settings, update Helm values if required, and add unit tests under `libs/rag-core-lib/tests`. For further instructions see the [Contributing Guide](https://github.com/stackitcloud/rag-template/blob/main/CONTRIBUTING.md). + +## License + +Licensed under Apache 2.0, see the project license at the root [`LICENSE`](https://github.com/stackitcloud/rag-template/blob/66570f95d8decb431a2ff7626e911d43231914a6/LICENSE) file of this repository. diff --git a/libs/rag-core-lib/pyproject.toml b/libs/rag-core-lib/pyproject.toml index b8f8ab59..e08c515a 100644 --- a/libs/rag-core-lib/pyproject.toml +++ b/libs/rag-core-lib/pyproject.toml @@ -4,10 +4,19 @@ build-backend = "poetry.core.masonry.api" [tool.poetry] name = "rag-core-lib" -version = "1.0.1" -description = "The perfect rag template" -authors = ["STACKIT GmbH & Co. KG"] +version = "v3.2.1" +description = "The rag-core-lib contains the shared components of at least two of the rag libs." +authors = [ + "STACKIT GmbH & Co. KG ", +] +maintainers = [ + "Andreas Klos ", +] packages = [{ include = "rag_core_lib", from = "src" }] +readme = "README.md" +license = "Apache-2.0" +repository = "https://github.com/stackitcloud/rag-template" +homepage = "https://pypi.org/project/rag-core-lib" [tool.poetry.dependencies] python = "^3.13" @@ -105,7 +114,7 @@ skip_gitignore = true max-line-length = 120 [tool.pytest.ini_options] -log_cli = 1 +log_cli = true log_cli_level = "DEBUG" pythonpath = "src" testpaths = "src/tests" diff --git a/libs/rag-core-lib/src/rag_core_lib/secret_provider/secret_provider.py b/libs/rag-core-lib/src/rag_core_lib/secret_provider/secret_provider.py deleted file mode 100644 index 444748d6..00000000 --- a/libs/rag-core-lib/src/rag_core_lib/secret_provider/secret_provider.py +++ /dev/null @@ -1,30 +0,0 @@ -"""Interface for providing API tokens.""" - -from abc import ABC, abstractmethod - - -class SecretProvider(ABC): - """Interface for providing API tokens.""" - - @property - @abstractmethod - def provided_key(self) -> str: - """ - Abstract property that should be implemented to provide a secret key. - - Returns - ------- - str - The secret key provided by the implementing class. - """ - - @abstractmethod - def provide_token(self) -> dict: - """ - Abstract method that should be implemented to provide an API token. - - Returns - ------- - dict - A dictionary containing the API token. - """ diff --git a/services/admin-backend/poetry.lock b/services/admin-backend/poetry.lock index 5191d719..332b577a 100644 --- a/services/admin-backend/poetry.lock +++ b/services/admin-backend/poetry.lock @@ -2,7 +2,7 @@ [[package]] name = "admin-api-lib" -version = "1.0.1" +version = "v3.2.0" description = "The admin backend is responsible for the document management. This includes deletion, upload and returning the source document." optional = false python-versions = "^3.13" @@ -3152,8 +3152,8 @@ files = [ [[package]] name = "rag-core-lib" -version = "1.0.1" -description = "The perfect rag template" +version = "v3.2.0" +description = "The rag-core-lib contains the shared components of at least two of the rag libs." optional = false python-versions = "^3.13" groups = ["main"] diff --git a/services/admin-backend/pyproject.toml b/services/admin-backend/pyproject.toml index b5341c8f..35079e41 100644 --- a/services/admin-backend/pyproject.toml +++ b/services/admin-backend/pyproject.toml @@ -51,9 +51,9 @@ skip_gitignore = true max-line-length = 120 [tool.poetry] -name = "admin_backend" -version = "0.0.1" -description = "The admin backend is responsible for the document management. This includes deletion, upload and getting particular documents or document lists." +name = "admin-backend-usecase-example" +version = "3.2.0" +description = "This example demonstrates the usage of the admin-api-lib." authors = ["STACKIT Data and AI Consulting "] readme = "README.md" diff --git a/services/document-extractor/poetry.lock b/services/document-extractor/poetry.lock index d436aa19..a831abc0 100644 --- a/services/document-extractor/poetry.lock +++ b/services/document-extractor/poetry.lock @@ -1088,7 +1088,7 @@ files = [ [[package]] name = "extractor-api-lib" -version = "1.0.1" +version = "v3.2.0" description = "Extracts the content of documents, websites, etc and maps it to a common format." optional = false python-versions = "^3.13" @@ -1106,11 +1106,11 @@ debugpy = "^1.8.14" dependency-injector = "^4.46.0" docx2txt = "^0.9" fake-useragent = "^2.2.0" -fastapi = "^0.116.0" -fasttext = {git = "https://github.com/cfculhane/fastText", rev = "4a4451337ae6b476b9c584b97776c8c3eb4b27c5"} +fastapi = "^0.118.0" +fasttext = "^0.9.3" html5lib = "^1.1" langchain-community = "^0.3.23" -langchain-core = "0.3.74" +langchain-core = "0.3.77" lxml = "^5.4.0" markdownify = "^1.1.0" numpy = "^2.2.5" @@ -1129,8 +1129,8 @@ pyyaml = "^6.0.2" requests-oauthlib = "^2.0.0" starlette = ">=0.47.2,<0.49.0" tabulate = "^0.9.0" -unstructured = {version = "0.18.13", extras = ["docx", "pptx"]} -uvicorn = "^0.35.0" +unstructured = {version = "0.18.15", extras = ["docx", "pptx"]} +uvicorn = "^0.37.0" wheel = "^0.45.1" [package.source] @@ -1151,14 +1151,14 @@ files = [ [[package]] name = "fastapi" -version = "0.116.2" +version = "0.118.3" description = "FastAPI framework, high performance, easy to learn, fast to code, ready for production" optional = false python-versions = ">=3.8" groups = ["main"] files = [ - {file = "fastapi-0.116.2-py3-none-any.whl", hash = "sha256:c3a7a8fb830b05f7e087d920e0d786ca1fc9892eb4e9a84b227be4c1bc7569db"}, - {file = "fastapi-0.116.2.tar.gz", hash = "sha256:231a6af2fe21cfa2c32730170ad8514985fc250bec16c9b242d3b94c835ef529"}, + {file = "fastapi-0.118.3-py3-none-any.whl", hash = "sha256:8b9673dc083b4b9d3d295d49ba1c0a2abbfb293d34ba210fd9b0a90d5f39981e"}, + {file = "fastapi-0.118.3.tar.gz", hash = "sha256:5bf36d9bb0cd999e1aefcad74985a6d6a1fc3a35423d497f9e1317734633411d"}, ] [package.dependencies] @@ -1167,31 +1167,27 @@ starlette = ">=0.40.0,<0.49.0" typing-extensions = ">=4.8.0" [package.extras] -all = ["email-validator (>=2.0.0)", "fastapi-cli[standard] (>=0.0.8)", "httpx (>=0.23.0)", "itsdangerous (>=1.1.0)", "jinja2 (>=3.1.5)", "orjson (>=3.2.1)", "pydantic-extra-types (>=2.0.0)", "pydantic-settings (>=2.0.0)", "python-multipart (>=0.0.18)", "pyyaml (>=5.3.1)", "ujson (>=4.0.1,!=4.0.2,!=4.1.0,!=4.2.0,!=4.3.0,!=5.0.0,!=5.1.0)", "uvicorn[standard] (>=0.12.0)"] -standard = ["email-validator (>=2.0.0)", "fastapi-cli[standard] (>=0.0.8)", "httpx (>=0.23.0)", "jinja2 (>=3.1.5)", "python-multipart (>=0.0.18)", "uvicorn[standard] (>=0.12.0)"] -standard-no-fastapi-cloud-cli = ["email-validator (>=2.0.0)", "fastapi-cli[standard-no-fastapi-cloud-cli] (>=0.0.8)", "httpx (>=0.23.0)", "jinja2 (>=3.1.5)", "python-multipart (>=0.0.18)", "uvicorn[standard] (>=0.12.0)"] +all = ["email-validator (>=2.0.0)", "fastapi-cli[standard] (>=0.0.8)", "httpx (>=0.23.0,<1.0.0)", "itsdangerous (>=1.1.0)", "jinja2 (>=3.1.5)", "orjson (>=3.2.1)", "pydantic-extra-types (>=2.0.0)", "pydantic-settings (>=2.0.0)", "python-multipart (>=0.0.18)", "pyyaml (>=5.3.1)", "ujson (>=4.0.1,!=4.0.2,!=4.1.0,!=4.2.0,!=4.3.0,!=5.0.0,!=5.1.0)", "uvicorn[standard] (>=0.12.0)"] +standard = ["email-validator (>=2.0.0)", "fastapi-cli[standard] (>=0.0.8)", "httpx (>=0.23.0,<1.0.0)", "jinja2 (>=3.1.5)", "python-multipart (>=0.0.18)", "uvicorn[standard] (>=0.12.0)"] +standard-no-fastapi-cloud-cli = ["email-validator (>=2.0.0)", "fastapi-cli[standard-no-fastapi-cloud-cli] (>=0.0.8)", "httpx (>=0.23.0,<1.0.0)", "jinja2 (>=3.1.5)", "python-multipart (>=0.0.18)", "uvicorn[standard] (>=0.12.0)"] [[package]] name = "fasttext" -version = "0.9.2" +version = "0.9.3" description = "fasttext Python bindings" optional = false python-versions = "*" groups = ["main"] -files = [] -develop = false +files = [ + {file = "fasttext-0.9.3-cp39-cp39-macosx_14_0_arm64.whl", hash = "sha256:8b39f3ac5df43873648ea400cb75d4f7f9455730ac5105490b23b70f14e03ea7"}, + {file = "fasttext-0.9.3.tar.gz", hash = "sha256:eb03f2ef6340c6ac9e4398a30026f05471da99381b307aafe2f56e4cd26baaef"}, +] [package.dependencies] numpy = "*" pybind11 = ">=2.2" setuptools = ">=0.7.0" -[package.source] -type = "git" -url = "https://github.com/cfculhane/fastText" -reference = "4a4451337ae6b476b9c584b97776c8c3eb4b27c5" -resolved_reference = "4a4451337ae6b476b9c584b97776c8c3eb4b27c5" - [[package]] name = "filelock" version = "3.19.1" @@ -2060,24 +2056,24 @@ tenacity = ">=8.1.0,<8.4.0 || >8.4.0,<10" [[package]] name = "langchain-core" -version = "0.3.74" +version = "0.3.77" description = "Building applications with LLMs through composability" optional = false -python-versions = ">=3.9" +python-versions = "<4.0.0,>=3.9.0" groups = ["main"] files = [ - {file = "langchain_core-0.3.74-py3-none-any.whl", hash = "sha256:088338b5bc2f6a66892f9afc777992c24ee3188f41cbc603d09181e34a228ce7"}, - {file = "langchain_core-0.3.74.tar.gz", hash = "sha256:ff604441aeade942fbcc0a3860a592daba7671345230c2078ba2eb5f82b6ba76"}, + {file = "langchain_core-0.3.77-py3-none-any.whl", hash = "sha256:9966dfe3d8365847c5fb85f97dd20e3e21b1904ae87cfd9d362b7196fb516637"}, + {file = "langchain_core-0.3.77.tar.gz", hash = "sha256:1d6f2ad6bb98dd806c6c66a822fa93808d821e9f0348b28af0814b3a149830e7"}, ] [package.dependencies] -jsonpatch = ">=1.33,<2.0" -langsmith = ">=0.3.45" -packaging = ">=23.2" -pydantic = ">=2.7.4" -PyYAML = ">=5.3" +jsonpatch = ">=1.33.0,<2.0.0" +langsmith = ">=0.3.45,<1.0.0" +packaging = ">=23.2.0,<26.0.0" +pydantic = ">=2.7.4,<3.0.0" +PyYAML = ">=5.3.0,<7.0.0" tenacity = ">=8.1.0,<8.4.0 || >8.4.0,<10.0.0" -typing-extensions = ">=4.7" +typing-extensions = ">=4.7.0,<5.0.0" [[package]] name = "langchain-text-splitters" @@ -4479,14 +4475,14 @@ files = [ [[package]] name = "unstructured" -version = "0.18.13" +version = "0.18.15" description = "A library that prepares raw documents for downstream ML tasks." optional = false python-versions = ">=3.10.0" groups = ["main"] files = [ - {file = "unstructured-0.18.13-py3-none-any.whl", hash = "sha256:cd4e3a9fe456b9e305e1e9669a444498b2b18f1f13d07a449816ff5849ddd998"}, - {file = "unstructured-0.18.13.tar.gz", hash = "sha256:3ca6034d8647fef5c26b39bacae3d90a5f530f520bfd80f0e964bd5e084a0d50"}, + {file = "unstructured-0.18.15-py3-none-any.whl", hash = "sha256:f05b1defcbe8190319d30da8adddbb888f74bf8ec7f65886867d7dca41d67ad0"}, + {file = "unstructured-0.18.15.tar.gz", hash = "sha256:81d8481280a4ac5cefe74bdb6db3687e8f240d5643706f86728eac39549112b5"}, ] [package.dependencies] @@ -4576,14 +4572,14 @@ zstd = ["zstandard (>=0.18.0)"] [[package]] name = "uvicorn" -version = "0.35.0" +version = "0.37.0" description = "The lightning-fast ASGI server." optional = false python-versions = ">=3.9" groups = ["main"] files = [ - {file = "uvicorn-0.35.0-py3-none-any.whl", hash = "sha256:197535216b25ff9b785e29a0b79199f55222193d47f820816e7da751e9bc8d4a"}, - {file = "uvicorn-0.35.0.tar.gz", hash = "sha256:bc662f087f7cf2ce11a1d7fd70b90c9f98ef2e2831556dd078d131b96cc94a01"}, + {file = "uvicorn-0.37.0-py3-none-any.whl", hash = "sha256:913b2b88672343739927ce381ff9e2ad62541f9f8289664fa1d1d3803fa2ce6c"}, + {file = "uvicorn-0.37.0.tar.gz", hash = "sha256:4115c8add6d3fd536c8ee77f0e14a7fd2ebba939fed9b02583a97f80648f9e13"}, ] [package.dependencies] diff --git a/services/document-extractor/pyproject.toml b/services/document-extractor/pyproject.toml index 685483dd..c3c61351 100644 --- a/services/document-extractor/pyproject.toml +++ b/services/document-extractor/pyproject.toml @@ -44,8 +44,8 @@ max-line-length = 120 [tool.poetry] name = "pdfextractor_server" -version = "0.0.0" -description = "Extracts the content of pdf documents." +version = "3.2.0" +description = "This example demonstrates the usage of the extractor-api-lib." authors = ["STACKIT Data and AI Consulting "] readme = "README.md" diff --git a/services/rag-backend/poetry.lock b/services/rag-backend/poetry.lock index 5916e3de..f8b2ee18 100644 --- a/services/rag-backend/poetry.lock +++ b/services/rag-backend/poetry.lock @@ -523,11 +523,11 @@ description = "Cross-platform colored terminal text." optional = false python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" groups = ["main", "dev"] +markers = "platform_system == \"Windows\" or sys_platform == \"win32\"" files = [ {file = "colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"}, {file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"}, ] -markers = {main = "platform_system == \"Windows\" or sys_platform == \"win32\"", dev = "sys_platform == \"win32\" or platform_system == \"Windows\""} [[package]] name = "coloredlogs" @@ -885,25 +885,25 @@ files = [ [[package]] name = "fastapi" -version = "0.116.1" +version = "0.118.3" description = "FastAPI framework, high performance, easy to learn, fast to code, ready for production" optional = false python-versions = ">=3.8" groups = ["main"] files = [ - {file = "fastapi-0.116.1-py3-none-any.whl", hash = "sha256:c46ac7c312df840f0c9e220f7964bada936781bc4e2e6eb71f1c4d7553786565"}, - {file = "fastapi-0.116.1.tar.gz", hash = "sha256:ed52cbf946abfd70c5a0dccb24673f0670deeb517a88b3544d03c2a6bf283143"}, + {file = "fastapi-0.118.3-py3-none-any.whl", hash = "sha256:8b9673dc083b4b9d3d295d49ba1c0a2abbfb293d34ba210fd9b0a90d5f39981e"}, + {file = "fastapi-0.118.3.tar.gz", hash = "sha256:5bf36d9bb0cd999e1aefcad74985a6d6a1fc3a35423d497f9e1317734633411d"}, ] [package.dependencies] pydantic = ">=1.7.4,<1.8 || >1.8,<1.8.1 || >1.8.1,<2.0.0 || >2.0.0,<2.0.1 || >2.0.1,<2.1.0 || >2.1.0,<3.0.0" -starlette = ">=0.40.0,<0.48.0" +starlette = ">=0.40.0,<0.49.0" typing-extensions = ">=4.8.0" [package.extras] -all = ["email-validator (>=2.0.0)", "fastapi-cli[standard] (>=0.0.8)", "httpx (>=0.23.0)", "itsdangerous (>=1.1.0)", "jinja2 (>=3.1.5)", "orjson (>=3.2.1)", "pydantic-extra-types (>=2.0.0)", "pydantic-settings (>=2.0.0)", "python-multipart (>=0.0.18)", "pyyaml (>=5.3.1)", "ujson (>=4.0.1,!=4.0.2,!=4.1.0,!=4.2.0,!=4.3.0,!=5.0.0,!=5.1.0)", "uvicorn[standard] (>=0.12.0)"] -standard = ["email-validator (>=2.0.0)", "fastapi-cli[standard] (>=0.0.8)", "httpx (>=0.23.0)", "jinja2 (>=3.1.5)", "python-multipart (>=0.0.18)", "uvicorn[standard] (>=0.12.0)"] -standard-no-fastapi-cloud-cli = ["email-validator (>=2.0.0)", "fastapi-cli[standard-no-fastapi-cloud-cli] (>=0.0.8)", "httpx (>=0.23.0)", "jinja2 (>=3.1.5)", "python-multipart (>=0.0.18)", "uvicorn[standard] (>=0.12.0)"] +all = ["email-validator (>=2.0.0)", "fastapi-cli[standard] (>=0.0.8)", "httpx (>=0.23.0,<1.0.0)", "itsdangerous (>=1.1.0)", "jinja2 (>=3.1.5)", "orjson (>=3.2.1)", "pydantic-extra-types (>=2.0.0)", "pydantic-settings (>=2.0.0)", "python-multipart (>=0.0.18)", "pyyaml (>=5.3.1)", "ujson (>=4.0.1,!=4.0.2,!=4.1.0,!=4.2.0,!=4.3.0,!=5.0.0,!=5.1.0)", "uvicorn[standard] (>=0.12.0)"] +standard = ["email-validator (>=2.0.0)", "fastapi-cli[standard] (>=0.0.8)", "httpx (>=0.23.0,<1.0.0)", "jinja2 (>=3.1.5)", "python-multipart (>=0.0.18)", "uvicorn[standard] (>=0.12.0)"] +standard-no-fastapi-cloud-cli = ["email-validator (>=2.0.0)", "fastapi-cli[standard-no-fastapi-cloud-cli] (>=0.0.8)", "httpx (>=0.23.0,<1.0.0)", "jinja2 (>=3.1.5)", "python-multipart (>=0.0.18)", "uvicorn[standard] (>=0.12.0)"] [[package]] name = "fastembed" @@ -2063,19 +2063,19 @@ files = [ [[package]] name = "langchain" -version = "0.3.26" +version = "0.3.27" description = "Building applications with LLMs through composability" optional = false -python-versions = ">=3.9" +python-versions = "<4.0,>=3.9" groups = ["main"] files = [ - {file = "langchain-0.3.26-py3-none-any.whl", hash = "sha256:361bb2e61371024a8c473da9f9c55f4ee50f269c5ab43afdb2b1309cb7ac36cf"}, - {file = "langchain-0.3.26.tar.gz", hash = "sha256:8ff034ee0556d3e45eff1f1e96d0d745ced57858414dba7171c8ebdbeb5580c9"}, + {file = "langchain-0.3.27-py3-none-any.whl", hash = "sha256:7b20c4f338826acb148d885b20a73a16e410ede9ee4f19bb02011852d5f98798"}, + {file = "langchain-0.3.27.tar.gz", hash = "sha256:aa6f1e6274ff055d0fd36254176770f356ed0a8994297d1df47df341953cec62"}, ] [package.dependencies] -langchain-core = ">=0.3.66,<1.0.0" -langchain-text-splitters = ">=0.3.8,<1.0.0" +langchain-core = ">=0.3.72,<1.0.0" +langchain-text-splitters = ">=0.3.9,<1.0.0" langsmith = ">=0.1.17" pydantic = ">=2.7.4,<3.0.0" PyYAML = ">=5.3" @@ -2103,50 +2103,50 @@ xai = ["langchain-xai"] [[package]] name = "langchain-community" -version = "0.3.27" +version = "0.3.30" description = "Community contributed LangChain integrations." optional = false -python-versions = ">=3.9" +python-versions = "<4.0.0,>=3.9.0" groups = ["main"] files = [ - {file = "langchain_community-0.3.27-py3-none-any.whl", hash = "sha256:581f97b795f9633da738ea95da9cb78f8879b538090c9b7a68c0aed49c828f0d"}, - {file = "langchain_community-0.3.27.tar.gz", hash = "sha256:e1037c3b9da0c6d10bf06e838b034eb741e016515c79ef8f3f16e53ead33d882"}, + {file = "langchain_community-0.3.30-py3-none-any.whl", hash = "sha256:a49dcedbf8f320d9868d5944d0991c7bcc9f2182a602e5d5e872d315183c11c3"}, + {file = "langchain_community-0.3.30.tar.gz", hash = "sha256:df68fbde7f7fa5142ab93b0cbc104916b12ab4163e200edd933ee93e67956ee9"}, ] [package.dependencies] aiohttp = ">=3.8.3,<4.0.0" -dataclasses-json = ">=0.5.7,<0.7" +dataclasses-json = ">=0.6.7,<0.7.0" httpx-sse = ">=0.4.0,<1.0.0" -langchain = ">=0.3.26,<1.0.0" -langchain-core = ">=0.3.66,<1.0.0" -langsmith = ">=0.1.125" +langchain = ">=0.3.27,<2.0.0" +langchain-core = ">=0.3.75,<2.0.0" +langsmith = ">=0.1.125,<1.0.0" numpy = {version = ">=2.1.0", markers = "python_version >= \"3.13\""} -pydantic-settings = ">=2.4.0,<3.0.0" -PyYAML = ">=5.3" -requests = ">=2,<3" -SQLAlchemy = ">=1.4,<3" -tenacity = ">=8.1.0,<8.4.0 || >8.4.0,<10" +pydantic-settings = ">=2.10.1,<3.0.0" +PyYAML = ">=5.3.0,<7.0.0" +requests = ">=2.32.5,<3.0.0" +SQLAlchemy = ">=1.4.0,<3.0.0" +tenacity = ">=8.1.0,<8.4.0 || >8.4.0,<10.0.0" [[package]] name = "langchain-core" -version = "0.3.74" +version = "0.3.77" description = "Building applications with LLMs through composability" optional = false -python-versions = ">=3.9" +python-versions = "<4.0.0,>=3.9.0" groups = ["main"] files = [ - {file = "langchain_core-0.3.74-py3-none-any.whl", hash = "sha256:088338b5bc2f6a66892f9afc777992c24ee3188f41cbc603d09181e34a228ce7"}, - {file = "langchain_core-0.3.74.tar.gz", hash = "sha256:ff604441aeade942fbcc0a3860a592daba7671345230c2078ba2eb5f82b6ba76"}, + {file = "langchain_core-0.3.77-py3-none-any.whl", hash = "sha256:9966dfe3d8365847c5fb85f97dd20e3e21b1904ae87cfd9d362b7196fb516637"}, + {file = "langchain_core-0.3.77.tar.gz", hash = "sha256:1d6f2ad6bb98dd806c6c66a822fa93808d821e9f0348b28af0814b3a149830e7"}, ] [package.dependencies] -jsonpatch = ">=1.33,<2.0" -langsmith = ">=0.3.45" -packaging = ">=23.2" -pydantic = ">=2.7.4" -PyYAML = ">=5.3" +jsonpatch = ">=1.33.0,<2.0.0" +langsmith = ">=0.3.45,<1.0.0" +packaging = ">=23.2.0,<26.0.0" +pydantic = ">=2.7.4,<3.0.0" +PyYAML = ">=5.3.0,<7.0.0" tenacity = ">=8.1.0,<8.4.0 || >8.4.0,<10.0.0" -typing-extensions = ">=4.7" +typing-extensions = ">=4.7.0,<5.0.0" [[package]] name = "langchain-ollama" @@ -2233,14 +2233,14 @@ six = "*" [[package]] name = "langfuse" -version = "3.3.4" +version = "3.6.1" description = "A client library for accessing langfuse" optional = false python-versions = "<4.0,>=3.9" groups = ["main"] files = [ - {file = "langfuse-3.3.4-py3-none-any.whl", hash = "sha256:15b9d20878cf39a48ca9cfa7e52acdfeb043603d3a9cef8cf451687a4d838c6b"}, - {file = "langfuse-3.3.4.tar.gz", hash = "sha256:e5df4e7284298990b522e02a1dc6c3c72ebc4a7a411dc7d39255fb8c2e5a7c3a"}, + {file = "langfuse-3.6.1-py3-none-any.whl", hash = "sha256:134e0007fcfdd9fb70b491c882bb431c8095b3f5cc5e865756f46a2abd3675a2"}, + {file = "langfuse-3.6.1.tar.gz", hash = "sha256:eac27ee5bbd8d05e7d665e822e0efb36766b20fe281930ff040f47eb22cc1b69"}, ] [package.dependencies] @@ -4202,8 +4202,8 @@ fastembed-gpu = ["fastembed-gpu (>=0.7,<0.8)"] [[package]] name = "rag-core-api" -version = "1.0.1" -description = "The core of the rag-template." +version = "v3.2.0" +description = "The rag-core-api contains the API layer for the RAG template for document retrieval, question answering, knowledge base management in the vector database and more." optional = false python-versions = "^3.13" groups = ["main"] @@ -4214,15 +4214,15 @@ develop = true datasets = "^3.5.1" dependency-injector = "^4.46.0" deprecated = "^1.2.18" -fastapi = "^0.116.0" +fastapi = "^0.118.0" fastembed = "^0.7.0" flashrank = "^0.2.10" -langchain-community = "0.3.27" +langchain-community = "0.3.30" langchain-ollama = "^0.3.2" langchain-qdrant = "^0.2.0" langchain-text-splitters = ">=0.3.9" langdetect = "^1.0.9" -langfuse = "3.3.4" +langfuse = "3.6.1" langgraph = "^0.6.0" openai = "^1.77.0" pillow = "^11.2.1" @@ -4232,7 +4232,7 @@ qdrant-client = "^1.14.2" rag-core-lib = {path = "../rag-core-lib", develop = true} ragas = "^0.3.0" requests-oauthlib = "^2.0.0" -uvicorn = "^0.35.0" +uvicorn = "^0.37.0" [package.source] type = "directory" @@ -4240,8 +4240,8 @@ url = "../../libs/rag-core-api" [[package]] name = "rag-core-lib" -version = "1.0.1" -description = "The perfect rag template" +version = "v3.2.0" +description = "The rag-core-lib contains the shared components of at least two of the rag libs." optional = false python-versions = "^3.13" groups = ["main"] @@ -4252,10 +4252,10 @@ develop = true deprecated = "^1.2.18" flashrank = "^0.2.10" langchain = "^0.3.25" -langchain-community = "0.3.27" -langchain-core = "0.3.74" +langchain-community = "0.3.30" +langchain-core = "0.3.77" langchain-openai = "^0.3.27" -langfuse = "3.3.4" +langfuse = "3.6.1" oauthlib = "^3.2.2" openai = "^1.77.0" pydantic = "^2.11.4" @@ -4411,14 +4411,14 @@ files = [ [[package]] name = "requests" -version = "2.32.4" +version = "2.32.5" description = "Python HTTP for Humans." optional = false -python-versions = ">=3.8" +python-versions = ">=3.9" groups = ["main"] files = [ - {file = "requests-2.32.4-py3-none-any.whl", hash = "sha256:27babd3cda2a6d50b30443204ee89830707d396671944c998b5975b031ac2b2c"}, - {file = "requests-2.32.4.tar.gz", hash = "sha256:27d0316682c8a29834d3264820024b62a36942083d52caf2f14c0591336d3422"}, + {file = "requests-2.32.5-py3-none-any.whl", hash = "sha256:2462f94637a34fd532264295e186976db0f5d453d1cdd31473c85a6a161affb6"}, + {file = "requests-2.32.5.tar.gz", hash = "sha256:dbba0bac56e100853db0ea71b82b4dfd5fe2bf6d3754a8893c3af500cec7d7cf"}, ] [package.dependencies] @@ -4912,14 +4912,14 @@ zstd = ["zstandard (>=0.18.0)"] [[package]] name = "uvicorn" -version = "0.35.0" +version = "0.37.0" description = "The lightning-fast ASGI server." optional = false python-versions = ">=3.9" groups = ["main"] files = [ - {file = "uvicorn-0.35.0-py3-none-any.whl", hash = "sha256:197535216b25ff9b785e29a0b79199f55222193d47f820816e7da751e9bc8d4a"}, - {file = "uvicorn-0.35.0.tar.gz", hash = "sha256:bc662f087f7cf2ce11a1d7fd70b90c9f98ef2e2831556dd078d131b96cc94a01"}, + {file = "uvicorn-0.37.0-py3-none-any.whl", hash = "sha256:913b2b88672343739927ce381ff9e2ad62541f9f8289664fa1d1d3803fa2ce6c"}, + {file = "uvicorn-0.37.0.tar.gz", hash = "sha256:4115c8add6d3fd536c8ee77f0e14a7fd2ebba939fed9b02583a97f80648f9e13"}, ] [package.dependencies] diff --git a/services/rag-backend/pyproject.toml b/services/rag-backend/pyproject.toml index e0b032dd..07703e44 100644 --- a/services/rag-backend/pyproject.toml +++ b/services/rag-backend/pyproject.toml @@ -1,7 +1,7 @@ [tool.poetry] -name = "rag-usecase-example" -version = "0.1.0" -description = "" +name = "rag-backend-usecase-example" +version = "3.2.0" +description = "This example demonstrates the use of the rag-core-lib and how to replace components of its dependency container." authors = ["STACKIT Data and AI Consulting "] [tool.poetry.dependencies] @@ -88,4 +88,3 @@ skip_gitignore = true [tool.pylint] max-line-length = 120 -