Skip to content

Release 1.0.0 - #3

Merged
kiranharidas187 merged 12 commits into
ELEVATE-Project:release-1.0.0from
darshilbabel:release-1.0.0
Jun 10, 2026
Merged

Release 1.0.0#3
kiranharidas187 merged 12 commits into
ELEVATE-Project:release-1.0.0from
darshilbabel:release-1.0.0

Conversation

@KUNALTEMPEST

@KUNALTEMPEST KUNALTEMPEST commented Jun 10, 2026

Copy link
Copy Markdown

Summary by CodeRabbit

  • New Features

    • Automatic chat session title generation using AI-powered bot
    • Quick-reply button translation for voice interactions
    • Profile management endpoints for retrieving user data and accepting terms of service
    • Language-specific document generation with translated labels and localized content
  • Improvements

    • Enhanced media type support with expanded file format compatibility
    • Improved user profile data persistence to maintain existing information

@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@KUNALTEMPEST, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 34 minutes and 11 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 493043e0-8ba9-42fe-967f-6b69ef17ceab

📥 Commits

Reviewing files that changed from the base of the PR and between 1d81d6f and e307ab5.

📒 Files selected for processing (1)
  • chatbot/views/drf_views.py
📝 Walkthrough

Walkthrough

This PR introduces LLM-driven chat session title generation via Celery, adds profile management APIs for onboarding workflows, and enhances multi-language support across document generation and message translations.

Changes

Session Title Generation

Layer / File(s) Summary
Schema and Model Updates
chatbot/models/company_models.py, chatbot/migrations/0085_*
Flow gains optional title_bot foreign key; migration creates the field on both flow and historicalflow with appropriate delete handlers and constraints.
Celery Task Implementation
chatbot/celery_tasks/title_tasks.py
New task loads ChatSession, invokes title bot LLM with guided messages, extracts title from tool call response, optionally translates via Voice provider, tracks token/cost usage in session.other_params, and persists the title.
ChatSession Model Refactor
chatbot/models/chat_models.py
Simplifies save_title() from multi-step LLM generation to a minimal setter that assigns/persists a provided title only when currently empty; removes LLM/translation/JSON-repair imports.
Consumer Integration
chatbot/consumers/async_base_consumer.py
Updates save_chat_session() to enqueue generate_session_title task asynchronously when a session exists and title is missing, using language derived from route.
Admin and Celery Config
chatbot/admin/company_admin.py, shikshalokam_mohini/celery_config.py
Adds title_bot to FlowAdmin raw_id_fields and Bot Configuration fieldset; registers title_tasks module in Celery autodiscovery.

Profile Management and Onboarding

Layer / File(s) Summary
API Endpoints
chatbot/views/api_views.py, chatbot/urls.py
Two new endpoints: GET /api/get-profile/ returns profile with computed is_tnc_accepted and is_profile_complete flags; PATCH /api/accept-tnc/ marks TNC acceptance. Both support profile ID or email lookup with company fallback.
Profile Tool Response Handler
chatbot/services/response_handlers/common_handler.py
Routes submit_user_context function calls to new profile tool handler; parses/persists profile fields to Profile and ProfileAddress, marks onboarding completion, injects context into llm_extra_content; filters private keys (_-prefixed) from other_params when storing extra_content.
Profile Params Merging
chatbot/utils/elevate/profile_utils.py
Incremental merge of elevate_profile_details into existing profile.other_params instead of upsert-time overwrite, preserving pre-existing metadata.

Multi-Language Support

Layer / File(s) Summary
Chip Translation
chatbot/celery_tasks/handle_message.py
New _translate_chips helper translates quick_reply_chips using text_translate_provider, preserves non-string chips, logs errors on failure; integrated into translate_and_send_message before chat payload emission.
Localized Document Generation
chatbot/utils/media_preview/media_creation.py
render_template_to_pdf() and create_docx_from_args() now accept language/display_filename parameters; load language-specific label constants from PDFTemplates, use localized headings (MIP sections, success indicators, references) and doc titles; _get_flow_title() helper derives document title with fallbacks.
Download File Translation
chatbot/services/response_handlers/common_handler.py
Translates LLM-generated argument string fields in download_file (except filename), computes translated display filename for non-English, passes language/display_filename to PDF/DOCX generation, stores only extra_content in persisted other_params instead of full function metadata.

