Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/pyright-type-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Pyright Type Check

on:
pull_request:
branches: ["*"]
push:
branches: ["*"]

jobs:
pyright:
name: Pyright Type Check
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version-file: '.python-version'

- name: Set up uv
uses: astral-sh/setup-uv@v6

- name: Install dependencies (locked)
run: uv sync --frozen

- name: Run Pyright
run: uv run pyright
28 changes: 28 additions & 0 deletions .github/workflows/pytest-testcases-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Pytest Testcases Check

on:
pull_request:
branches: ["*"] # run on PRs to any branch
push:
branches: [main, dev, testing, wip] # optional; expand to ["*"] if you want all pushes

jobs:
pytest-testcases:
name: Pytest Testcases Check
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version-file: '.python-version'

- name: Set up uv
uses: astral-sh/setup-uv@v6

# Format check only — fails if files are not formatted
- name: Run test cases using Pytest
run: uv run pytest tests
28 changes: 28 additions & 0 deletions .github/workflows/ruff-format-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Ruff Format Check

on:
pull_request:
branches: ["*"] # run on PRs to any branch
push:
branches: ["*"] # optional; expand to ["*"] if you want all pushes

jobs:
ruff-format:
name: Ruff Format Check
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version-file: '.python-version'

- name: Set up uv
uses: astral-sh/setup-uv@v6

# Format check only — fails if files are not formatted
- name: Ruff format check
run: uvx ruff format --check .
28 changes: 28 additions & 0 deletions .github/workflows/ruff-lint-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Ruff Lint Check

on:
pull_request:
branches: ["*"] # run on PRs to any branch
push:
branches: ["*"] # optional; broaden to ["*"] if desired

jobs:
ruff:
name: Ruff Lint & Format Check
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version-file: '.python-version'

- name: Set up uv
uses: astral-sh/setup-uv@v6

# Lint: exits non-zero on violations -> job fails
- name: Ruff lint
run: uvx ruff check --output-format=github .
20 changes: 9 additions & 11 deletions .github/workflows/uv-env-check.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: Environment Check (uv sync)
name: UV Environment Check

on:
pull_request:
branches: [wip, dev, testing, main]
branches: ["*"]
push:
branches: [wip, dev, testing, main]
branches: ["*"]

jobs:
checks:
Expand All @@ -15,16 +15,14 @@ jobs:
uses: actions/checkout@v4

- name: Setup uv (with cache)
uses: astral-sh/setup-uv@v3
uses: astral-sh/setup-uv@v6
with:
enable-cache: true
version: "0.8.15"

# If you commit .python-version, this ensures the exact interpreter is available
- name: Pin Python
run: |
uv python install 3.12.10
uv python pin 3.12.10
uv run python -c "import sys; print(sys.version)"
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version-file: '.python-version'

# The authoritative guard: MUST match uv.lock and Python markers
- name: Sync (frozen)
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ For more help, check the [uv documentation](https://docs.astral.sh/uv/)

- Located in `.github/workflows/uv-env-check.yml`

- This GitHub actions check runs to check whether there are any conflicts between the lockfile and pyproject.toml. If it fails
- This GitHub actions check runs to check whether there are any conflicts between the lockfile and pyproject.toml. If it fails, then there has been some dependency update to the pyproject.toml without updating the lockfile

### Type check for Python

Expand Down
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# BYK-RAG (Retrieval-Augmented Generation Module)

The **BYK-RAG Module** is part of the Burokratt ecosystem, designed to provide **retrieval-augmented generation (RAG)** capabilities for Estonian government digital services. It ensures reliable, multilingual, and compliant AI-powered responses by integrating with multiple LLM providers, syncing with knowledge bases, and exposing flexible configuration and monitoring features for administrators.

---

## Features

- **Configurable LLM Providers**
- Support for AWS Bedrock, Azure AI, Google Cloud, OpenAI, Anthropic, and self-hosted open-source LLMs.
- Admins can create "connections" and switch providers/models without downtime.
- Models searchable via dropdown with cache-enabled indicators.

- **Knowledge Base Integration**
- Continuous sync with central knowledge base (CKB).
- Last sync timestamp displayed in UI.
- LLMs restricted to answering only from CKB content.
- “I don’t know” payload returned when confidence is low.

- **Citations & Transparency**
- All responses are accompanied with **clear citations**.

- **Analytics & Monitoring**
- External **Langfuse dashboard** for API usage, inference trends, cost analysis, and performance logs.
- Agencies can configure cost alerts and view alerts via LLM Alerts UI.
- Logs integrated with **Grafana Loki**.
44 changes: 43 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,46 @@ version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = "==3.12.10"
dependencies = []
dependencies = [
"pyright>=1.1.404",
"pytest>=8.4.1",
]

[tool.pyright]
# --- Environment & discovery ---
pythonVersion = "3.12.10" # Target Python semantics (pattern matching, typing features, stdlib types).
venvPath = "." # Where virtual envs live relative to repo root.
venv = ".venv" # The specific env name uv manages (uv sync creates .venv).

# --- What to analyze ---
include = ["src", "tests"] # Top-level packages & tests to check.
exclude = [
"**/.venv", "**/__pycache__", "build", "dist", ".git",
".ruff_cache", ".mypy_cache"
]

# --- Global strictness ---
typeCheckingMode = "strict" # Enforce full strict mode repo-wide (see notes below).
useLibraryCodeForTypes = true # If a lib lacks stubs, inspect its code to infer types where possible.

# Make the most common "loose" mistakes fail fast in strict mode.
# You can tune these individually if you need a temporary carve-out.
reportMissingTypeStubs = "error" # Untyped third-party libs must have type info (stubs or inline).
reportUnknownVariableType = "error" # Vars with unknown/implicit Any are not allowed.
reportUnknownMemberType = "error" # Members on unknowns are not allowed.
reportUnknownArgumentType = "error" # Call arguments can't be unknown.
reportUnknownLambdaType = "error" # Lambda params must be typed in strict contexts.
reportImplicitOptional = "error" # T | None must be explicit; no silent Optional.
reportMissingTypeArgument = "error" # Generic types must specify their parameters.
reportIncompatibleVariableOverride = "error" # Subclass fields must type-refine correctly.
reportInvalidTypeVarUse = "error" # Catch misuse of TypeVar/variance.
reportUntypedFunctionDecorator = "error" # Decorators must be typed (prevents Any leakage).
reportUnusedVariable = "error" # Ditto; promote to "error" if you want hard hygiene.
reportUnusedImport = "warning" # Hygiene: warn, but don’t fail builds.


# Tests often deserialize lots of data and patch frameworks; keep them strict,
# but relax "missing stubs" so untyped test-only libs don’t block you.
[[tool.pyright.overrides]]
module = "tests/**"
reportMissingTypeStubs = "warning"
1 change: 1 addition & 0 deletions main.py → src/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
def main():
""
print("Hello from rag-module!")


Expand Down
1 change: 1 addition & 0 deletions tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This folder contains all the testcases for the Python code
6 changes: 6 additions & 0 deletions tests/test_dummy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# tests/test_smoke.py
def test_smoke():
"""
This is a dummy to test ensure the CI check works before actual testcases are written
"""
assert 1 + 1 == 2
102 changes: 102 additions & 0 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.