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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ jobs:
run: uv sync --group dev

- name: ruff — check
run: uv run ruff check .
run: uv run ruff check app data evaluation frontend pipelines scripts vector_store

- name: ruff — format
run: uv run ruff format --check .
run: uv run ruff format --check app data evaluation frontend pipelines scripts vector_store

test:
name: Test
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
<h1 align="center">Global Retail Intelligence Engine
<br>
<!-- Version Badge - update on release (must match CHANGELOG.md) -->
<a href="https://github.com/kokou-egbewatt/re-llm_engineering/tags">
<img src="https://img.shields.io/github/v/tag/kokou-egbewatt/re-llm_engineering?label=version" alt="Version">
<a href="https://github.com/kokou-egbewatt/retail-intelligence/tags">
<img src="https://img.shields.io/github/v/tag/kokou-egbewatt/retail-intelligence?label=version" alt="Version">
</a>
</h1>
<p align="center">
<i>Advanced RAG pipeline for product search, regional pricing, policies, and secure querying across 11 markets.</i><br><br>
<a href="https://github.com/kokou-egbewatt/re-llm_engineering/actions/workflows/ci.yml">
<img src="https://github.com/kokou-egbewatt/re-llm_engineering/actions/workflows/ci.yml/badge.svg" alt="CI"/>
<a href="https://github.com/kokou-egbewatt/retail-intelligence/actions/workflows/ci.yml">
<img src="https://github.com/kokou-egbewatt/retail-intelligence/actions/workflows/ci.yml/badge.svg" alt="CI"/>
</a>
<img src="https://img.shields.io/badge/Python-3.11+-3776AB?style=flat-square&logo=python&logoColor=white" alt="Python"/>
<img src="https://img.shields.io/badge/FastAPI-009688?style=flat-square&logo=fastapi&logoColor=white" alt="FastAPI"/>
Expand Down
2 changes: 1 addition & 1 deletion app/api/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Chat API: POST /chat - accepts query and optional country, returns RAG response.
"""

from fastapi import APIRouter, HTTPException
from fastapi import APIRouter
from pydantic import BaseModel, Field

from app.rag.pipeline import run_rag
Expand Down
9 changes: 5 additions & 4 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@

from dotenv import load_dotenv

# Load .env from project root (parent of app/)
_env_path = Path(__file__).resolve().parent.parent / ".env"
load_dotenv(_env_path)

from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware

from app.api.chat import router as chat_router

# Load .env from project root (parent of app/)
_env_path = Path(__file__).resolve().parent.parent / ".env"
load_dotenv(_env_path)


app = FastAPI(
title="Global Retail Intelligence Engine",
description="RAG API for product search, regional pricing, and policy answers.",
Expand Down
2 changes: 1 addition & 1 deletion app/rag/hybrid_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def search(
bm25_scores = self._bm25.get_scores(tokenized_query)
order_bm25 = np.argsort(bm25_scores)[::-1][:vector_k]
indices_bm25 = order_bm25.tolist()
scores_bm25_list = bm25_scores.tolist()
_ = bm25_scores.tolist() # scores_bm25_list

# Reciprocal rank fusion: score = 1/(rank_vec) + 1/(rank_bm25)
rank_vec = {idx: r for r, idx in enumerate(indices_vec, 1)}
Expand Down
4 changes: 2 additions & 2 deletions app/rag/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import os
import re
from dataclasses import dataclass
from typing import Any, List, Optional
from typing import List, Optional

from app.guardrails.prompt_injection import detect_prompt_injection
from app.guardrails.security_filter import check_restricted_data
Expand Down Expand Up @@ -83,7 +83,7 @@ def _merge_retrieval_results(
for lst in result_lists:
for doc in lst:
doc_id = doc.get(id_key) or id(doc)
score = doc.get("score", 0.0)
_ = doc.get("score", 0.0) # score
if doc_id not in by_id or (doc.get("score") or 0) > (
by_id[doc_id].get("score") or 0
):
Expand Down
9 changes: 4 additions & 5 deletions scripts/run_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,19 @@
import sys
from pathlib import Path

from pipelines.indexing.build_vector_index import main as index_main
from pipelines.ingestion.clean_data import main as clean_main

# Add project root
project_root = Path(__file__).resolve().parent.parent
sys.path.insert(0, str(project_root))

from pipelines.indexing.build_vector_index import main as index_main
from pipelines.ingestion.clean_data import main as clean_main


def main():
# Ingest Task 1 xlsx if present (adds GH-K-001, UK-W-202 Policy, NL-L-5042, etc.)
task_xlsx = project_root / "Task 1_ Global Retail Intelligence Engine Data.xlsx"
if task_xlsx.exists():
from pipelines.ingestion.ingest_task_data import \
main as ingest_task_main
from pipelines.ingestion.ingest_task_data import main as ingest_task_main

ingest_task_main()
print("Re-running clean to merge task data...")
Expand Down
4 changes: 2 additions & 2 deletions scripts/run_retrieval.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
import sys
from pathlib import Path

from app.rag.hybrid_search import HybridRetriever

# Quiet HuggingFace / sentence-transformers logs when running as CLI
os.environ.setdefault("TRANSFORMERS_VERBOSITY", "error")
os.environ.setdefault("HF_HUB_DISABLE_PROGRESS_BARS", "1")

project_root = Path(__file__).resolve().parent.parent
sys.path.insert(0, str(project_root))

from app.rag.hybrid_search import HybridRetriever


def main():
query = "How much does the Solar Inverter cost?"
Expand Down
Loading