Minor Updates

  • ProfileAddress.str() now returns profile.first_name when available, falls back to profile.email.
  • CompanyStateMachine lookup in translate_message changed from get() to filter().first() to handle missing/multiple rows gracefully.
  • Settings path for secrets.json updated to /home/ubuntu/saathi-backend/config/secrets.json.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

A rabbit hops through translation's gleam,
Titles born from the LLM dream—
Profiles now speak in any tongue,
While documents sing, localized and young! 🐰✨

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 38.46% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'Release 1.0.0' is vague and does not describe the specific technical changes made in this pull request. Consider providing a more descriptive title that summarizes the key features or changes, such as 'Add profile APIs, session title generation, and PDF translation support' or similar.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 and usage tips.

@KUNALTEMPEST

Copy link
Copy Markdown
Author

@CodeRabbit review

@coderabbitai

coderabbitai Bot commented Jun 10, 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: 6

🧹 Nitpick comments (3)
chatbot/consumers/async_consumer.py (1)

253-255: ⚡ Quick win

Inconsistent error handling for missing CompanyStateMachine.

Lines 112-123 explicitly catch DoesNotExist and log an error when CompanyStateMachine is missing, while this change silently returns None. Although the guard on line 257 prevents a crash, the lack of logging here may hide misconfigurations where a state machine is expected but missing.

📝 Proposed fix to add logging when state machine is missing
 state_machine = CompanyStateMachine.objects.filter(
     company_bot=self.company_bot, step=chat_session.current_step
 ).first()
+
+if not state_machine:
+    logger.warning(
+        f"CompanyStateMachine not found for bot_id={self.company_bot.id}, "
+        f"step={chat_session.current_step} in translate_message. "
+        f"Defaulting to translation without state-specific text_conversion_type."
+    )
🤖 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/consumers/async_consumer.py` around lines 253 - 255, The change uses
CompanyStateMachine.objects.filter(...).first() which can return None without
logging; add an error log when state_machine is None (same place where
DoesNotExist was previously handled) that includes identifying info like
self.company_bot (or company_bot id) and chat_session.current_step, then return
None as before; locate the state_machine assignment and insert a
logger/process_logger.error call (matching the existing logging convention in
this file) to report the missing CompanyStateMachine.
chatbot/celery_tasks/title_tasks.py (1)

77-77: 💤 Low value

Consider unpacking instead of list concatenation.

Ruff suggests using unpacking syntax for better readability and performance.

♻️ Proposed refactor
     response = call_llm_gateway(
-        messages=[system_msg] + list(messages),
+        messages=[system_msg, *messages],
         provider=company_bot.provider,
         model=company_bot.llm_model,
         params=build_gateway_params(company_bot),
🤖 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/celery_tasks/title_tasks.py` at line 77, Replace the list
concatenation "messages=[system_msg] + list(messages)" with the clearer
unpacking form "messages=[system_msg, *messages]" in title_tasks.py; this keeps
the same semantics but is more readable and avoids the extra list()
allocation—ensure "messages" is an iterable (if it's a generator that must be
consumed elsewhere, convert it before unpacking) and update the call site where
system_msg and messages are combined in the task function.
chatbot/views/api_views.py (1)

215-222: ⚡ Quick win

Redundant bool() calls and alias.

Lines 215-217 and 219-221 wrap .get('...', False) in bool(), but the get() method already returns the boolean False as the default, making the outer bool() redundant. Additionally, line 222 creates is_profile_complete as an alias for is_onboarding_completed without adding semantic value.

