Commit 89cefb8
committed
refactor(chat_router): Extract prompt builder functions (Step 5)
- Extracted prompt building functions to backend/api/handlers/prompt_builder.py:
- get_validator_info_for_prompt()
- build_prompt_context_from_chat_request()
- truncate_user_message()
- get_transparency_disclaimer()
- build_minimal_philosophical_prompt()
- format_conversation_history()
- calculate_confidence_score()
- Added ValidatorInfo class to chat_config.py for validator defaults
- Updated chat_router.py to import and use new prompt builder functions
- Created comprehensive unit tests for prompt_builder.py (26 test cases)
- Reduced chat_router.py from ~8,983 LOC to 7,864 LOC (~1,119 lines removed)
This is Step 5 of the 10-step refactoring plan to reduce chat_router.py complexity.1 parent 6485d88 commit 89cefb8
5 files changed
Lines changed: 1529 additions & 1146 deletions
File tree
- backend/api
- config
- handlers
- routers
- tests/unit/handlers
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
85 | 93 | | |
86 | 94 | | |
87 | 95 | | |
| |||
94 | 102 | | |
95 | 103 | | |
96 | 104 | | |
| 105 | + | |
97 | 106 | | |
98 | 107 | | |
99 | 108 | | |
| |||
116 | 125 | | |
117 | 126 | | |
118 | 127 | | |
| 128 | + | |
| 129 | + | |
119 | 130 | | |
120 | 131 | | |
121 | 132 | | |
| |||
0 commit comments