Skip to content

Release 1.0.0 - #5

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

Release 1.0.0#5
kiranharidas187 merged 6 commits into
ELEVATE-Project:release-1.0.0from
darshilbabel:release-1.0.0

Conversation

@KUNALTEMPEST

@KUNALTEMPEST KUNALTEMPEST commented Jun 17, 2026

Copy link
Copy Markdown

Summary by CodeRabbit

  • New Features

    • Added support for Openrouter as an LLM provider.
    • Enabled custom LLM model configuration for gateway calls.
  • Bug Fixes

    • Improved text-to-speech handling of time patterns.
    • Fixed document generation formatting for duration fields.
  • Improvements

    • Enhanced admin dashboard visibility with additional chat columns.
    • Optimized chat session status tracking logic.
    • Improved template rendering for prompt context data.

… all prompt context fields

- ProfileSerializer: expose password as write-only field so it flows through to the model's save() hashing logic (was excluded entirely before)
- PromptBuilder: apply Jinja2 rendering to company_bot.context, state_machine.context, and completion_criteria (not just tag_context); extract shared _render_template helper and compute profile/address context once
- audio_provider_utils: prevent TTS from reading "1: 30"-style patterns as time by replacing colon with comma
@coderabbitai

coderabbitai Bot commented Jun 17, 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 45 minutes and 58 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ 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.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9a16bea5-17ad-4e4f-bd8c-6c4c7ca7ceb8

📥 Commits

Reviewing files that changed from the base of the PR and between d50766d and 00e3088.

📒 Files selected for processing (2)
  • chatbot/services/response_handlers/base_response_handler.py
  • chatbot/utils/audio_provider_utils.py
📝 Walkthrough

Walkthrough

This PR refactors chat session status tracking so ChatSession.session_status is updated instead of CompanyChat.status, with bot-type-specific logic using Max('step') for last-step detection. It adds OPENROUTER to LLMProvider and a _get_effective_model helper for custom model overrides, centralizes Jinja template rendering in PromptBuilder, and applies minor fixes to admin columns, ProfileSerializer password handling, TTS preprocessing, and DOCX duration output.

Changes

Session Status Refactor, LLM Routing, Prompt Builder, and Utility Fixes

Layer / File(s) Summary
OpenRouter enum and ProfileSerializer password
chatbot/models/enums.py, chatbot/serializer/profile_serializer.py
LLMProvider gains an OPENROUTER entry; ProfileSerializer.Meta switches from excluding password to marking it write_only and not required.
Effective model selection in BaseResponseHandler
chatbot/services/response_handlers/base_response_handler.py
New _get_effective_model helper returns other_params['custom_model'] when set, otherwise llm_model; both non-stream and streaming gateway calls are updated to use it.
Centralized Jinja rendering in PromptBuilder
chatbot/services/core/prompt_builder.py
_render_template added to handle UndefinedError uniformly; build_system_prompt builds a shared context_data with profile and address; _render_tag_context signature changed to accept context_data.
Session status logic in AsyncBaseConsumer
chatbot/consumers/async_base_consumer.py
determine_company_chat_status refactored to branch on SIMPLE vs. non-SIMPLE bots using Max('step') for last-step detection; update_last_chat_status targets ChatSession.session_status; new update_session_status database-sync method added.
Conditional status update in AsyncSocketConsumer
chatbot/consumers/async_consumer.py
create_chat_session returns (cs, cs_created); receive calls determine_company_chat_status_async and update_session_status only when session pre-existed; non-auth path gates update_session_status on IN_PROGRESS.
Admin list_display additions
chatbot/admin/company_admin.py
CompanyChatAdmin adds status; ChatSessionAdmin adds updated_at to list display and both get_list_display branches.
TTS and DOCX utility fixes
chatbot/utils/audio_provider_utils.py, chatbot/utils/media_preview/media_creation.py
strip_markdown_for_tts normalizes digit: digit patterns; DOCX duration output drops the duration_prefix label.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant AsyncSocketConsumer
    participant AsyncBaseConsumer
    participant ChatSession

    Client->>AsyncSocketConsumer: WebSocket receive(message)
    AsyncSocketConsumer->>AsyncSocketConsumer: create_chat_session() → (cs, cs_created)
    alt session already existed
        AsyncSocketConsumer->>AsyncBaseConsumer: determine_company_chat_status_async()
        AsyncBaseConsumer->>ChatSession: query existing chats & Max(step)
        ChatSession-->>AsyncBaseConsumer: status result
        AsyncBaseConsumer-->>AsyncSocketConsumer: company_chat_status
        AsyncSocketConsumer->>AsyncBaseConsumer: update_session_status(company_chat_status)
        AsyncBaseConsumer->>ChatSession: save session_status (if not COMPLETED)
    end
    alt non-auth path & status == IN_PROGRESS
        AsyncSocketConsumer->>AsyncBaseConsumer: update_session_status(IN_PROGRESS)
        AsyncBaseConsumer->>ChatSession: save session_status
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐇 A bunny hopped through sessions galore,
Tracking each status from STARTED to more,
OpenRouter joined the LLM crew,
Templates now render with context brand new,
And TTS won't read "1: 30" as time—
Every small fix makes the chatbot sublime! 🌟

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 30.00% 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 extremely vague and generic. It does not describe any actual technical changes in the changeset, only indicating a version bump without meaningful context. Consider a more descriptive title that highlights key changes, such as 'Add OpenRouter provider, fix password field serialization, and improve chat status handling' 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 17, 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: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
chatbot/consumers/async_base_consumer.py (1)

