Skip to content

Conversation

@HavenDV
Copy link
Contributor

@HavenDV HavenDV commented Oct 8, 2025

Summary by CodeRabbit

  • New Features
    • Added sorting to the public models list via sort_by (model_created_at, latest_version_created_at) and sort_direction (asc, desc), with sensible defaults.
  • Refactor
    • Standardized request header to Cancel-After across relevant endpoints, replacing the previous header name.
  • Documentation
    • Expanded /models GET docs with a Sorting section, usage examples, and default behaviors.
    • Updated header parameter references and descriptions to reflect the new Cancel-After header.

@HavenDV HavenDV enabled auto-merge (squash) October 8, 2025 18:22
@coderabbitai
Copy link

coderabbitai bot commented Oct 8, 2025

Walkthrough

Introduces sorting parameters (sort_by, sort_direction) to the public models listing and replaces the max lifetime header parameter with Cancel-After across endpoints. Updates OpenAPI descriptions to document sorting behavior and new header usage within src/libs/Replicate/openapi.yaml.

Changes

Cohort / File(s) Summary
Models listing sorting params
src/libs/Replicate/openapi.yaml
Adds query params sort_by (model_created_at, latest_version_created_at) and sort_direction (asc, desc) with defaults and descriptions for /models GET. Documentation includes examples and sorting section.
Header parameter rename
src/libs/Replicate/openapi.yaml
Replaces references to parameters_max_lifetime_header with parameters_cancel_after_header across affected endpoints; header name standardized to Cancel-After with updated descriptions.
Documentation updates
src/libs/Replicate/openapi.yaml
Expands /models GET description to include Sorting section, examples, and explicit defaults; aligns header parameter descriptions to the new Cancel-After header.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Client
  participant API as HTTP API
  participant Models as Models Service

  Note over Client,API: List public models with sorting
  Client->>API: GET /models?sort_by=model_created_at&sort_direction=desc
  API->>Models: Fetch models sorted by criteria
  Models-->>API: Sorted model list
  API-->>Client: 200 OK (JSON list)

  rect rgb(245,250,255)
    Note right of Client: Optional timeout control
    Client->>API: Any endpoint with header Cancel-After: <seconds>
    API->>API: Enforce cancellation if processing exceeds value
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

I twitch my whiskers at headers anew,
Cancel-After whispers, “now I’m the cue.”
Models line up, sorted neat as a row,
Asc to the moon, desc to burrows below.
I stamp my paw—specs polished bright,
Hop-hop! The API reads just right.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Title Check ⚠️ Warning The title ‘feat:@coderabbitai’ does not describe the actual changes in this pull request, such as the addition of sorting parameters or the replacement of the lifetime header with Cancel-After in the OpenAPI specification, making it too generic and uninformative. Please update the PR title to concisely reflect the main changes, for example “Add model listing sorting and replace max-lifetime header with Cancel-After in OpenAPI spec.”
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bot/update-openapi_202510081821

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.

@HavenDV HavenDV merged commit 1fff021 into main Oct 8, 2025
3 of 4 checks passed
@HavenDV HavenDV deleted the bot/update-openapi_202510081821 branch October 8, 2025 18:23
@coderabbitai coderabbitai bot changed the title feat:@coderabbitai feat:Add sorting params to models listing and adopt Cancel-After header Oct 8, 2025
Copy link

@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: 0

🧹 Nitpick comments (2)
src/libs/Replicate/openapi.yaml (2)

481-501: Sorting params for /models: clear and consistent.

Defaults and enums align with the docs. Nice addition.

  • Consider adding x-enumDescriptions or brief inline notes to each enum value to improve SDK generation and IDE hints.
  • Optionally add an example to each parameter for quick copy/paste:
-        - name: sort_by
+        - name: sort_by
           in: query
           description: "Field to sort models by. Defaults to `latest_version_created_at`.\n"
           schema:
             enum:
               - model_created_at
               - latest_version_created_at
             type: string
             default: latest_version_created_at
+          example: latest_version_created_at
-        - name: sort_direction
+        - name: sort_direction
           in: query
           description: "Sort direction. Defaults to `desc` (descending, newest first).\n"
           schema:
             enum:
               - asc
               - desc
             type: string
             default: desc
+          example: desc

1812-1819: Enhance Cancel-After parameter with examples and clarify interaction with Prefer.

Add concrete examples and note that Cancel-After (job lifetime) is independent of Prefer: wait (HTTP request wait).

   parameters:
     parameters_cancel_after_header:
       name: Cancel-After
       in: header
