Skip to content

Fix issues, optimize data flow and AI service robustness#149

Draft
google-labs-jules[bot] wants to merge 1 commit intomainfrom
fix-issues-optimize-data-flow-10700405334920891744
Draft

Fix issues, optimize data flow and AI service robustness#149
google-labs-jules[bot] wants to merge 1 commit intomainfrom
fix-issues-optimize-data-flow-10700405334920891744

Conversation

@google-labs-jules
Copy link
Contributor

This PR addresses several issues and optimizations:

  1. Security: Removed hardcoded Gemini API keys. The app now warns if the key is missing instead of crashing or using a leaked key.
  2. Robustness: Improved the AI JSON parsing logic to handle cases where the model returns Markdown or malformed JSON, preventing 500 errors.
  3. Performance: Removed redundant function calls in detection endpoints (infrastructure, flooding, vandalism) where a local model was called but the result was immediately overwritten by the CLIP model result.
  4. Code Quality: Refactored the issue serialization logic in backend/main.py into a reusable helper function and updated Pydantic schemas for better type clarity.
  5. Logging: Standardized logging during application startup.

Verified with existing tests.


PR created automatically by Jules for task 10700405334920891744 started by @RohanExploit

- Removed hardcoded API key in `backend/ai_service.py` and `backend/gemini_summary.py` in favor of env var check with graceful fallback.
- Improved JSON extraction robustness in `backend/ai_service.py` to handle markdown code blocks and partial JSON.
- Optimized `backend/main.py` detection endpoints by removing redundant local model calls when using CLIP.
- Refactored `get_recent_issues` in `backend/main.py` to use a helper `_serialize_issue` function for consistent `action_plan` handling.
- Updated `IssueResponse` schema to explicitly support `ActionPlan` or `dict`.
- Switched from `print` to `logger` for startup data loading messages.
@google-labs-jules
Copy link
Contributor Author

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@github-actions
Copy link

🙏 Thank you for your contribution, @google-labs-jules[bot]!

PR Details:

Quality Checklist:
Please ensure your PR meets the following criteria:

  • Code follows the project's style guidelines
  • Self-review of code completed
  • Code is commented where necessary
  • Documentation updated (if applicable)
  • No new warnings generated
  • Tests added/updated (if applicable)
  • All tests passing locally
  • No breaking changes to existing functionality

Review Process:

  1. Automated checks will run on your code
  2. A maintainer will review your changes
  3. Address any requested changes promptly
  4. Once approved, your PR will be merged! 🎉

Note: The maintainers will monitor code quality and ensure the overall project flow isn't broken.

@RohanExploit RohanExploit added the bug Something isn't working label Jan 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working size/s

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant