Skip to content

Conversation

@satwikkansal
Copy link
Collaborator

@satwikkansal satwikkansal commented Jul 14, 2025

Description

Brief description of what this PR does and why.

Checklist

  • I have created an issue for this change (not mandatory for small changes)
  • My changes are to-the-point
  • Code is styled as the rest of the codebase and linting passes
  • I have tested my changes locally and they work as expected
  • I have updated the documentation (if needed)
  • I have reviewed the code myself once and I don't see any issues

Additional Notes

Any additional context or notes for reviewers.

@satwikkansal satwikkansal requested a review from Copilot July 14, 2025 13:56
@satwikkansal satwikkansal changed the title Suggestions Improve suggestions API Jul 14, 2025
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Jul 14, 2025

Deploying mxtoai-backend with  Cloudflare Pages  Cloudflare Pages

Latest commit: 25f1597
Status: ✅  Deploy successful!
Preview URL: https://14998d4f.mxtoai-backend.pages.dev
Branch Preview URL: https://suggestions.mxtoai-backend.pages.dev

View logs

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR centralizes suggestion count limits with new constants, updates the prompt and logic to use these limits, shifts error handling to HTTP exceptions, and enhances logging configuration.

  • Introduce MIN_SUGGESTIONS and MAX_SUGGESTIONS constants and update prompt templates and suggestion-building logic.
  • Change API error flows to raise HTTPException (403/500) instead of embedding error suggestions.
  • Update tests to expect at least 3 suggestions and verify HTTP status codes; make logs directory configurable and update Dockerfile.

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/test_suggestions.py Bumped expected minimum suggestions from 2 to 3 in tests.
tests/test_api.py Assert 403/500 status codes and check detail in error responses.
mxtoai/suggestions.py Added MIN/MAX constants, updated docs and suggestion-combining logic.
mxtoai/api.py Switched to raising HTTPException for whitelist and processing errors.
mxtoai/_logging.py Made logs directory configurable and guarded file handlers.
docker/api_server.dockerfile Create /app/logs directory for file logging.

gautamp8
gautamp8 previously approved these changes Jul 14, 2025
@satwikkansal satwikkansal merged commit a4f13e9 into master Jul 14, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants