[Phase 5] feat(ai): 법률 RAG 임베딩 적재 구현 - #25
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughImplements Phase 5 of the legal RAG pipeline: adds ChangesLegal Embedding Upsert Pipeline
Sequence Diagram(s)sequenceDiagram
actor CLI
participant main
participant write_legal_chunks
participant embed_legal_chunks
participant EmbeddingClient
participant SupabaseVectorClient
CLI->>main: --write --source <file>
main->>write_legal_chunks: prepared rows, embedding_client, vector_client
write_legal_chunks->>embed_legal_chunks: rows, embedding_client
loop per chunk row
embed_legal_chunks->>EmbeddingClient: embed_query(content)
EmbeddingClient-->>embed_legal_chunks: embedding vector
end
embed_legal_chunks-->>write_legal_chunks: rows with embeddings
write_legal_chunks->>SupabaseVectorClient: upsert_legal_document_chunks(embedded rows)
SupabaseVectorClient-->>write_legal_chunks: upserted count
write_legal_chunks-->>main: {chunks, upserted}
main-->>CLI: print summary, exit 0
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
backend-ai/tests/test_legal_ingestion_upsert.py (1)
172-190: 🧹 Nitpick | 🔵 Trivial | ⚡ Quick winAlign the test name with what is actually asserted.
At Line 172, the name says it verifies
prepare_legal_chunksdefaults embeddings toNone, but the test only asserts dry-run returns0. Rename it (or add assertions for the no-embedding invariant) to avoid misleading coverage.Proposed minimal fix
-def test_prepare_legal_chunks_still_defaults_to_no_embedding(tmp_path) -> None: +def test_dry_run_mode_returns_success(tmp_path) -> None:🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@backend-ai/tests/test_legal_ingestion_upsert.py` around lines 172 - 190, The test function test_prepare_legal_chunks_still_defaults_to_no_embedding has a misleading name that doesn't match its actual assertions. The test name suggests it verifies that prepare_legal_chunks defaults embeddings to None, but the test only asserts that main returns exit code 0. Either rename the test to accurately reflect what it actually validates (such as testing that dry-run succeeds) or add assertions that verify the no-embedding invariant by inspecting the output or chunks to confirm embeddings are indeed not included.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@backend-ai/app/clients/supabase_client.py`:
- Around line 66-107: The SQL upsert query in the legal_document_chunks insert
operation unconditionally updates the updated_at timestamp whenever a
content_hash conflict occurs, even if the incoming chunk data is identical to
the existing row. This breaks idempotent reruns since repeated ingestion mutates
rows unnecessarily. Add a WHERE clause to the DO UPDATE section that only
performs the update when at least one of the actual data fields (such as law_id,
law_name, article_no, article_title, effective_date, source_name, source_url,
chunk_index, content, embedding, or metadata_json) has actually changed compared
to the existing row values, ensuring that updated_at is only advanced when the
data genuinely differs from what is already stored.
---
Nitpick comments:
In `@backend-ai/tests/test_legal_ingestion_upsert.py`:
- Around line 172-190: The test function
test_prepare_legal_chunks_still_defaults_to_no_embedding has a misleading name
that doesn't match its actual assertions. The test name suggests it verifies
that prepare_legal_chunks defaults embeddings to None, but the test only asserts
that main returns exit code 0. Either rename the test to accurately reflect what
it actually validates (such as testing that dry-run succeeds) or add assertions
that verify the no-embedding invariant by inspecting the output or chunks to
confirm embeddings are indeed not included.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: ec0c3bcb-6c85-4af9-8a88-245c64659fd1
📒 Files selected for processing (4)
backend-ai/app/clients/supabase_client.pybackend-ai/scripts/ingest_legal_docs.pybackend-ai/tests/test_legal_ingestion_upsert.pyphases/ai-legal-rag/phase5-legal-embedding-upsert.md
변경 내용
연결 이슈
closes #24
테스트
Summary by CodeRabbit
Release Notes
New Features
--writemode to perform database writes and prints ingestion counts; dry-run remains safe and read-only.Tests
Documentation