92-103: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

COMPLETED status check is unreachable for sessions with user chats.

The elif chain has a logic flaw: when user chats exist (existing_chats.exclude(sender_id=1).count() > 0), line 92's condition is False. Since those chats are part of existing_chats, line 96's existing_chats.exists() will be True, causing line 100's COMPLETED check to never execute.

This means sessions already marked COMPLETED by the response handler (per context snippet 3) will incorrectly return IN_PROGRESS instead of preserving COMPLETED.

🐛 Proposed fix: check COMPLETED status earlier
+            if chat_session and chat_session.session_status == ChatStatus.COMPLETED:
+                return ChatStatus.COMPLETED
+
             if existing_chats.exclude(sender_id=1).count() == 0:
                 return ChatStatus.STARTED
             elif state_machine and not is_last_step and is_disconnected:
                 return ChatStatus.PAUSED
             elif existing_chats.exists():
                 last_chat = existing_chats.last()
                 if last_chat and last_chat.status == ChatStatus.PAUSED:
                     return ChatStatus.RESUME
-            elif chat_session and chat_session.session_status == ChatStatus.COMPLETED:
-                return ChatStatus.COMPLETED

             return ChatStatus.IN_PROGRESS
🤖 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_base_consumer.py` around lines 92 - 103, The
COMPLETED status check is unreachable because when user chats exist in
existing_chats, the condition on line 96 (existing_chats.exists()) evaluates to
True and prevents line 100's chat_session.session_status check from executing.
Move the COMPLETED status check to an earlier position in the elif chain, before
the existing_chats.exists() condition, so that chat_session sessions marked as
COMPLETED are detected and returned regardless of whether user chats exist in
the queryset.
🤖 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 852-853: The custom_model value extracted from
company_bot.other_params is not being normalized before being used as an
override, which allows invalid values like whitespace-only strings to be
returned and break gateway calls. Normalize the custom variable by stripping
whitespace and validating it is a non-empty string before returning it; only
return the normalized custom value if it passes validation, otherwise fall back
to returning company_bot.llm_model as the default.

In `@chatbot/utils/audio_provider_utils.py`:
- Around line 66-67: The regex pattern in the text normalization at the re.sub
call is requiring whitespace after the colon using \s+, which misses common time
formats like 1:30 that have no space. Modify the regex pattern to make the
whitespace optional by replacing \s+ with \s* so that it matches both formats
with and without spaces after the colon (e.g., both "1:30" and "1: 30" will be
normalized to "1, 30").

---

Outside diff comments:
In `@chatbot/consumers/async_base_consumer.py`:
- Around line 92-103: The COMPLETED status check is unreachable because when
user chats exist in existing_chats, the condition on line 96
(existing_chats.exists()) evaluates to True and prevents line 100's
chat_session.session_status check from executing. Move the COMPLETED status
check to an earlier position in the elif chain, before the
existing_chats.exists() condition, so that chat_session sessions marked as
COMPLETED are detected and returned regardless of whether user chats exist in
the queryset.
🪄 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: 1b242a67-72a0-4d4f-ba63-ffe259f3d61c

📥 Commits

Reviewing files that changed from the base of the PR and between fc76db8 and d50766d.

📒 Files selected for processing (9)
  • chatbot/admin/company_admin.py
  • chatbot/consumers/async_base_consumer.py
  • chatbot/consumers/async_consumer.py
  • chatbot/models/enums.py
  • chatbot/serializer/profile_serializer.py
  • chatbot/services/core/prompt_builder.py
  • chatbot/services/response_handlers/base_response_handler.py
  • chatbot/utils/audio_provider_utils.py
  • chatbot/utils/media_preview/media_creation.py

Comment thread chatbot/services/response_handlers/base_response_handler.py Outdated
Comment thread chatbot/utils/audio_provider_utils.py Outdated
@KUNALTEMPEST

Copy link
Copy Markdown
Author

@CodeRabbit review

@coderabbitai

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

@kiranharidas187
kiranharidas187 merged commit 95fdddb into ELEVATE-Project:release-1.0.0 Jun 18, 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