Skip to main content

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.

Reason this release was yanked:

dependency to old version of internal lib rag-core-lib

Project description

rag-core-api

High-level API layer for the STACKIT RAG-Template. It transforms its own primitives and those from rag-core-lib into a production-ready FastAPI surface, exposing chat, evaluation, and document-management endpoints used by 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.
  • 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 settings so LLMS, embeddings, retries, and Langfuse behave the same way across services.

Installation

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
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

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 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

from rag_core_api.main import app as perfect_rag_app

Delivers a full functional API. See services/rag-backend/main.py and 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 for shared logic. Run poetry run pytest and the configured linters before opening a PR. For further instructions see the Contributing Guide.

License

Licensed under the project license. See the root LICENSE file.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rag_core_api-4.1.0.tar.gz (38.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rag_core_api-4.1.0-py3-none-any.whl (66.9 kB view details)

Uploaded Python 3

File details

Details for the file rag_core_api-4.1.0.tar.gz.

File metadata

  • Download URL: rag_core_api-4.1.0.tar.gz
  • Upload date:
  • Size: 38.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.13.11 Linux/6.11.0-1018-azure

File hashes

Hashes for rag_core_api-4.1.0.tar.gz
Algorithm Hash digest
SHA256 9a2a54dc70030dd6ef260474e86edb75d0107edd20ef79d878b1d21d82ab9f87
MD5 a1ab2362e8447f1d9c43a950d70d12ee
BLAKE2b-256 615d72db745f3f1262d472706fb005ba22a6acc0ab9632db6fe61b3c72c64f7e

See more details on using hashes here.

File details

Details for the file rag_core_api-4.1.0-py3-none-any.whl.

File metadata

  • Download URL: rag_core_api-4.1.0-py3-none-any.whl
  • Upload date:
  • Size: 66.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.13.11 Linux/6.11.0-1018-azure

File hashes

Hashes for rag_core_api-4.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0fb89f4c9ef1ea0efe1c408ca373564d7732d125c84341ac7588b4ecb07a26fa
MD5 bebc4cc03b2f31e02e110cef517f8e68
BLAKE2b-256 370f9a4d0b2e2202509cb116e87f58958aef25a61e945995fe218a4055216000

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page