♻️ Simplify boolean extraction and remove alias
-        is_tnc_accepted = bool(
-            profile.other_params and profile.other_params.get('is_tnc_accepted', False)
-        )
-
-        is_onboarding_completed = bool(
-            profile.other_params and profile.other_params.get('is_onboarding_completed', False)
-        )
-        is_profile_complete = is_onboarding_completed
+        is_tnc_accepted = (profile.other_params or {}).get('is_tnc_accepted', False)
+        is_profile_complete = (profile.other_params or {}).get('is_onboarding_completed', False)

Then update line 236 to use is_profile_complete directly without the intermediate is_onboarding_completed variable.

🤖 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 215 - 222, Remove the redundant
bool() wrappers around profile.other_params.get(...) by assigning
is_tnc_accepted = profile.other_params and
profile.other_params.get('is_tnc_accepted', False) and is_profile_complete =
profile.other_params and profile.other_params.get('is_onboarding_completed',
False); delete the intermediate is_onboarding_completed variable and then update
any later usages (e.g., the reference at the previous line 236) to use
is_profile_complete directly instead of is_onboarding_completed.
🤖 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/celery_tasks/title_tasks.py`:
- Around line 114-123: The translation can fail because text_translate_provider
is called with voice_provider possibly None but without the company_bot
fallback; update the call in title_tasks.py so it passes company_bot (the same
variable used to query Voice.objects.filter) into text_translate_provider along
with voice_provider, message_body=output_title, target_language=language and
source_language='en' and keep the existing check of translated.get('status') ==
200 to assign output_title; this ensures text_translate_provider can resolve a
fallback provider when Voice.objects.filter(...) returns None.

In `@chatbot/models/chat_models.py`:
- Around line 28-31: The save_title method signature was changed and now breaks
callers; restore backward compatibility by changing save_title to accept
optional parameters: def save_title(self, title=None, language=None) and keep
the existing behavior of only setting and saving self.title when a non-empty
title is provided (leave language unused for now). Update the body to check if
title is truthy and self.title is falsy before assigning and calling
self.save(update_fields=['title']) so calls like save_title(),
save_title(language=...), and save_title(title=...) all work without raising
TypeError; keep the method name save_title to match callers in
chatbot/utils/story_utils/story_utils.py,
chatbot/scripts/meghaPTM/create_story_script.py,
chatbot/consumers/base_consumer.py and tests.

In `@chatbot/models/geo_models.py`:
- Around line 28-29: The __str__ in the model returns str(self.profile.email)
which yields "None" when email is None; update the __str__ method (in the class
defining __str__) to check for a real email and provide a user-friendly fallback
(e.g., return self.profile.first_name or self.profile.email or "<no email>" or
another meaningful identifier like self.profile.username or id) so that if
self.profile.email is None it does not display the literal "None".

In `@chatbot/utils/media_preview/media_creation.py`:
- Around line 272-273: Docstring for _get_flow_title incorrectly mentions
constants_json['title'] while the function uses constants_json['doc_title'];
update the docstring to reference constants_json['doc_title'] (or change the key
access to 'title' if intended) so the description matches the implementation,
and ensure the function name _get_flow_title and the constants_json key name are
consistent.

In `@chatbot/views/api_views.py`:
- Around line 204-212: Both endpoints (get_profile_view, accept_tnc_view) share
non-deterministic fallback logic using Company.objects.order_by('id').first()
when company_slug is missing; extract that into a helper (e.g.,
resolve_company(company_slug, require_slug_for_email=False)) and replace the
duplicated code. Implement resolve_company to: 1) return
Company.objects.get(slug=company_slug) if company_slug provided; 2) if not
provided, check an env var DEFAULT_COMPANY_SLUG and return that company if set;
3) otherwise, when require_slug_for_email is True (used by endpoints that lookup
by email like get_profile_view), raise/return a 400 response forcing the caller
to supply company_slug; else return a clear 404/error instead of silently using
Company.objects.order_by('id').first(). Update get_profile_view and
accept_tnc_view to call resolve_company and handle the helper's 400/404
semantics accordingly.

In `@shikshalokam_mohini/settings.py`:
- Around line 28-33: The repo still contains legacy
"shikshalokam-mohini-service" references that must be renamed to
"saathi-backend" to avoid broken deploys; update occurrences referenced by
load_secrets (paths_to_try in load_secrets) and then update docker-compose.yml
(image names and log volume paths), README.md and docs/setup/developer_setup.md
(local project paths/examples), and manage.spec / celery_worker.spec (replace
/home/ubuntu/shikshalokam-mohini-service/... with
/home/ubuntu/saathi-backend/...) so all image names, volume mounts, and
documented paths consistently use saathi-backend. Ensure exact string
replacements preserve surrounding syntax (YAML, spec files, markdown) and run a
quick grep to verify no remaining "shikshalokam-mohini-service" tokens.

---

Nitpick comments:
In `@chatbot/celery_tasks/title_tasks.py`:
- Line 77: Replace the list concatenation "messages=[system_msg] +
list(messages)" with the clearer unpacking form "messages=[system_msg,
*messages]" in title_tasks.py; this keeps the same semantics but is more
readable and avoids the extra list() allocation—ensure "messages" is an iterable
(if it's a generator that must be consumed elsewhere, convert it before
unpacking) and update the call site where system_msg and messages are combined
in the task function.

In `@chatbot/consumers/async_consumer.py`:
- Around line 253-255: The change uses
CompanyStateMachine.objects.filter(...).first() which can return None without
logging; add an error log when state_machine is None (same place where
DoesNotExist was previously handled) that includes identifying info like
self.company_bot (or company_bot id) and chat_session.current_step, then return
None as before; locate the state_machine assignment and insert a
logger/process_logger.error call (matching the existing logging convention in
this file) to report the missing CompanyStateMachine.

In `@chatbot/views/api_views.py`:
- Around line 215-222: Remove the redundant bool() wrappers around
profile.other_params.get(...) by assigning is_tnc_accepted =
profile.other_params and profile.other_params.get('is_tnc_accepted', False) and
is_profile_complete = profile.other_params and
profile.other_params.get('is_onboarding_completed', False); delete the
intermediate is_onboarding_completed variable and then update any later usages
(e.g., the reference at the previous line 236) to use is_profile_complete
directly instead of is_onboarding_completed.
🪄 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: f39e7bbb-fb3f-4a3e-ac8d-95c364206d61

📥 Commits

Reviewing files that changed from the base of the PR and between f2739ed and 1d81d6f.

📒 Files selected for processing (16)
  • chatbot/admin/company_admin.py
  • chatbot/celery_tasks/handle_message.py
  • chatbot/celery_tasks/title_tasks.py
  • chatbot/consumers/async_base_consumer.py
  • chatbot/consumers/async_consumer.py
  • chatbot/migrations/0085_flow_title_bot_historicalflow_title_bot_and_more.py
  • chatbot/models/chat_models.py
  • chatbot/models/company_models.py
  • chatbot/models/geo_models.py
  • chatbot/services/response_handlers/common_handler.py
  • chatbot/urls.py
  • chatbot/utils/elevate/profile_utils.py
  • chatbot/utils/media_preview/media_creation.py
  • chatbot/views/api_views.py
  • shikshalokam_mohini/celery_config.py
  • shikshalokam_mohini/settings.py

Comment thread chatbot/celery_tasks/title_tasks.py
Comment thread chatbot/models/chat_models.py
Comment thread chatbot/models/geo_models.py
Comment thread chatbot/utils/media_preview/media_creation.py
Comment thread chatbot/views/api_views.py
Comment thread shikshalokam_mohini/settings.py
@KUNALTEMPEST

Copy link
Copy Markdown
Author

@CodeRabbit review

@coderabbitai

coderabbitai Bot commented Jun 10, 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.

@bhavana-venugopal

Copy link
Copy Markdown

reviewed

@kiranharidas187
kiranharidas187 merged commit 2491f60 into ELEVATE-Project:release-1.0.0 Jun 10, 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.

3 participants