From 91e311a51f982201c9903e38baaed9c4e54e8f42 Mon Sep 17 00:00:00 2001 From: Krishnatejaswi S Date: Sun, 22 Mar 2026 17:41:46 +0530 Subject: [PATCH 1/2] chore: ignore .worktrees directory --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 119b59a..c661ec2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +# --- Git worktrees --- +.worktrees/ + # --- Environment variables --- .env .env.local From 1232016780c3d11291d48f7deffe8cabeeacfe33 Mon Sep 17 00:00:00 2001 From: Krishnatejaswi S Date: Sun, 22 Mar 2026 17:42:58 +0530 Subject: [PATCH 2/2] fix: remove credential pattern from .env.example, read OLLAMA_HOST in embedding.py, fix exp08 JudgeClient silent mock MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - .env.example: replace inline URI-with-credentials comment (triggered GitHub secret scanner) with a plain description; no real credentials were present - embedding.py: read OLLAMA_HOST env var instead of hardcoding the URL, consistent with database_handlers.py, rag.py, and log_parser.py - experiments/08_rag_real_world: align JudgeClient with experiment 07 — raise ValueError on missing API keys instead of silently setting client=None, and return 0.0 with a warning on retry exhaustion instead of silent 0.5 --- .env.example | 9 ++--- backend/app/core/embedding.py | 4 ++- .../08_rag_real_world/run_experiment.py | 33 +++++++++++-------- 3 files changed, 27 insertions(+), 19 deletions(-) diff --git a/.env.example b/.env.example index c17e53e..f6a6128 100644 --- a/.env.example +++ b/.env.example @@ -4,10 +4,11 @@ # --------------------------------------------------------------------------- # Required: MongoDB connection URI -# If using the bundled docker-compose.yaml, use: -# MONGO_URI=mongodb://admin:changeme@localhost:27017/ -# For an external Atlas cluster: -# MONGO_URI=mongodb+srv://user:pass@cluster.mongodb.net/ +# If using the bundled docker-compose.yaml, set this to: +# mongodb://:@localhost:27017/ +# where MONGO_USERNAME and MONGO_PASSWORD match the values below. +# For an external Atlas cluster, set this to your Atlas connection string +# (found in the Atlas UI under "Connect > Drivers"). # --------------------------------------------------------------------------- MONGO_URI=mongodb://localhost:27017/ diff --git a/backend/app/core/embedding.py b/backend/app/core/embedding.py index 09255c5..13d066d 100644 --- a/backend/app/core/embedding.py +++ b/backend/app/core/embedding.py @@ -1,10 +1,12 @@ +import os from typing import List from .database_handlers import OllamaEmbeddingFunction class EmbeddingCreator: def __init__(self): + ollama_host = os.environ.get("OLLAMA_HOST", "http://localhost:11435") self.ef = OllamaEmbeddingFunction( - url="http://localhost:11435/api/embeddings", + url=f"{ollama_host}/api/embeddings", model_name="nomic-embed-text" ) diff --git a/experiments/08_rag_real_world/run_experiment.py b/experiments/08_rag_real_world/run_experiment.py index 4225724..57f5409 100644 --- a/experiments/08_rag_real_world/run_experiment.py +++ b/experiments/08_rag_real_world/run_experiment.py @@ -77,20 +77,25 @@ def _init_client(self): keys = os.environ.get("OPENAI_API_KEY", "").split(",") self.api_keys = [k.strip() for k in keys if k.strip()] if not self.api_keys: - print("WARN: OPENAI_API_KEY not set. Using mock judge.") - self.client = None - else: - from openai import OpenAI - self.client = OpenAI(api_key=self.api_keys[0]) + raise ValueError( + "OPENAI_API_KEY environment variable is not set or is empty. " + "Run: export OPENAI_API_KEY=your_key_here\n" + "Without a valid key, judge scores would be fabricated. Aborting." + ) + from openai import OpenAI + self.client = OpenAI(api_key=self.api_keys[0]) elif judge_type == "groq": keys = os.environ.get("GROQ_API_KEY", "").split(",") self.api_keys = [k.strip() for k in keys if k.strip()] if not self.api_keys: - self.client = None - else: - from groq import Groq - self.client = Groq(api_key=self.api_keys[0]) + raise ValueError( + "GROQ_API_KEY environment variable is not set or is empty. " + "Run: export GROQ_API_KEY=your_key_here\n" + "Without a valid key, judge scores would be fabricated. Aborting." + ) + from groq import Groq + self.client = Groq(api_key=self.api_keys[0]) def _rotate_key(self): """Rotate to next API key if available.""" @@ -114,10 +119,7 @@ def score(self, prediction: str, ground_truth: str) -> float: """Score prediction against ground truth.""" if not prediction or len(prediction.strip()) < 5: return 0.0 - - if not self.client: # Mock mode - return 0.5 - + prompt = f"""Compare these two root cause descriptions and rate their similarity from 0.0 to 1.0. Ground Truth: {ground_truth} @@ -134,7 +136,10 @@ def score(self, prediction: str, ground_truth: str) -> float: print(f" Judge attempt {attempt+1}/3 failed: {e}") time.sleep(2) - return 0.5 + # All retries exhausted — return 0.0 and warn rather than silently return 0.5 + print(f" WARNING: all scoring attempts failed for judge '{self.judge_name}'. " + f"Returning 0.0 (not a mock). Check API key and connectivity.") + return 0.0 def _call_judge(self, prompt: str) -> Optional[float]: judge_type = self.judge_config["type"]