Skip to content

ci: add optional AuditAI RAG quality smoke suite#2

Open
iZenDeveloper wants to merge 1 commit into
hnamyud:mainfrom
iZenDeveloper:ci/auditai-quality-gate
Open

ci: add optional AuditAI RAG quality smoke suite#2
iZenDeveloper wants to merge 1 commit into
hnamyud:mainfrom
iZenDeveloper:ci/auditai-quality-gate

Conversation

@iZenDeveloper

Copy link
Copy Markdown

ci: thêm AuditAI — gate chống ảo giác (RAG)

Chào bạn, dự án RAG/chatbot của bạn rất thú vị!

Mình đã chạy thử AuditAI (CLI + GitHub Action mã nguồn mở) để đánh giá chống ảo giác (hallucination) và vài kiểm tra an toàn cơ bản.

Kết quả baseline (máy local)

Metric Mean Threshold Pass
Faithfulness 0.04 0.75
Answer relevancy 0.24 0.70
Prompt injection 1.00 0.90
  • Tổng case: 20 · Target errors: 0
  • Exit reason: metric_below_threshold:faithfulness · judge calls: 38
  • Judge: xai/grok-4.3 · tokens in/out/total = 17645/1538/19183
  • Chi tiết: file report trong PR (tests/auditai/auditai-out/ hoặc artifact CI)

Lưu ý: Đây là kiểm thử kỹ thuật với dataset lấy từ README/docs public, không phải đánh giá toàn bộ sản phẩm của bạn.

PR này thêm gì?

  • tests/auditai/auditai.yml — cấu hình gate
  • tests/auditai/dataset.json — ~20 câu hỏi smoke
  • .github/workflows/auditai.yml — chạy AuditAI (mặc định có thể chỉ workflow_dispatch để tránh tốn API bất ngờ)
  • (nếu có) adapter HTTP nếu app chưa expose JSON API

Từ nay mỗi lần bạn (hoặc CI) chạy workflow, pipeline sẽ tự test bảo vệ chất lượng trả lời.

Cách chạy lại

pip install "git+https://github.com/iZenDeveloper/auditai.git@v0.1.1"
export OPENAI_API_KEY=...   # hoặc XAI_API_KEY + judge.provider=xai
# start app / adapter nếu cần
auditai run --config tests/auditai/auditai.yml

Badge (tuỳ chọn — chỉ khi bạn muốn)

[![Audited by AuditAI](https://img.shields.io/badge/🛡️_Audited_by-AuditAI-7c5cfc?style=flat-square)](https://github.com/iZenDeveloper/auditai)

Mình sẵn sàng chỉnh threshold, dataset, hoặc bỏ workflow nếu bạn chỉ muốn CLI local.

Cảm ơn bạn đã open-source! 🙏

Scaffold dataset, mock adapter, and docs for optional faithfulness / relevancy / prompt-injection checks via AuditAI.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces an AuditAI testing scaffold, including configuration files, a mock HTTP adapter, a GitHub Actions workflow example, and a dataset of 20 test cases. The review feedback highlights two key areas for improvement: first, the questions in dataset.json are systematically truncated (ending in …?), which should be restored to their full text to prevent negative impacts on LLM evaluation metrics; second, the mock_adapter.py lacks error handling when parsing the incoming JSON request body, which could lead to server crashes if invalid payloads are received.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

},
{
"id": "q1",
"question": "Theo tài liệu dự án, nội dung sau nói gì: Hệ thống chatbot AI hỗ trợ tra cứu và tư vấn Nghị định 168/2024/NĐ-CP và Luật Đường bộ 2024, sử dụng kiến trúc RAG (Retrieval-Augmented Gene…?",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Các câu hỏi trong file dataset.json đang bị cắt cụt (truncated) một cách hệ thống ở cuối câu và kết thúc bằng ký tự …? (ví dụ: Gene…?, phá…?, e…?, OA…?, yam…?, Citation…?, Xóa…?, con…?). Điều này có thể do công cụ hoặc script tự động thu thập dữ liệu bị giới hạn độ dài ký tự.

Việc câu hỏi bị cắt cụt giữa chừng không chỉ làm giảm tính chuyên nghiệp của bộ dữ liệu thử nghiệm mà còn có thể ảnh hưởng tiêu cực đến kết quả đánh giá của LLM Judge (đặc biệt là chỉ số answer_relevancyfaithfulness). Bạn nên cập nhật lại các câu hỏi này thành câu hỏi đầy đủ, không bị cắt cụt.

Comment on lines +21 to +24
def do_POST(self):
n = int(self.headers.get("Content-Length", 0))
body = json.loads(self.rfile.read(n) or b"{}")
q = str(body.get("question") or "")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Trong phương thức do_POST của mock_adapter.py, việc đọc và phân tích cú pháp JSON từ request body (json.loads(self.rfile.read(n) or b"{}")) chưa được bao bọc trong khối xử lý ngoại lệ. Nếu request gửi đến chứa dữ liệu JSON không hợp lệ hoặc header Content-Length không phải là số nguyên hợp lệ, mock server sẽ ném ra ngoại lệ (json.JSONDecodeError hoặc ValueError) và bị crash hoặc phản hồi lỗi không kiểm soát.

Bạn nên bao bọc đoạn mã này trong khối try-except để trả về phản hồi 400 Bad Request một cách an toàn và giúp bộ test hoạt động ổn định hơn.

    def do_POST(self):
        try:
            n = int(self.headers.get("Content-Length", 0))
            body = json.loads(self.rfile.read(n) or b"{}")
        except (ValueError, json.JSONDecodeError):
            self.send_response(400)
            self.end_headers()
            self.wfile.write(b"Invalid JSON or Content-Length")
            return
        q = str(body.get("question") or "")

@iZenDeveloper

Copy link
Copy Markdown
Author

Chào maintainer 👋

Mình follow-up nhẹ PR này — scaffold opt-in (dataset từ docs public + mock adapter / workflow example), không bắt buộc merge.

Baseline local dùng mock target yếu + LLM-as-judge (Grok): quality metrics fail trung thực (injection pass). Ý là gate chạy được; số đẹp cần API/app thật, không greenwash.

Committed config: judge.provider=mock + AUDITAI_TARGET_URL (opt-in).

Nếu không phù hợp repo, cứ close/request changes — mình chỉnh hoặc rút PR ngay. Cảm ơn bạn đã open-source! 🙏

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.

2 participants