Skip to content

Feat/evaluation#58

Open
swaploard wants to merge 10 commits into
Finntegrate:mainfrom
swaploard:feat/evaluation
Open

Feat/evaluation#58
swaploard wants to merge 10 commits into
Finntegrate:mainfrom
swaploard:feat/evaluation

Conversation

@swaploard

Copy link
Copy Markdown

Description

This PR solves #25 by implementing an evaluation harness. Introduces a comprehensive evaluation framework for Tapio’s RAG pipeline, designed to systematically measure and improve retrieval quality, answer correctness, safety, and conversational performance. The goal is to move beyond ad-hoc testing and establish a repeatable, production-grade evaluation setup that provides clear signals on system performance and regression.

Checklist

  • I ran uv run pytest and all tests pass
  • I ran uv run prek run --all-files (or uv run ruff check . and uv run ruff check . --fix) and addressed any issues
  • I ran uv run mypy tapio and uv run pyrefly check and addressed any issues
  • New/changed code meets the project's 80% coverage guideline (uv run pytest --cov=tapio)
  • I updated README.md if this PR changes user-facing behavior

Related issue

Additional context

At the core of this change are two complementary evaluation suites: DeepEval and Ragas. DeepEval is used for rubric-based evaluation of correctness, retrieval quality, and safety using structured scoring criteria, while Ragas focuses on retrieval and generation metrics such as faithfulness, answer relevancy, and context precision/recall. Together, they provide both qualitative and quantitative coverage of the system, ensuring that improvements (or regressions) can be detected reliably across different dimensions of the RAG pipeline.

To support this, the PR introduces structured datasets and a domain taxonomy covering key Finnish immigration topics such as Kela, DVV, residence permits, taxation, and work rights. These datasets are paired with retrieval anchors and relevance labels, enabling precise evaluation of whether the system is retrieving the correct documents. In addition, a conversational test framework has been added to evaluate multi-turn interactions, where the system must maintain context across turns and produce consistent, grounded responses.

Another major addition is LangSmith tracing, which provides visibility into the internal behavior of the RAG pipeline. Retrieval steps are now instrumented to log document metadata such as chunk IDs, source URLs, and content previews, making it easier to debug failures and understand why a particular answer was generated. This is fully integrated into the application lifecycle and can be configured via environment variables.

swaploard added 10 commits July 7, 2026 18:13
…and related policies

- Introduced new JSON datasets for residence permits, taxes, and work rights, including test cases for various personas.
- Created expected documents and relevance labels for retrieval processes.
- Defined domains, personas, and policies in YAML format to structure the evaluation framework.
- Enhanced integration of information regarding immigration, taxation, and work rights for third-country nationals in Finland.
…data extraction

- Added logging for assistant responses and queries in RAG orchestrator.
- Implemented structured metadata extraction for documents in tracing utilities.
- Introduced logging of retrieved document metadata and content previews in document retrieval service.
- Added unit tests for metadata extraction and tracing functionalities.
@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@swaploard, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 34 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 5bab2f3d-41f7-4011-b38a-2333311f9784

📥 Commits

Reviewing files that changed from the base of the PR and between 5436f2a and 5a40e0e.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (67)
  • .env.example
  • .gitignore
  • mise.toml
  • pyproject.toml
  • pytest.ini
  • tapio-evaluation/datasets/citizenship.jsonl
  • tapio-evaluation/datasets/dvv.jsonl
  • tapio-evaluation/datasets/edge_cases.jsonl
  • tapio-evaluation/datasets/healthcare.jsonl
  • tapio-evaluation/datasets/housing.jsonl
  • tapio-evaluation/datasets/kela.jsonl
  • tapio-evaluation/datasets/multi_turn_conversations.jsonl
  • tapio-evaluation/datasets/residence_permits.jsonl
  • tapio-evaluation/datasets/taxes.jsonl
  • tapio-evaluation/datasets/work_rights.jsonl
  • tapio-evaluation/evals/README.md
  • tapio-evaluation/evals/__init__.py
  • tapio-evaluation/evals/conftest.py
  • tapio-evaluation/evals/test_conversational.py
  • tapio-evaluation/evals/test_correctness.py
  • tapio-evaluation/evals/test_retrieval.py
  • tapio-evaluation/evals/test_safety.py
  • tapio-evaluation/evaluation_spec.md
  • tapio-evaluation/ragas_eval/README.md
  • tapio-evaluation/ragas_eval/__init__.py
  • tapio-evaluation/ragas_eval/conftest.py
  • tapio-evaluation/ragas_eval/test_answer.py
  • tapio-evaluation/ragas_eval/test_comprehensive.py
  • tapio-evaluation/ragas_eval/test_retrieval.py
  • tapio-evaluation/retrieval/expected_documents.json
  • tapio-evaluation/retrieval/relevance_labels.json
  • tapio-evaluation/rubrics/correctness.md
  • tapio-evaluation/rubrics/retrieval.md
  • tapio-evaluation/rubrics/safety.md
  • tapio-evaluation/scripts/release_version.py
  • tapio-evaluation/taxonomy/domains.yaml
  • tapio-evaluation/taxonomy/personas.yaml
  • tapio-evaluation/taxonomy/policies.yaml
  • tapio-evaluation/versions/changelog.md
  • tapio-evaluation/versions/v1.0/datasets/citizenship.json
  • tapio-evaluation/versions/v1.0/datasets/dvv.json
  • tapio-evaluation/versions/v1.0/datasets/edge_cases.json
  • tapio-evaluation/versions/v1.0/datasets/family_reunification.jsonl
  • tapio-evaluation/versions/v1.0/datasets/healthcare.json
  • tapio-evaluation/versions/v1.0/datasets/housing.json
  • tapio-evaluation/versions/v1.0/datasets/kela.json
  • tapio-evaluation/versions/v1.0/datasets/residence_permits.json
  • tapio-evaluation/versions/v1.0/datasets/taxes.json
  • tapio-evaluation/versions/v1.0/datasets/work_rights.json
  • tapio-evaluation/versions/v1.0/retrieval/expected_documents.json
  • tapio-evaluation/versions/v1.0/retrieval/relevance_labels.json
  • tapio-evaluation/versions/v1.0/taxonomy/domains.yaml
  • tapio-evaluation/versions/v1.0/taxonomy/personas.yaml
  • tapio-evaluation/versions/v1.0/taxonomy/policies.yaml
  • tapio/app.py
  • tapio/config/config_models.py
  • tapio/config/settings.py
  • tapio/core/__init__.py
  • tapio/core/tracing.py
  • tapio/evaluation/__init__.py
  • tapio/evaluation/conversational_test_case.py
  • tapio/factories.py
  • tapio/services/document_retrieval_service.py
  • tapio/services/llm_service.py
  • tapio/services/rag_orchestrator.py
  • tests/core/test_tracing.py
  • tests/test_conversational_test_case.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
C Security Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

💡 Need a hand with PR review? Try Gitar by Sonar!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant