-
Notifications
You must be signed in to change notification settings - Fork 4
fix: Remove arbitrary 10K char limit + fix datetime.utcnow() deprecation #547
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🚀 Development Environment OptionsThis repository supports Dev Containers for a consistent development environment. Option 1: GitHub Codespaces (Recommended)Create a cloud-based development environment:
Option 2: VS Code Dev Containers (Local)Use Dev Containers on your local machine:
Option 3: Traditional Local SetupSet up the development environment manually: # Clone the repository
git clone https://github.com/manavgup/rag_modulo.git
cd rag_modulo
git checkout fix/conversation-content-length-limit
# Initialize development environment
make dev-init
make dev-build
make dev-up
make dev-validateAvailable CommandsOnce in your development environment: make help # Show all available commands
make dev-validate # Validate environment setup
make test-atomic # Run atomic tests
make test-unit # Run unit tests
make lint # Run lintingServices AvailableWhen running
This automated message helps reviewers quickly set up the development environment. |
Pull Request Review: Fix Conversation Content Length LimitThank you for this PR! Overall, this is a solid fix that addresses real pain points with LLM response handling. Here's my detailed review: ✅ Strengths1. Well-Justified Changes
2. Python 3.12 Compatibility
3. Good Documentation
|
Code Review: PR #547 - Fix Message Content Length + datetime.utcnow() DeprecationSummaryThis PR addresses two important issues:
✅ Strengths1. Well-Documented Changes
2. Correct Technical ApproachMessage Length Fix (conversation_schema.py:237):
datetime.utcnow() Migration:
3. Context Pollution FixesThe PR includes critical bug fixes for conversation context pollution:
These fixes are production-critical and well-implemented. 🔍 Issues & Recommendations1. Critical: Message Length Validation GapLocation: The 100K limit is only validated in the Pydantic schema. Large messages could cause:
Recommendation: # Add early validation in conversation_service.py
MAX_MESSAGE_CONTENT_LENGTH = 100000 # Match schema limit
async def send_message_and_search(self, message_input: ConversationMessageInput) -> dict:
# Validate message size early
if len(message_input.content) > MAX_MESSAGE_CONTENT_LENGTH:
raise ValidationError(
f"Message content exceeds maximum length of {MAX_MESSAGE_CONTENT_LENGTH} characters. "
f"Got {len(message_input.content)} characters."
)Also verify:
2. Medium: Test Coverage IncompleteLocation: The new test file has only 3 tests (105 lines). Missing test cases:
Recommendation: @pytest.mark.asyncio
async def test_large_message_handling(service):
"""Test that 100K char messages are accepted, >100K rejected."""
large_message = "x" * 99999 # Just under limit
result = await service.enhance_question_with_context(
question=large_message,
conversation_context="context",
message_history=[]
)
assert result is not None
# Test rejection at boundary
oversized = "x" * 100001
with pytest.raises(ValidationError):
ConversationMessageInput(
session_id=uuid4(),
content=oversized,
role=MessageRole.USER,
message_type=MessageType.QUESTION
)3. Low: Documentation File SizeLocation: This file is excellent for understanding the fixes, but:
Reason: Root-level markdown files should be reserved for key project docs (README, CONTRIBUTING, etc.) 4. Low: Logging Improvements NeededLocation: The fixes are critical but lack instrumentation: # Add telemetry for monitoring
user_messages = [msg for msg in messages[-10:] if msg.role == MessageRole.USER]
logger.info(
"Context enhancement: filtered %d total messages to %d user messages",
len(messages[-10:]),
len(user_messages)
)
# Log deduplication
if len(deduped_history) < len(message_history):
logger.warning(
"Deduplication removed %d duplicate messages from history",
len(message_history) - len(deduped_history)
)5. Low: datetime.now(UTC) Import StyleLocation: Current: Alternative (more explicit): from datetime import datetime
from datetime import timezone
# Usage
datetime.now(timezone.utc)Both are valid, but 📊 Testing ResultsBased on PR description:
Recommendation: Run full test suite before merging: make test-all # Run all test categories
make coverage # Verify 60%+ coverage maintained
make lint # Ensure Ruff/MyPy pass🔒 Security ConsiderationsPositive:
Watch for:
🎯 Performance ImpactBefore fixes:
After fixes:
Estimated cost savings: ~60% reduction in token usage for multi-turn conversations 💰 ✅ Approval RecommendationStatus: This PR fixes critical production issues and is well-designed. However, recommend addressing:
📝 Final NotesStrengths:
Areas for improvement:
Great work on the thorough analysis and implementation! The context pollution fixes are particularly impressive - this will significantly improve conversation quality. 🎉 Reviewed by: Claude Code |
Code Review - PR #547SummaryThis PR addresses two important issues:
✅ Approved Changes1. Message Content Length FixFiles: Change: Increased Analysis:
Recommendation: Approve ✅ 2. Python 3.12 Datetime Deprecation FixFiles: Changes:
Analysis:
Examples reviewed:
Recommendation: Approve with minor suggestion ✅ 🔴 Critical IssuesIssue #1: Massive Analysis Document Should Not Be in PRFile: Problem:
Why this matters:
Recommendation: Remove from this PR ❌
Issue #2: Test File Constructor MismatchFile: Problem: Lines 25-29 show incorrect constructor signature: service = ConversationService(
search_service=mock_search,
conversation_repository=mock_repo,
llm_config_service=mock_llm_config
)Actual constructor ( def __init__(self, db: Session, settings: Settings):Analysis:
Recommendation: Remove test file from this PR ❌
|
0cfeeff to
5608ed0
Compare
✅ PR Cleaned Up - Ready for ReviewAddressed all review feedback by removing unrelated changes: Changes Made
What Remains (Core Fixes)This PR now focuses solely on the two stated objectives: ✅ Message Length Fix (
✅ Python 3.12 Datetime Deprecation (14 occurrences)
Files Changed
Testing
Status: Ready for final review and merge 🚀 |
Code Review: PR #547SummaryThis PR addresses a critical production issue where LLM responses exceeding 10,000 characters were causing validation errors. The changes are well-justified and properly scoped, fixing both the immediate issue and a Python 3.12 deprecation warning. ✅ Strengths
📋 Code Quality AssessmentSchema Changes (
|
**Critical Fix - Message Content Length**: - Increased ConversationMessageInput.content max_length from 10,000 to 100,000 characters - **Problem**: LLM responses frequently exceed 10K chars, especially with: - Chain of Thought reasoning (adds 8K-16K chars) - Code examples and technical documentation - Long document summaries - Claude can output ~32,000 chars, GPT-4 ~16,000 chars - **Impact**: Users getting 404 errors with "string_too_long" validation failures - **Solution**: Raised limit to 100,000 chars (safe for all LLM use cases) **Deprecation Fix - datetime.utcnow()**: - Replaced all datetime.utcnow() with datetime.now(UTC) - **Files**: conversation_schema.py (9 occurrences), conversation_service.py (4 occurrences) - **Reason**: datetime.utcnow() deprecated in Python 3.12+ - **Migration**: Added UTC import, changed: - datetime.utcnow() → datetime.now(UTC) - default_factory=datetime.utcnow → default_factory=lambda: datetime.now(UTC) **Error Resolved**: ``` ValidationError: 1 validation error for ConversationMessageInput content String should have at most 10000 characters [type=string_too_long] ``` **Testing**: ✅ Schema validation works with 50,000+ char content ✅ datetime.now(UTC) produces timezone-aware timestamps ✅ No breaking changes to API **Files Changed**: - backend/rag_solution/schemas/conversation_schema.py - backend/rag_solution/services/conversation_service.py Fixes: User-reported runtime error in conversation service Related: Python 3.12 deprecation warnings (Issue #520) Signed-off-by: manavgup <manavg@gmail.com>
5608ed0 to
65af7bf
Compare
Code Review - PR #547SummaryThis PR addresses two critical issues:
✅ Strengths1. Well-Justified Changes
2. Comprehensive Deprecation Fix
3. Database Compatibility
4. Test Coverage
5. No Breaking Changes
🔍 Observations & Recommendations1. Security Considerations
|
Problem
Users experiencing runtime errors when LLM responses exceed 10,000 characters:
Root Cause: Arbitrary 10K character limit in
ConversationMessageInput.contentfieldImpact:
Changes
1. Message Content Length Fix
backend/rag_solution/schemas/conversation_schema.pymax_lengthfrom 10,000 → 100,000 characterscontext_windowlimit (50,000 chars)2. Python 3.12 Deprecation Fix
conversation_schema.py,conversation_service.pydatetime.utcnow()withdatetime.now(UTC)datetime.utcnow()deprecated in Python 3.12+datetime.utcnow()→datetime.now(UTC)default_factory=datetime.utcnow→default_factory=lambda: datetime.now(UTC)Testing
✅ Schema validation works with 50,000+ character content
✅
datetime.now(UTC)produces timezone-aware timestamps✅ No breaking changes to API
✅ All imports valid
Files Changed
backend/rag_solution/schemas/conversation_schema.pybackend/rag_solution/services/conversation_service.pyRelated