Skip to content

Terms and condition now comes from elevate - #15

Merged
kiranharidas187 merged 4 commits into
ELEVATE-Project:release-1.1.0from
darshilbabel:drop_8_fixes
Jul 13, 2026
Merged

Terms and condition now comes from elevate#15
kiranharidas187 merged 4 commits into
ELEVATE-Project:release-1.1.0from
darshilbabel:drop_8_fixes

Conversation

@KUNALTEMPEST

@KUNALTEMPEST KUNALTEMPEST commented Jul 9, 2026

Copy link
Copy Markdown

Summary by CodeRabbit

  • New Features
    • T&C acceptance is now synced with Elevate and reflected in profile views; it can be updated from the app.
    • Elevate access token support expanded: use a configured cookie or the X-auth-token request header.
  • Bug Fixes
    • T&C acceptance now defaults to false when Elevate data is unavailable (instead of an incorrect placeholder).
    • T&C acceptance updates now require an access token; failures return an error response.
  • Improvements
    • Knowledge-base retrieval sent to the AI now includes explicit retrieved-content provenance markers, with clearer messaging when no results are found.

@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f56df5d0-ad13-4e63-a921-661b966cc5f2

📥 Commits

Reviewing files that changed from the base of the PR and between 6e91a59 and 174cd8d.

📒 Files selected for processing (1)
  • chatbot/services/response_handlers/base_response_handler.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • chatbot/services/response_handlers/base_response_handler.py

📝 Walkthrough

Walkthrough

Terms and conditions state now flows through Elevate profile APIs and access-token-based views. Profile responses use boolean defaults, and knowledge-base results include explicit provenance wrappers.

Changes

Elevate TNC State Propagation

Layer / File(s) Summary
Elevate profile utils: fetch, upsert, update TNC state
chatbot/utils/elevate/profile_utils.py
Fetch and upsert operations propagate has_accepted_tnc, while profile updates optionally send the acceptance state to Elevate.
API views: access token helper and TNC view updates
chatbot/views/api_views.py
Tokens are read from a configured cookie or X-auth-token; profile retrieval reads TNC state from Elevate, and acceptance updates Elevate with missing-token and update-error responses.
Shikshalokam profile view default fix
shikshalokam/views/profile_views.py
has_accepted_tnc defaults to False when absent from profile details.

Knowledge-Base Result Provenance

Layer / File(s) Summary
Knowledge-base response wrapping
chatbot/services/response_handlers/base_response_handler.py
Knowledge-base results use repository or none provenance wrappers through a shared formatting helper.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant apiViews as api_views
  participant profileUtils as profile_utils
  participant Elevate

  Client->>apiViews: accept_tnc_view request
  apiViews->>apiViews: _get_access_token()
  alt token missing
    apiViews-->>Client: 400 error response
  else token present
    apiViews->>profileUtils: update_elevate_profile(has_accepted_terms_and_conditions=True)
    profileUtils->>Elevate: update profile request
    Elevate-->>profileUtils: response
    profileUtils-->>apiViews: result
    apiViews-->>Client: is_tnc_accepted True
  end
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: Elevate now becomes the source of truth for terms-and-conditions acceptance.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@KUNALTEMPEST

Copy link
Copy Markdown
Author

@CodeRabbit review

@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
chatbot/views/api_views.py (1)

13-28: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider extracting _get_access_token to a shared utility.

The same access-token retrieval logic (cookie fallback to X-auth-token header) is duplicated inline in shikshalokam/views/profile_views.py:13-15. Extracting _get_access_token to a shared module would eliminate the duplication and ensure consistent token-retrieval behavior across both view files.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@chatbot/views/api_views.py` around lines 13 - 28, The access-token lookup
logic in _get_access_token is duplicated in multiple view modules, so move this
helper into a shared utility and have both api_views and profile_views call the
same function. Keep the existing behavior of checking the
ACCESS_TOKEN_COOKIE_KEY cookie first and then falling back to the X-auth-token
header so token retrieval stays consistent across the codebase.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@chatbot/views/api_views.py`:
- Around line 295-303: The accept_tnc_view flow is treating Elevate updates as
successful even when update_elevate_profile fails. Update accept_tnc_view to
inspect the return value from update_elevate_profile and only return the success
response when the Elevate profile update actually succeeds; if it returns an
empty result or otherwise indicates failure, respond with an error instead. Use
the existing update_elevate_profile and accept_tnc_view symbols to locate the
change, and consider making update_elevate_profile surface failures more
explicitly so callers can distinguish real success from a swallowed exception.

