-
-
Notifications
You must be signed in to change notification settings - Fork 1
feat:Add 200 response to prediction POST endpoints; fix 'endpoint' typos #124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughAdded HTTP 200 responses with schemas_prediction_response to two POST prediction creation endpoints to allow synchronous final results, alongside existing 201/202 asynchronous responses. Corrected “endpiont” to “endpoint” in several prediction-related descriptions. No other structural or signature changes. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant C as Client
participant A as API (POST /predictions)
participant W as Prediction Worker
rect rgb(235, 245, 255)
note over C,A: New synchronous path (200 OK)
C->>A: Create prediction (input)
A->>W: Dispatch job
W-->>A: Final output ready
A-->>C: 200 OK with schemas_prediction_response
end
opt Existing asynchronous paths (201/202)
C->>A: Create prediction (input)
A-->>C: 201/202 Accepted + status URL
loop Polling/Webhook
C->>A: GET status (poll) / A->>C: In-progress
A->>W: Check status
end
A-->>C: Final result when complete
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
✨ Finishing Touches🧪 Generate 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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (3)
src/libs/Replicate/openapi.yaml (3)
850-872: Add 200 response for POST /predictions to match models endpoint and SDKs.Per the PR intent and for parity with /models/{owner}/{name}/predictions, POST /predictions should also document a 200 “Success” response carrying schemas_prediction_response for cases where the model completes within the Prefer: wait window. Currently only 201/202 are defined here.
Apply this diff to add the missing 200 response:
responses: + '200': + description: Success + content: + application/json: + schema: + $ref: '#/components/schemas/schemas_prediction_response' '201': description: 'Prediction has been created. If the `Prefer: wait` header is provided it will contain the final output.' content: application/json: schema: $ref: '#/components/schemas/schemas_prediction_response' '202': description: Prediction has been created but does not yet have all outputs content: application/json: schema: $ref: '#/components/schemas/schemas_prediction_response'
1278-1280: Doc bug: “url” should be “urls” (property name).The deprecation note says the stream link appears under the prediction’s url property; the schema defines urls (plural). Fix in both request schema descriptions to avoid confusion.
Apply this diff in both locations:
-This field is no longer needed as the returned prediction will always have a `stream` entry in its `url` property if the model supports streaming. +This field is no longer needed as the returned prediction will always have a `stream` entry in its `urls` property if the model supports streaming.Also applies to: 1505-1507
1549-1555: Regex allows wait=61..99; cap at 60.The current pattern permits 10–99 (including 61–99). Tighten it to 1–60 as documented.
Apply this diff:
- pattern: '^wait(=([1-9]|[1-9][0-9]|60))?$' + pattern: '^wait(=([1-9]|[1-5][0-9]|60))?$'
🧹 Nitpick comments (3)
src/libs/Replicate/openapi.yaml (3)
656-662: Good addition: 200 response enables synchronous success path.The new 200 response for models.predictions.create looks correct and uses the same schemas_prediction_response as 201/202. Consider keeping response-code ordering consistent (200, 201, 202) across operations for readability.
Apply this diff to reorder (optional):
responses: - '201': + '200': + description: Success + content: + application/json: + schema: + $ref: '#/components/schemas/schemas_prediction_response' + '201': description: 'Prediction has been created. If the `Prefer: wait` header is provided it will contain the final output.' content: application/json: schema: $ref: '#/components/schemas/schemas_prediction_response' '202': description: Prediction has been created but does not yet have all outputs content: application/json: schema: $ref: '#/components/schemas/schemas_prediction_response' - '200': - description: Successful - content: - application/json: - schema: - $ref: '#/components/schemas/schemas_prediction_response'
246-279: Optional: consider documenting a 200 success path here too for symmetry.If deployments-backed predictions can also complete within the Prefer: wait window, consider adding a 200 response like the models and predictions endpoints for consistency across SDKs and codegen.
Proposed diff (optional):
responses: + '200': + description: Success + content: + application/json: + schema: + $ref: '#/components/schemas/schemas_prediction_response' '201': description: 'Prediction has been created. If the `Prefer: wait` header is provided it will contain the final output.' content: application/json: schema: $ref: '#/components/schemas/schemas_prediction_response' '202': description: Prediction has been created but does not yet have all outputs content: application/json: schema: $ref: '#/components/schemas/schemas_prediction_response'
657-657: Unify response descriptions (“Success” vs “Successful”).You use both “Success” and “Successful”. Choose one (e.g., “Success”) for consistency across the spec. Not functionally critical, but it improves generated docs.
Example change:
- description: Successful + description: SuccessAlso applies to: 885-886, 191-191, 284-286, 462-464, 484-487, 709-713, 766-771, 916-921, 978-982
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
⛔ Files ignored due to path filters (6)
src/libs/Replicate/Generated/Replicate.IReplicateApi.DeploymentsPredictionsCreate.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.IReplicateApi.ModelsPredictionsCreate.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.IReplicateApi.PredictionsCreate.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.ReplicateApi.DeploymentsPredictionsCreate.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.ReplicateApi.ModelsPredictionsCreate.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.ReplicateApi.PredictionsCreate.g.csis excluded by!**/generated/**
📒 Files selected for processing (1)
src/libs/Replicate/openapi.yaml(3 hunks)
| post: | ||
| summary: Create a prediction using an official model | ||
| description: "Create a prediction using an [official model](https://replicate.com/changelog/2025-01-29-official-models).\n\nIf you're _not_ running an official model, use the [`predictions.create`](#predictions.create) operation instead.\n\nExample cURL request:\n\n```console\ncurl -s -X POST -H 'Prefer: wait' \\\n -d '{\"input\": {\"prompt\": \"Write a short poem about the weather.\"}}' \\\n -H \"Authorization: Bearer $REPLICATE_API_TOKEN\" \\\n -H 'Content-Type: application/json' \\\n https://api.replicate.com/v1/models/meta/meta-llama-3-70b-instruct/predictions\n```\n\nThe request will wait up to 60 seconds for the model to run. If this time is exceeded the prediction will be returned in a `\"starting\"` state and need to be retrieved using the `predictions.get` endpiont.\n\nFor a complete overview of the `deployments.predictions.create` API check out our documentation on [creating a prediction](https://replicate.com/docs/topics/predictions/create-a-prediction) which covers a variety of use cases.\n" | ||
| description: "Create a prediction using an [official model](https://replicate.com/changelog/2025-01-29-official-models).\n\nIf you're _not_ running an official model, use the [`predictions.create`](#predictions.create) operation instead.\n\nExample cURL request:\n\n```console\ncurl -s -X POST -H 'Prefer: wait' \\\n -d '{\"input\": {\"prompt\": \"Write a short poem about the weather.\"}}' \\\n -H \"Authorization: Bearer $REPLICATE_API_TOKEN\" \\\n -H 'Content-Type: application/json' \\\n https://api.replicate.com/v1/models/meta/meta-llama-3-70b-instruct/predictions\n```\n\nThe request will wait up to 60 seconds for the model to run. If this time is exceeded the prediction will be returned in a `\"starting\"` state and need to be retrieved using the `predictions.get` endpoint.\n\nFor a complete overview of the `deployments.predictions.create` API check out our documentation on [creating a prediction](https://replicate.com/docs/topics/predictions/create-a-prediction) which covers a variety of use cases.\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix incorrect cross-reference: should not point to deployments.predictions.create.
This is the models.predictions.create operation; the final sentence references deployments.predictions.create. Replace with models.predictions.create (or with predictions.create if you want a generic reference).
Apply this diff to the description text:
-For a complete overview of the `deployments.predictions.create` API check out our documentation on [creating a prediction](https://replicate.com/docs/topics/predictions/create-a-prediction) which covers a variety of use cases.
+For a complete overview of the `models.predictions.create` API, see our documentation on [creating a prediction](https://replicate.com/docs/topics/predictions/create-a-prediction), which covers a variety of use cases.📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| description: "Create a prediction using an [official model](https://replicate.com/changelog/2025-01-29-official-models).\n\nIf you're _not_ running an official model, use the [`predictions.create`](#predictions.create) operation instead.\n\nExample cURL request:\n\n```console\ncurl -s -X POST -H 'Prefer: wait' \\\n -d '{\"input\": {\"prompt\": \"Write a short poem about the weather.\"}}' \\\n -H \"Authorization: Bearer $REPLICATE_API_TOKEN\" \\\n -H 'Content-Type: application/json' \\\n https://api.replicate.com/v1/models/meta/meta-llama-3-70b-instruct/predictions\n```\n\nThe request will wait up to 60 seconds for the model to run. If this time is exceeded the prediction will be returned in a `\"starting\"` state and need to be retrieved using the `predictions.get` endpoint.\n\nFor a complete overview of the `deployments.predictions.create` API check out our documentation on [creating a prediction](https://replicate.com/docs/topics/predictions/create-a-prediction) which covers a variety of use cases.\n" | |
| description: "Create a prediction using an [official model](https://replicate.com/changelog/2025-01-29-official-models).\n\nIf you're _not_ running an official model, use the [`predictions.create`](#predictions.create) operation instead.\n\nExample cURL request:\n\n |
🤖 Prompt for AI Agents
In src/libs/Replicate/openapi.yaml around line 622, the description incorrectly
references deployments.predictions.create; update that final sentence to
reference models.predictions.create (or predictions.create for a generic link)
so it points to the correct operation for this models.predictions.create
endpoint, and ensure the wording matches the rest of the description.
Summary by CodeRabbit
New Features
Documentation