Skip to content
Open
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
36 changes: 36 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
=== AGENTS.md ===

# ACG Protocol

Audited Context Generation (ACG) Protocol — a dual-layer standard for veracity assurance in RAG systems. Python-based project for grounding facts and verifying reasoning.

## Directory Structure

README.md
Usage.md
requirements.txt
AGENTS.md
docs/
ACG_PROTOCOL.md — Core ACG protocol specification
UGVP_PROTOCOL.md — Universal Grounding & Verification Protocol (Layer 1)
RSVP_PROTOCOL.md — Reasoning & Synthesis Verification Protocol (Layer 2)
src/
agent.py — Main agent entry point / inference
config.py — Configuration
evaluation_data.py — Evaluation data helpers
indexer.py — Chunk + SHI indexer for URLs
mongodb_client.py — MongoDB client for store/retrieve
ragas_evaluator.py — RAGAS evaluation integration
ugvp_protocol.py — UGVP protocol implementation
utils.py — Utility functions

## Stack

Python 3.12+, MongoDB, aiohttp, google-generativeai, RAGAS

## Commands

Setup: python -m venv venv && source venv/bin/activate && pip install -r requirements.txt
Index: python src/indexer.py --sentences_per_chunk 5 <url>
Agent: python src/agent.py
Tests: pytest (if configured)
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ click==8.3.0
distro==1.9.0
dnspython==2.8.0
docstring_parser==0.17.0
fastuuid==0.13.5
fastuuid==0.14.0
filelock==3.19.1
frozenlist==1.8.0
fsspec==2025.9.0
Expand Down Expand Up @@ -44,11 +44,11 @@ langchain-community
langchain-litellm
langchain-google-vertexai
langchain-google-genai
litellm
litellm==1.85.5
MarkupSafe==3.0.3
mcp==1.16.0
multidict==6.7.0
openai==2.2.0
openai==2.20.0
opentelemetry-api==1.37.0
opentelemetry-instrumentation==0.58b0
opentelemetry-instrumentation-threading==0.58b0
Expand Down
6 changes: 3 additions & 3 deletions src/evaluation_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ async def get_evaluation_data() -> List[Dict[str, Any]]:
reference_answer = agent_answer

evaluation_data.append({
"question": question,
"contexts": verified_contexts,
"answer": agent_answer,
"user_input": question,
"retrieved_contexts": verified_contexts,
"response": agent_answer,
"reference": reference_answer,
})

Expand Down
11 changes: 6 additions & 5 deletions src/ragas_evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from datasets import Dataset
from ragas import evaluate
from ragas.metrics import (
from ragas.metrics.collections import (
faithfulness,
answer_relevancy,
context_recall,
Expand All @@ -25,9 +25,9 @@ async def run_ragas_evaluation(data: List[Dict[str, Any]]):
Runs RAGAS evaluation on the provided dataset using Google Gemini via ChatGoogleGenerativeAI.

@param data: A list of dictionaries, where each dictionary contains:
'question': The user query.
'contexts': A list of retrieved contexts.
'answer': The generated answer.
'user_input': The user query.
'retrieved_contexts': A list of retrieved contexts.
'response': The generated answer.
'reference': The ground truth answer (single string).
"""
if not data:
Expand Down Expand Up @@ -59,7 +59,8 @@ async def run_ragas_evaluation(data: List[Dict[str, Any]]):
context_recall,
context_precision,
],
llm=ragas_llm
llm=ragas_llm,
embeddings=ragas_embeddings,
)
log.info("RAGAS evaluation completed.")
log.info(result.to_pandas().to_json(orient="records", indent=2))
Expand Down