---

Nitpick comments:
In `@chatbot/views/api_views.py`:
- Around line 13-28: The access-token lookup logic in _get_access_token is
duplicated in multiple view modules, so move this helper into a shared utility
and have both api_views and profile_views call the same function. Keep the
existing behavior of checking the ACCESS_TOKEN_COOKIE_KEY cookie first and then
falling back to the X-auth-token header so token retrieval stays consistent
across the codebase.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 34ed2adb-dab3-4a22-b05d-8bdbec661e5e

📥 Commits

Reviewing files that changed from the base of the PR and between ee2aa67 and 5ac8179.

📒 Files selected for processing (3)
  • chatbot/utils/elevate/profile_utils.py
  • chatbot/views/api_views.py
  • shikshalokam/views/profile_views.py

Comment thread chatbot/views/api_views.py Outdated
…"repository|none"> provenance markers before they enter the LLM transcript.
@KUNALTEMPEST

Copy link
Copy Markdown
Author

@coderabbitai review please check new pushed changes

@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown

@KUNALTEMPEST Sure, triggering a review of the newly pushed changes now.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
chatbot/services/response_handlers/base_response_handler.py (1)

540-542: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider escaping text to prevent premature wrapper closure.

If retrieved chunk text contains the literal </retrieved_content>, it would prematurely close the provenance wrapper in the LLM transcript. While this is only a prompt hint (not parsed as structured data), a malformed wrapper could confuse the LLM about source boundaries. This is low-risk given current data sources but worth noting for future robustness.

🛡️ Optional defensive escaping
 def _wrap_retrieved_content(self, text, source):
     """Wrap tool-retrieved text in an explicit provenance marker before it enters the transcript."""
+    # Prevent chunk text from prematurely closing the wrapper
+    safe_text = text.replace('</retrieved_content>', '</retrieved_content_>')
     return f'<retrieved_content source="{source}">\n{text}\n</retrieved_content>'
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@chatbot/services/response_handlers/base_response_handler.py` around lines 540
- 542, Update _wrap_retrieved_content to defensively escape or neutralize any
literal </retrieved_content> sequence in text before interpolating it into the
provenance wrapper, while preserving the retrieved content as much as possible.
Ensure the generated opening and closing markers remain unambiguous in the LLM
transcript.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@chatbot/services/response_handlers/base_response_handler.py`:
- Around line 529-533: Update the fallback text passed to
_wrap_retrieved_content in the source='none' branch so it does not encourage an
immediate general-knowledge response before web search is attempted. Instruct
the LLM to use web search if available, and only otherwise respond from general
knowledge when appropriate, while preserving the no-hallucination guidance.

---

Nitpick comments:
In `@chatbot/services/response_handlers/base_response_handler.py`:
- Around line 540-542: Update _wrap_retrieved_content to defensively escape or
neutralize any literal </retrieved_content> sequence in text before
interpolating it into the provenance wrapper, while preserving the retrieved
content as much as possible. Ensure the generated opening and closing markers
remain unambiguous in the LLM transcript.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3f96e82b-e784-4ea9-b8f8-a0a8e28da024

📥 Commits

Reviewing files that changed from the base of the PR and between 5ac8179 and 6e91a59.

📒 Files selected for processing (2)
  • chatbot/services/response_handlers/base_response_handler.py
  • chatbot/views/api_views.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • chatbot/views/api_views.py

Comment thread chatbot/services/response_handlers/base_response_handler.py
@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown

@KUNALTEMPEST Sure, triggering a review of the newly pushed changes now.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@KUNALTEMPEST

Copy link
Copy Markdown
Author

@coderabbitai review please check new pushed changes and resolve any comments that are left opened

@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown

@KUNALTEMPEST Sure, I'll trigger a review of the newly pushed changes and resolve the open review comments.

✅ Action performed

Comments resolved. Approval is disabled; enable reviews.request_changes_workflow to allow explicit top-level @coderabbitai resolve or @coderabbitai approve commands.


Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@kiranharidas187
kiranharidas187 merged commit c5f0b58 into ELEVATE-Project:release-1.1.0 Jul 13, 2026
1 check 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