-
Notifications
You must be signed in to change notification settings - Fork 213
Log /api/chat streaming output #1244
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
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Codex <[email protected]>
WalkthroughBoth files are enhanced with logging instrumentation. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Pre-merge checks❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
holmes/utils/stream.py (1)
137-150: Consider usinglogging.exceptionfor better error diagnostics.The exception handling correctly creates and logs SSE error messages. However, line 138 uses
logging.error(e)which doesn't include the stack trace. Usinglogging.exceptionwould provide better debugging information.🔎 Suggested improvement
except Exception as e: - logging.error(e) + logging.exception("Error in stream_chat_formatter") if "Model is getting throttled" in str(e): # happens for bedrock sse_message = create_rate_limit_error_message(str(e))As per static analysis hints, this change would provide stack traces for unexpected errors, making debugging easier.
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
holmes/utils/stream.pyserver.py
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.py: ALWAYS place Python imports at the top of the file, not inside functions or methods
Use Ruff for formatting and linting code
Type hints are required for all Python code
Files:
holmes/utils/stream.pyserver.py
🧬 Code graph analysis (1)
server.py (1)
holmes/core/models.py (1)
ChatResponse(243-249)
🪛 Ruff (0.14.10)
holmes/utils/stream.py
137-137: Do not catch blind exception: Exception
(BLE001)
138-138: Use logging.exception instead of logging.error
Replace with exception
(TRY400)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
- GitHub Check: llm_evals
- GitHub Check: build (3.10)
- GitHub Check: build (3.12)
- GitHub Check: build (3.11)
- GitHub Check: build
🔇 Additional comments (4)
server.py (1)
403-411: Good addition of response logging for observability.The logging implementation aligns with the PR objectives. However, be aware that
response.model_dump()will serialize the entire ChatResponse, includingconversation_history,tool_calls, andmetadata, which could produce verbose logs.Please verify:
- The log volume is acceptable for production environments, especially with lengthy conversation histories.
- No sensitive data (PII, credentials, etc.) flows through conversation_history or metadata that shouldn't be logged.
holmes/utils/stream.py (3)
93-104: Excellent refactoring to consolidate the yield path.The introduction of the
sse_messagevariable and single yield point improves code maintainability and enables consistent logging for all event types. This structural change makes the streaming logic cleaner and more predictable.Also applies to: 117-121, 128-128
123-128: Great addition for streaming observability.The logging successfully implements the PR objective to log SSE responses while streaming. Each event is logged with its type and full message content, providing comprehensive visibility into the streaming flow.
130-136: Proper logging added for rate limit errors.The exception handler correctly creates the SSE error message, logs it, and yields it, maintaining consistency with the normal event flow.
Results of HolmesGPT evals
Legend
|
|
Dev Docker images are ready for this commit: Use this tag to pull the image for testing. gcloud auth configure-docker us-central1-docker.pkg.dev
docker pull us-central1-docker.pkg.dev/robusta-development/temporary-builds/holmes:3af9d54
docker tag us-central1-docker.pkg.dev/robusta-development/temporary-builds/holmes:3af9d54 me-west1-docker.pkg.dev/robusta-development/development/holmes-dev:3af9d54
docker push me-west1-docker.pkg.dev/robusta-development/development/holmes-dev:3af9d54Patch Helm values in one line (choose the chart you use):
helm upgrade --install holmesgpt ./helm/holmes \
--set registry=me-west1-docker.pkg.dev/robusta-development/development \
--set image=holmes-dev:3af9d54
helm upgrade --install robusta robusta/robusta \
--reuse-values \
--set holmes.registry=me-west1-docker.pkg.dev/robusta-development/development \
--set holmes.image=holmes-dev:3af9d54 |
Summary
Testing
Codex Task
Summary by CodeRabbit
Refactor
Chores
✏️ Tip: You can customize this high-level summary in your review settings.