-      description: "The maximum time the prediction can run before it is automatically canceled. The lifetime is measured from when the prediction is created.\n\nThe duration can be specified as string with an optional unit suffix:\n- `s` for seconds (e.g., `30s`, `90s`)\n- `m` for minutes (e.g., `5m`, `15m`)\n- `h` for hours (e.g., `1h`, `2h30m`)\n- defaults to seconds if no unit suffix is provided (e.g. `30` is the same as `30s`)\n\nYou can combine units for more precision (e.g., `1h30m45s`).\n\nThe minimum allowed duration is 5 seconds.\n"
+      description: "The maximum time the prediction can run before it is automatically canceled. The lifetime is measured from when the prediction is created.\n\nThe duration can be specified as string with an optional unit suffix:\n- `s` for seconds (e.g., `30s`, `90s`)\n- `m` for minutes (e.g., `5m`, `15m`)\n- `h` for hours (e.g., `1h`, `2h30m`)\n- defaults to seconds if no unit suffix is provided (e.g. `30` is the same as `30s`)\n\nYou can combine units for more precision (e.g., `1h30m45s`).\n\nThe minimum allowed duration is 5 seconds.\n\nNote: This header controls job cancellation and is independent of the `Prefer: wait` header, which only affects how long the HTTP request waits for completion.\n"
       schema:
         type: string
         example: 5m
+      examples:
+        seconds:
+          summary: 30 seconds
+          value: 30s
+        minutes:
+          summary: 5 minutes
+          value: 5m
+        hours_mixed:
+          summary: 1 hour, 30 minutes, 45 seconds
+          value: 1h30m45s
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5d58845 and 2b5dd71.

⛔ Files ignored due to path filters (16)
  • src/libs/Replicate/Generated/Replicate..JsonSerializerContext.g.cs is excluded by !**/generated/**
  • src/libs/Replicate/Generated/Replicate.IReplicateApi.DeploymentsPredictionsCreate.g.cs is excluded by !**/generated/**
  • src/libs/Replicate/Generated/Replicate.IReplicateApi.ModelsList.g.cs is excluded by !**/generated/**
  • src/libs/Replicate/Generated/Replicate.IReplicateApi.ModelsPredictionsCreate.g.cs is excluded by !**/generated/**
  • src/libs/Replicate/Generated/Replicate.IReplicateApi.PredictionsCreate.g.cs is excluded by !**/generated/**
  • src/libs/Replicate/Generated/Replicate.JsonConverters.ModelsListSortBy.g.cs is excluded by !**/generated/**
  • src/libs/Replicate/Generated/Replicate.JsonConverters.ModelsListSortByNullable.g.cs is excluded by !**/generated/**
  • src/libs/Replicate/Generated/Replicate.JsonConverters.ModelsListSortDirection.g.cs is excluded by !**/generated/**
  • src/libs/Replicate/Generated/Replicate.JsonConverters.ModelsListSortDirectionNullable.g.cs is excluded by !**/generated/**
  • src/libs/Replicate/Generated/Replicate.JsonSerializerContextTypes.g.cs is excluded by !**/generated/**
  • src/libs/Replicate/Generated/Replicate.Models.ModelsListSortBy.g.cs is excluded by !**/generated/**
  • src/libs/Replicate/Generated/Replicate.Models.ModelsListSortDirection.g.cs is excluded by !**/generated/**
  • src/libs/Replicate/Generated/Replicate.ReplicateApi.DeploymentsPredictionsCreate.g.cs is excluded by !**/generated/**
  • src/libs/Replicate/Generated/Replicate.ReplicateApi.ModelsList.g.cs is excluded by !**/generated/**
  • src/libs/Replicate/Generated/Replicate.ReplicateApi.ModelsPredictionsCreate.g.cs is excluded by !**/generated/**
  • src/libs/Replicate/Generated/Replicate.ReplicateApi.PredictionsCreate.g.cs is excluded by !**/generated/**
📒 Files selected for processing (1)
  • src/libs/Replicate/openapi.yaml (5 hunks)
🔇 Additional comments (1)
src/libs/Replicate/openapi.yaml (1)

262-263: No lingering max-lifetime references; Cancel-After header adopted consistently.

  • rg search shows no occurrences of max[-_]lifetime or parameters_max_lifetime_header.
  • Please confirm the backend accepts the Cancel-After header (exact casing and duration formats).

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