Skip to content

Conversation

kumarUjjawal
Copy link
Contributor

@kumarUjjawal kumarUjjawal commented Oct 14, 2025

Pull Request

Related issue

Fixes #696

What does this PR do?

PR checklist

Please check if your PR fulfills the following requirements:

  • Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)?
  • Have you read the contributing guidelines?
  • Have you made sure that the title is accurate and descriptive of the changes?

Thank you so much for contributing to Meilisearch!

Summary by CodeRabbit

  • New Features

    • Chat workspaces management: list (with pagination), retrieve, and view/update/reset workspace settings.
    • Configurable prompts included in workspace settings with builder-style configuration.
    • Optional streaming API for real-time chat completions.
  • Documentation

    • Added introductory documentation for the new chats module.
  • Tests

    • Integration test covering full chat workspace lifecycle (list, retrieve, configure prompts, update/reset).
  • Chores

    • Added a crate-private accessor for the HTTP client used by the optional reqwest integration.

Copy link
Contributor

coderabbitai bot commented Oct 14, 2025

Walkthrough

Adds a new chats module implementing chat-workspace data models, a query builder, CRUD-like client methods, optional reqwest-gated streaming for chat completions, an integration-style lifecycle test, exports the module in lib.rs, and adds a crate-private accessor in the reqwest client.

Changes

Cohort / File(s) Summary
Chats module & API surface
src/chats.rs
Adds chat workspace models (ChatWorkspace, ChatWorkspacesResults, ChatPrompts, ChatWorkspaceSettings), builder-style setters, ChatWorkspacesQuery query builder, client methods for list/get/settings CRUD (list_*, get_*, update_*, reset_*), optional stream_chat_completion behind reqwest feature, networking helpers for streaming, and an integration-style test chat_workspace_lifecycle.
Library export
src/lib.rs
Exposes the new chats module via pub mod chats (adds doc comment).
Reqwest client accessor
src/reqwest.rs
Adds pub(crate) fn inner(&self) -> &reqwest::Client to expose the internal reqwest client within the crate.
Client tests import
src/client.rs
Narrows test imports: removes glob import of client items in tests and imports only Action and qualified_version.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Dev as Developer
  participant Client as Client<Http>
  participant HTTP as Meilisearch API

  Dev->>Client: list_chat_workspaces()
  Client->>HTTP: GET /chats
  HTTP-->>Client: ChatWorkspacesResults
  Client-->>Dev: ChatWorkspacesResults

  Dev->>Client: get_chat_workspace(uid)
  Client->>HTTP: GET /chats/{uid}
  HTTP-->>Client: ChatWorkspace
  Client-->>Dev: ChatWorkspace

  Dev->>Client: get_chat_workspace_settings(uid)
  Client->>HTTP: GET /chats/{uid}/settings
  HTTP-->>Client: ChatWorkspaceSettings
  Client-->>Dev: ChatWorkspaceSettings

  Dev->>Client: update_chat_workspace_settings(uid, settings)
  Client->>HTTP: PATCH /chats/{uid}/settings (JSON)
  HTTP-->>Client: ChatWorkspaceSettings
  Client-->>Dev: ChatWorkspaceSettings

  Dev->>Client: reset_chat_workspace_settings(uid)
  Client->>HTTP: DELETE /chats/{uid}/settings
  HTTP-->>Client: ChatWorkspaceSettings
  Client-->>Dev: ChatWorkspaceSettings
Loading
sequenceDiagram
  autonumber
  actor Dev as Developer
  participant Client as Client<reqwest> (feature)
  participant HTTP as Meilisearch API

  Dev->>Client: stream_chat_completion(uid, body)
  Client->>HTTP: POST /chats/{uid}/chat/completions\nAccept: text/event-stream
  Note over HTTP,Client: Server streams JSON chunks (SSE/stream)
  HTTP-->>Client: Streaming response
  Client-->>Dev: reqwest::Response (stream)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

