refactor(apps): eliminate RAG app boilerplate across 14 apps#371
Closed
luojiyin1987 wants to merge 5 commits into
Closed
refactor(apps): eliminate RAG app boilerplate across 14 apps#371luojiyin1987 wants to merge 5 commits into
luojiyin1987 wants to merge 5 commits into
Conversation
…lass - Create apps/chat_export_rag.py (153 lines) with unified: _find_exports, _add_specific_arguments, load_data, per-source max_items loop - chatgpt_rag.py: 187 → 50 lines (-137) - claude_rag.py: 190 → 51 lines (-139) - Net: -123 lines, config-driven via constructor params
…urce iteration - Add _foreach_source() to BaseRAGExample — handles max_items tracking, per-source printing, and exception handling in one place - Migrate chat_export_rag, browser_rag, email_rag, wechat_rag to use it - Each app's load_data() drops the verbose per-source loop (~20 lines each) replacing it with a single _foreach_source() call - Net: +81/-124 lines across 5 files
…_ boilerplate - Add BaseRAGExample.main() classmethod — prints header + runs app - Add example_queries param to BaseRAGExample.__init__ - Add _print_header() method (overridable for platform warnings, help text) - All 14 app __main__ blocks reduced to 1-line ClassName.main() - Fix ChatExportRAG to pass example_queries through to BaseRAGExample - Net: +110/-171 lines across 15 files
…import out of loop
Author
|
pr 太大了, 我先关闭了 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #370
Summary
Eliminates ~230 lines of duplicated boilerplate across the 14 RAG example apps.
Changes
Phase 1: Merge chatgpt_rag ↔ claude_rag
ChatExportRAGshared base class with unified_find_exports,_add_specific_arguments,load_data, per-sourcemax_itemsloopchatgpt_rag.py: 187 → 36 lines,claude_rag.py: 190 → 37 linesPhase 2: Extract per-source processing loop
_foreach_source()helper inBaseRAGExample— handlesmax_itemstracking, exception handling, progress printingmax_itemslogic now lives in ONE placePhase 3: Eliminate
__main__boilerplateClassName.main()classmethod +_print_header()inBaseRAGExampleexample_queriesparam moved to__init__if __name__ == "__main__"blocks → 1 line:ClassName.main()Line counts
No functional changes. 5 separate commits for easy review.