I twitch my whiskers at fresh chat lands,
New burrows mapped with careful hands.
Prompts tucked in pockets neat,
Settings patched, responses fleet.
Hop, stream, list — a rabbit's beat. 🐇

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Out of Scope Changes Check ⚠️ Warning A minor change to the test imports in src/client.rs restricts which client items are imported and is unrelated to conversational search support and the linked issue objectives, indicating an out-of-scope modification. Please remove or separate the unrelated import change in src/client.rs to keep this PR focused solely on the conversational search feature.
Docstring Coverage ⚠️ Warning Docstring coverage is 48.39% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The PR title clearly references adding support for conversational search, which aligns with the main change—the new chats API surface and related client methods—so it accurately and succinctly summarizes the primary feature introduced by this changeset.
Linked Issues Check ✅ Passed The implementation adds all required client methods for the Meilisearch chats API, including CRUD operations and streaming support, and includes corresponding tests, thereby satisfying the tasks of adding new API methods and test cases as specified in issue #696.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 24b6f59 and eaeb2e8.

📒 Files selected for processing (1)
  • src/chats.rs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/chats.rs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: integration-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.

Copy link

codecov bot commented Oct 14, 2025

Codecov Report

❌ Patch coverage is 91.13924% with 28 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.16%. Comparing base (5e84bdf) to head (eaeb2e8).

Files with missing lines Patch % Lines
src/chats.rs 91.05% 28 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #716      +/-   ##
==========================================
+ Coverage   85.90%   86.16%   +0.25%     
==========================================
  Files          19       20       +1     
  Lines        6079     6395     +316     
==========================================
+ Hits         5222     5510     +288     
- Misses        857      885      +28     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

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)
src/chats.rs (1)

144-147: Consider accepting impl Into<ChatPrompts> for consistency.

The set_prompts method takes ChatPrompts by value, while other setters use impl Into<String>. For consistency and flexibility, consider accepting impl Into<ChatPrompts> or cloning a reference.

Apply this diff:

-    pub fn set_prompts(&mut self, prompts: ChatPrompts) -> &mut Self {
-        self.prompts = Some(prompts);
+    pub fn set_prompts(&mut self, prompts: impl Into<ChatPrompts>) -> &mut Self {
+        self.prompts = Some(prompts.into());
         self
     }

Then implement:

impl From<ChatPrompts> for ChatPrompts {
    fn from(p: ChatPrompts) -> Self { p }
}
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 02993ad and c985ee4.

📒 Files selected for processing (1)
  • src/chats.rs (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/chats.rs (3)
src/reqwest.rs (3)
  • new (24-51)
  • new (148-155)
  • qualified_version (131-135)
src/client.rs (3)
  • new (53-65)
  • None (1283-1283)
  • None (1362-1362)
src/request.rs (2)
  • body (49-56)
  • parse_response (110-146)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: integration-tests
🔇 Additional comments (5)
src/chats.rs (5)

12-47: LGTM! Well-designed data models.

The structs properly use serde attributes for JSON serialization. The ChatPrompts.extra field with flatten allows provider-specific extensions while maintaining type safety for known fields.


49-79: LGTM! Clean builder pattern.

The implementation follows Rust builder conventions with must_use and method chaining support.


150-184: LGTM! Well-designed query builder.

The query builder properly manages the client reference with lifetimes and excludes it from serialization. The builder pattern is correctly implemented.


186-268: LGTM! Solid CRUD implementation.

The methods follow REST conventions and use AsRef<str> for flexible string parameters. The HTTP method choices align with RESTful design.


336-413: LGTM! Comprehensive integration test.

The test thoroughly exercises the chats API lifecycle:

  • Settings CRUD operations
  • Workspace retrieval
  • Query builder with pagination
  • API key masking verification (lines 380-385)

The test structure is clear and covers the key use cases.

@kumarUjjawal
Copy link
Contributor Author

@coderabbitai generate docstrings

Copy link
Contributor

coderabbitai bot commented Oct 15, 2025

✅ Actions performed

Initiated docstring generation; will generate only if new commits exist.

Copy link
Contributor

coderabbitai bot commented Oct 15, 2025

Note

Docstrings generation - SUCCESS
Generated docstrings for this pull request at #718

coderabbitai bot added a commit that referenced this pull request Oct 15, 2025
Docstrings generation was requested by @kumarUjjawal.

* #716 (comment)

The following files were modified:

* `src/chats.rs`
* `src/reqwest.rs`
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.

[v1.15.1] Add support for conversational search

1 participant