diff --git a/.release-please-manifest.json b/.release-please-manifest.json
index 6b7b74c..cce9240 100644
--- a/.release-please-manifest.json
+++ b/.release-please-manifest.json
@@ -1,3 +1,3 @@
{
- ".": "0.3.0"
+ ".": "0.3.1"
}
\ No newline at end of file
diff --git a/.stats.yml b/.stats.yml
index c87e70b..713348a 100644
--- a/.stats.yml
+++ b/.stats.yml
@@ -1,4 +1,4 @@
-configured_endpoints: 1
+configured_endpoints: 2
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/isaacus%2Fisaacus-861e8a85f0fb73cf4b7fc6c2b27722072ff33109459e90c17be24af15dfcbd0c.yml
openapi_spec_hash: 644a0383600633ee604bb1e5b9ca025d
-config_hash: 8a781867f31df68b9c6fba04c165c647
+config_hash: 2bc262108dc3b065c16da5bb85c1e282
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 678c0a4..eddb418 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,13 @@
# Changelog
+## 0.3.1 (2025-04-01)
+
+Full Changelog: [v0.3.0...v0.3.1](https://github.com/isaacus-dev/isaacus-python/compare/v0.3.0...v0.3.1)
+
+### Bug Fixes
+
+* **stainless:** added missing reranking endpoint to SDK API ([#50](https://github.com/isaacus-dev/isaacus-python/issues/50)) ([65bcc7c](https://github.com/isaacus-dev/isaacus-python/commit/65bcc7c274dc5609c1537e417c75e6b9942ac8fc))
+
## 0.3.0 (2025-04-01)
Full Changelog: [v0.2.0...v0.3.0](https://github.com/isaacus-dev/isaacus-python/compare/v0.2.0...v0.3.0)
diff --git a/api.md b/api.md
index f2d3694..58ab695 100644
--- a/api.md
+++ b/api.md
@@ -11,3 +11,15 @@ from isaacus.types.classifications import UniversalClassification
Methods:
- client.classifications.universal.create(\*\*params) -> UniversalClassification
+
+# Rerankings
+
+Types:
+
+```python
+from isaacus.types import Reranking
+```
+
+Methods:
+
+- client.rerankings.create(\*\*params) -> Reranking
diff --git a/pyproject.toml b/pyproject.toml
index 8197914..f94bd96 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,6 @@
[project]
name = "isaacus"
-version = "0.3.0"
+version = "0.3.1"
description = "The official Python library for the isaacus API"
dynamic = ["readme"]
license = "Apache-2.0"
diff --git a/src/isaacus/_client.py b/src/isaacus/_client.py
index d2b679f..99ee81b 100644
--- a/src/isaacus/_client.py
+++ b/src/isaacus/_client.py
@@ -24,6 +24,7 @@
get_async_library,
)
from ._version import __version__
+from .resources import rerankings
from ._streaming import Stream as Stream, AsyncStream as AsyncStream
from ._exceptions import IsaacusError, APIStatusError
from ._base_client import (
@@ -38,6 +39,7 @@
class Isaacus(SyncAPIClient):
classifications: classifications.ClassificationsResource
+ rerankings: rerankings.RerankingsResource
with_raw_response: IsaacusWithRawResponse
with_streaming_response: IsaacusWithStreamedResponse
@@ -96,6 +98,7 @@ def __init__(
)
self.classifications = classifications.ClassificationsResource(self)
+ self.rerankings = rerankings.RerankingsResource(self)
self.with_raw_response = IsaacusWithRawResponse(self)
self.with_streaming_response = IsaacusWithStreamedResponse(self)
@@ -206,6 +209,7 @@ def _make_status_error(
class AsyncIsaacus(AsyncAPIClient):
classifications: classifications.AsyncClassificationsResource
+ rerankings: rerankings.AsyncRerankingsResource
with_raw_response: AsyncIsaacusWithRawResponse
with_streaming_response: AsyncIsaacusWithStreamedResponse
@@ -264,6 +268,7 @@ def __init__(
)
self.classifications = classifications.AsyncClassificationsResource(self)
+ self.rerankings = rerankings.AsyncRerankingsResource(self)
self.with_raw_response = AsyncIsaacusWithRawResponse(self)
self.with_streaming_response = AsyncIsaacusWithStreamedResponse(self)
@@ -375,21 +380,25 @@ def _make_status_error(
class IsaacusWithRawResponse:
def __init__(self, client: Isaacus) -> None:
self.classifications = classifications.ClassificationsResourceWithRawResponse(client.classifications)
+ self.rerankings = rerankings.RerankingsResourceWithRawResponse(client.rerankings)
class AsyncIsaacusWithRawResponse:
def __init__(self, client: AsyncIsaacus) -> None:
self.classifications = classifications.AsyncClassificationsResourceWithRawResponse(client.classifications)
+ self.rerankings = rerankings.AsyncRerankingsResourceWithRawResponse(client.rerankings)
class IsaacusWithStreamedResponse:
def __init__(self, client: Isaacus) -> None:
self.classifications = classifications.ClassificationsResourceWithStreamingResponse(client.classifications)
+ self.rerankings = rerankings.RerankingsResourceWithStreamingResponse(client.rerankings)
class AsyncIsaacusWithStreamedResponse:
def __init__(self, client: AsyncIsaacus) -> None:
self.classifications = classifications.AsyncClassificationsResourceWithStreamingResponse(client.classifications)
+ self.rerankings = rerankings.AsyncRerankingsResourceWithStreamingResponse(client.rerankings)
Client = Isaacus
diff --git a/src/isaacus/_version.py b/src/isaacus/_version.py
index cdb0102..96bdd89 100644
--- a/src/isaacus/_version.py
+++ b/src/isaacus/_version.py
@@ -1,4 +1,4 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
__title__ = "isaacus"
-__version__ = "0.3.0" # x-release-please-version
+__version__ = "0.3.1" # x-release-please-version
diff --git a/src/isaacus/resources/__init__.py b/src/isaacus/resources/__init__.py
index 3d7a144..3cc3129 100644
--- a/src/isaacus/resources/__init__.py
+++ b/src/isaacus/resources/__init__.py
@@ -1,5 +1,13 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+from .rerankings import (
+ RerankingsResource,
+ AsyncRerankingsResource,
+ RerankingsResourceWithRawResponse,
+ AsyncRerankingsResourceWithRawResponse,
+ RerankingsResourceWithStreamingResponse,
+ AsyncRerankingsResourceWithStreamingResponse,
+)
from .classifications import (
ClassificationsResource,
AsyncClassificationsResource,
@@ -16,4 +24,10 @@
"AsyncClassificationsResourceWithRawResponse",
"ClassificationsResourceWithStreamingResponse",
"AsyncClassificationsResourceWithStreamingResponse",
+ "RerankingsResource",
+ "AsyncRerankingsResource",
+ "RerankingsResourceWithRawResponse",
+ "AsyncRerankingsResourceWithRawResponse",
+ "RerankingsResourceWithStreamingResponse",
+ "AsyncRerankingsResourceWithStreamingResponse",
]
diff --git a/src/isaacus/resources/rerankings.py b/src/isaacus/resources/rerankings.py
new file mode 100644
index 0000000..b32362d
--- /dev/null
+++ b/src/isaacus/resources/rerankings.py
@@ -0,0 +1,285 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+from __future__ import annotations
+
+from typing import List, Optional
+from typing_extensions import Literal
+
+import httpx
+
+from ..types import reranking_create_params
+from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven
+from .._utils import (
+ maybe_transform,
+ async_maybe_transform,
+)
+from .._compat import cached_property
+from .._resource import SyncAPIResource, AsyncAPIResource
+from .._response import (
+ to_raw_response_wrapper,
+ to_streamed_response_wrapper,
+ async_to_raw_response_wrapper,
+ async_to_streamed_response_wrapper,
+)
+from .._base_client import make_request_options
+from ..types.reranking import Reranking
+
+__all__ = ["RerankingsResource", "AsyncRerankingsResource"]
+
+
+class RerankingsResource(SyncAPIResource):
+ @cached_property
+ def with_raw_response(self) -> RerankingsResourceWithRawResponse:
+ """
+ This property can be used as a prefix for any HTTP method call to return
+ the raw response object instead of the parsed content.
+
+ For more information, see https://www.github.com/isaacus-dev/isaacus-python#accessing-raw-response-data-eg-headers
+ """
+ return RerankingsResourceWithRawResponse(self)
+
+ @cached_property
+ def with_streaming_response(self) -> RerankingsResourceWithStreamingResponse:
+ """
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
+
+ For more information, see https://www.github.com/isaacus-dev/isaacus-python#with_streaming_response
+ """
+ return RerankingsResourceWithStreamingResponse(self)
+
+ def create(
+ self,
+ *,
+ model: Literal["kanon-universal-classifier", "kanon-universal-classifier-mini"],
+ query: str,
+ texts: List[str],
+ chunking_options: Optional[reranking_create_params.ChunkingOptions] | NotGiven = NOT_GIVEN,
+ is_iql: bool | NotGiven = NOT_GIVEN,
+ scoring_method: Literal["auto", "chunk_max", "chunk_avg", "chunk_min"] | NotGiven = NOT_GIVEN,
+ top_n: Optional[int] | NotGiven = NOT_GIVEN,
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
+ ) -> Reranking:
+ """
+ Rerank legal documents by their relevance to a query with an Isaacus legal AI
+ reranker.
+
+ Args:
+ model: The ID of the [model](https://docs.isaacus.com/models#reranking) to use for
+ reranking.
+
+ query: The query to evaluate the relevance of the texts to.
+
+ The query must contain at least one non-whitespace character.
+
+ Unlike the texts being reranked, the query cannot be so long that it exceeds the
+ maximum input length of the reranker.
+
+ texts: The texts to rerank.
+
+ There must be at least one text.
+
+ The texts must contain at least one non-whitespace character.
+
+ chunking_options: Options for how to split text into smaller chunks.
+
+ is_iql: Whether the query should be interpreted as an
+ [Isaacus Query Language (IQL)](https://docs.isaacus.com/iql) query, which is not
+ the case by default.
+
+ If you allow untrusted users to construct their own queries, think carefully
+ before enabling IQL since queries can be crafted to consume an excessively large
+ amount of tokens.
+
+ scoring_method: The method to use for producing an overall relevance score for a text.
+
+ `auto` is the default scoring method and is recommended for most use cases.
+ Currently, it is equivalent to `chunk_max`. In the future, it will automatically
+ select the best method based on the model and inputs.
+
+ `chunk_max` uses the highest relevance score of all of a text's chunks.
+
+ `chunk_avg` averages the relevance scores of all of a text's chunks.
+
+ `chunk_min` uses the lowest relevance score of all of a text's chunks.
+
+ top_n: A whole number greater than or equal to 1.
+
+ extra_headers: Send extra headers
+
+ extra_query: Add additional query parameters to the request
+
+ extra_body: Add additional JSON properties to the request
+
+ timeout: Override the client-level default timeout for this request, in seconds
+ """
+ return self._post(
+ "/rerankings",
+ body=maybe_transform(
+ {
+ "model": model,
+ "query": query,
+ "texts": texts,
+ "chunking_options": chunking_options,
+ "is_iql": is_iql,
+ "scoring_method": scoring_method,
+ "top_n": top_n,
+ },
+ reranking_create_params.RerankingCreateParams,
+ ),
+ options=make_request_options(
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
+ ),
+ cast_to=Reranking,
+ )
+
+
+class AsyncRerankingsResource(AsyncAPIResource):
+ @cached_property
+ def with_raw_response(self) -> AsyncRerankingsResourceWithRawResponse:
+ """
+ This property can be used as a prefix for any HTTP method call to return
+ the raw response object instead of the parsed content.
+
+ For more information, see https://www.github.com/isaacus-dev/isaacus-python#accessing-raw-response-data-eg-headers
+ """
+ return AsyncRerankingsResourceWithRawResponse(self)
+
+ @cached_property
+ def with_streaming_response(self) -> AsyncRerankingsResourceWithStreamingResponse:
+ """
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
+
+ For more information, see https://www.github.com/isaacus-dev/isaacus-python#with_streaming_response
+ """
+ return AsyncRerankingsResourceWithStreamingResponse(self)
+
+ async def create(
+ self,
+ *,
+ model: Literal["kanon-universal-classifier", "kanon-universal-classifier-mini"],
+ query: str,
+ texts: List[str],
+ chunking_options: Optional[reranking_create_params.ChunkingOptions] | NotGiven = NOT_GIVEN,
+ is_iql: bool | NotGiven = NOT_GIVEN,
+ scoring_method: Literal["auto", "chunk_max", "chunk_avg", "chunk_min"] | NotGiven = NOT_GIVEN,
+ top_n: Optional[int] | NotGiven = NOT_GIVEN,
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
+ ) -> Reranking:
+ """
+ Rerank legal documents by their relevance to a query with an Isaacus legal AI
+ reranker.
+
+ Args:
+ model: The ID of the [model](https://docs.isaacus.com/models#reranking) to use for
+ reranking.
+
+ query: The query to evaluate the relevance of the texts to.
+
+ The query must contain at least one non-whitespace character.
+
+ Unlike the texts being reranked, the query cannot be so long that it exceeds the
+ maximum input length of the reranker.
+
+ texts: The texts to rerank.
+
+ There must be at least one text.
+
+ The texts must contain at least one non-whitespace character.
+
+ chunking_options: Options for how to split text into smaller chunks.
+
+ is_iql: Whether the query should be interpreted as an
+ [Isaacus Query Language (IQL)](https://docs.isaacus.com/iql) query, which is not
+ the case by default.
+
+ If you allow untrusted users to construct their own queries, think carefully
+ before enabling IQL since queries can be crafted to consume an excessively large
+ amount of tokens.
+
+ scoring_method: The method to use for producing an overall relevance score for a text.
+
+ `auto` is the default scoring method and is recommended for most use cases.
+ Currently, it is equivalent to `chunk_max`. In the future, it will automatically
+ select the best method based on the model and inputs.
+
+ `chunk_max` uses the highest relevance score of all of a text's chunks.
+
+ `chunk_avg` averages the relevance scores of all of a text's chunks.
+
+ `chunk_min` uses the lowest relevance score of all of a text's chunks.
+
+ top_n: A whole number greater than or equal to 1.
+
+ extra_headers: Send extra headers
+
+ extra_query: Add additional query parameters to the request
+
+ extra_body: Add additional JSON properties to the request
+
+ timeout: Override the client-level default timeout for this request, in seconds
+ """
+ return await self._post(
+ "/rerankings",
+ body=await async_maybe_transform(
+ {
+ "model": model,
+ "query": query,
+ "texts": texts,
+ "chunking_options": chunking_options,
+ "is_iql": is_iql,
+ "scoring_method": scoring_method,
+ "top_n": top_n,
+ },
+ reranking_create_params.RerankingCreateParams,
+ ),
+ options=make_request_options(
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
+ ),
+ cast_to=Reranking,
+ )
+
+
+class RerankingsResourceWithRawResponse:
+ def __init__(self, rerankings: RerankingsResource) -> None:
+ self._rerankings = rerankings
+
+ self.create = to_raw_response_wrapper(
+ rerankings.create,
+ )
+
+
+class AsyncRerankingsResourceWithRawResponse:
+ def __init__(self, rerankings: AsyncRerankingsResource) -> None:
+ self._rerankings = rerankings
+
+ self.create = async_to_raw_response_wrapper(
+ rerankings.create,
+ )
+
+
+class RerankingsResourceWithStreamingResponse:
+ def __init__(self, rerankings: RerankingsResource) -> None:
+ self._rerankings = rerankings
+
+ self.create = to_streamed_response_wrapper(
+ rerankings.create,
+ )
+
+
+class AsyncRerankingsResourceWithStreamingResponse:
+ def __init__(self, rerankings: AsyncRerankingsResource) -> None:
+ self._rerankings = rerankings
+
+ self.create = async_to_streamed_response_wrapper(
+ rerankings.create,
+ )
diff --git a/src/isaacus/types/__init__.py b/src/isaacus/types/__init__.py
index f8ee8b1..e5c4540 100644
--- a/src/isaacus/types/__init__.py
+++ b/src/isaacus/types/__init__.py
@@ -1,3 +1,6 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
from __future__ import annotations
+
+from .reranking import Reranking as Reranking
+from .reranking_create_params import RerankingCreateParams as RerankingCreateParams
diff --git a/src/isaacus/types/reranking.py b/src/isaacus/types/reranking.py
new file mode 100644
index 0000000..9d147e0
--- /dev/null
+++ b/src/isaacus/types/reranking.py
@@ -0,0 +1,37 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+from typing import List
+
+from .._models import BaseModel
+
+__all__ = ["Reranking", "Result", "Usage"]
+
+
+class Result(BaseModel):
+ index: int
+ """
+ The index of the text in the input array of texts, starting from `0` (and,
+ therefore, ending at the number of texts minus `1`).
+ """
+
+ score: float
+ """
+ A score between `0` and `1`, inclusive, representing the relevance of the text
+ to the query.
+ """
+
+
+class Usage(BaseModel):
+ input_tokens: int
+ """The number of tokens inputted to the model."""
+
+
+class Reranking(BaseModel):
+ results: List[Result]
+ """
+ The rerankings of the texts, by relevance to the query, in order from highest to
+ lowest relevance score.
+ """
+
+ usage: Usage
+ """Statistics about the usage of resources in the process of reranking the texts."""
diff --git a/src/isaacus/types/reranking_create_params.py b/src/isaacus/types/reranking_create_params.py
new file mode 100644
index 0000000..bd82314
--- /dev/null
+++ b/src/isaacus/types/reranking_create_params.py
@@ -0,0 +1,75 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+from __future__ import annotations
+
+from typing import List, Optional
+from typing_extensions import Literal, Required, TypedDict
+
+__all__ = ["RerankingCreateParams", "ChunkingOptions"]
+
+
+class RerankingCreateParams(TypedDict, total=False):
+ model: Required[Literal["kanon-universal-classifier", "kanon-universal-classifier-mini"]]
+ """
+ The ID of the [model](https://docs.isaacus.com/models#reranking) to use for
+ reranking.
+ """
+
+ query: Required[str]
+ """The query to evaluate the relevance of the texts to.
+
+ The query must contain at least one non-whitespace character.
+
+ Unlike the texts being reranked, the query cannot be so long that it exceeds the
+ maximum input length of the reranker.
+ """
+
+ texts: Required[List[str]]
+ """The texts to rerank.
+
+ There must be at least one text.
+
+ The texts must contain at least one non-whitespace character.
+ """
+
+ chunking_options: Optional[ChunkingOptions]
+ """Options for how to split text into smaller chunks."""
+
+ is_iql: bool
+ """
+ Whether the query should be interpreted as an
+ [Isaacus Query Language (IQL)](https://docs.isaacus.com/iql) query, which is not
+ the case by default.
+
+ If you allow untrusted users to construct their own queries, think carefully
+ before enabling IQL since queries can be crafted to consume an excessively large
+ amount of tokens.
+ """
+
+ scoring_method: Literal["auto", "chunk_max", "chunk_avg", "chunk_min"]
+ """The method to use for producing an overall relevance score for a text.
+
+ `auto` is the default scoring method and is recommended for most use cases.
+ Currently, it is equivalent to `chunk_max`. In the future, it will automatically
+ select the best method based on the model and inputs.
+
+ `chunk_max` uses the highest relevance score of all of a text's chunks.
+
+ `chunk_avg` averages the relevance scores of all of a text's chunks.
+
+ `chunk_min` uses the lowest relevance score of all of a text's chunks.
+ """
+
+ top_n: Optional[int]
+ """A whole number greater than or equal to 1."""
+
+
+class ChunkingOptions(TypedDict, total=False):
+ overlap_ratio: Optional[float]
+ """A number greater than or equal to 0 and less than 1."""
+
+ overlap_tokens: Optional[int]
+ """A whole number greater than -1."""
+
+ size: Optional[int]
+ """A whole number greater than or equal to 1."""
diff --git a/tests/api_resources/test_rerankings.py b/tests/api_resources/test_rerankings.py
new file mode 100644
index 0000000..ad1dd94
--- /dev/null
+++ b/tests/api_resources/test_rerankings.py
@@ -0,0 +1,186 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+from __future__ import annotations
+
+import os
+from typing import Any, cast
+
+import pytest
+
+from isaacus import Isaacus, AsyncIsaacus
+from tests.utils import assert_matches_type
+from isaacus.types import Reranking
+
+base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
+
+
+class TestRerankings:
+ parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"])
+
+ @pytest.mark.skip()
+ @parametrize
+ def test_method_create(self, client: Isaacus) -> None:
+ reranking = client.rerankings.create(
+ model="kanon-universal-classifier",
+ query="What are the essential elements required to establish a negligence claim?",
+ texts=[
+ "To form a contract, there must be an offer, acceptance, consideration, and mutual intent to be bound.",
+ "Criminal cases involve a completely different standard, requiring proof beyond a reasonable doubt.",
+ "In a negligence claim, the plaintiff must prove duty, breach, causation, and damages.",
+ "Negligence in tort law requires establishing a duty of care that the defendant owed to the plaintiff.",
+ "The concept of negligence is central to tort law, with courts assessing whether a breach of duty caused harm.",
+ ],
+ )
+ assert_matches_type(Reranking, reranking, path=["response"])
+
+ @pytest.mark.skip()
+ @parametrize
+ def test_method_create_with_all_params(self, client: Isaacus) -> None:
+ reranking = client.rerankings.create(
+ model="kanon-universal-classifier",
+ query="What are the essential elements required to establish a negligence claim?",
+ texts=[
+ "To form a contract, there must be an offer, acceptance, consideration, and mutual intent to be bound.",
+ "Criminal cases involve a completely different standard, requiring proof beyond a reasonable doubt.",
+ "In a negligence claim, the plaintiff must prove duty, breach, causation, and damages.",
+ "Negligence in tort law requires establishing a duty of care that the defendant owed to the plaintiff.",
+ "The concept of negligence is central to tort law, with courts assessing whether a breach of duty caused harm.",
+ ],
+ chunking_options={
+ "overlap_ratio": 0.1,
+ "overlap_tokens": 0,
+ "size": 512,
+ },
+ is_iql=False,
+ scoring_method="auto",
+ top_n=1,
+ )
+ assert_matches_type(Reranking, reranking, path=["response"])
+
+ @pytest.mark.skip()
+ @parametrize
+ def test_raw_response_create(self, client: Isaacus) -> None:
+ response = client.rerankings.with_raw_response.create(
+ model="kanon-universal-classifier",
+ query="What are the essential elements required to establish a negligence claim?",
+ texts=[
+ "To form a contract, there must be an offer, acceptance, consideration, and mutual intent to be bound.",
+ "Criminal cases involve a completely different standard, requiring proof beyond a reasonable doubt.",
+ "In a negligence claim, the plaintiff must prove duty, breach, causation, and damages.",
+ "Negligence in tort law requires establishing a duty of care that the defendant owed to the plaintiff.",
+ "The concept of negligence is central to tort law, with courts assessing whether a breach of duty caused harm.",
+ ],
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ reranking = response.parse()
+ assert_matches_type(Reranking, reranking, path=["response"])
+
+ @pytest.mark.skip()
+ @parametrize
+ def test_streaming_response_create(self, client: Isaacus) -> None:
+ with client.rerankings.with_streaming_response.create(
+ model="kanon-universal-classifier",
+ query="What are the essential elements required to establish a negligence claim?",
+ texts=[
+ "To form a contract, there must be an offer, acceptance, consideration, and mutual intent to be bound.",
+ "Criminal cases involve a completely different standard, requiring proof beyond a reasonable doubt.",
+ "In a negligence claim, the plaintiff must prove duty, breach, causation, and damages.",
+ "Negligence in tort law requires establishing a duty of care that the defendant owed to the plaintiff.",
+ "The concept of negligence is central to tort law, with courts assessing whether a breach of duty caused harm.",
+ ],
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ reranking = response.parse()
+ assert_matches_type(Reranking, reranking, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+
+class TestAsyncRerankings:
+ parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"])
+
+ @pytest.mark.skip()
+ @parametrize
+ async def test_method_create(self, async_client: AsyncIsaacus) -> None:
+ reranking = await async_client.rerankings.create(
+ model="kanon-universal-classifier",
+ query="What are the essential elements required to establish a negligence claim?",
+ texts=[
+ "To form a contract, there must be an offer, acceptance, consideration, and mutual intent to be bound.",
+ "Criminal cases involve a completely different standard, requiring proof beyond a reasonable doubt.",
+ "In a negligence claim, the plaintiff must prove duty, breach, causation, and damages.",
+ "Negligence in tort law requires establishing a duty of care that the defendant owed to the plaintiff.",
+ "The concept of negligence is central to tort law, with courts assessing whether a breach of duty caused harm.",
+ ],
+ )
+ assert_matches_type(Reranking, reranking, path=["response"])
+
+ @pytest.mark.skip()
+ @parametrize
+ async def test_method_create_with_all_params(self, async_client: AsyncIsaacus) -> None:
+ reranking = await async_client.rerankings.create(
+ model="kanon-universal-classifier",
+ query="What are the essential elements required to establish a negligence claim?",
+ texts=[
+ "To form a contract, there must be an offer, acceptance, consideration, and mutual intent to be bound.",
+ "Criminal cases involve a completely different standard, requiring proof beyond a reasonable doubt.",
+ "In a negligence claim, the plaintiff must prove duty, breach, causation, and damages.",
+ "Negligence in tort law requires establishing a duty of care that the defendant owed to the plaintiff.",
+ "The concept of negligence is central to tort law, with courts assessing whether a breach of duty caused harm.",
+ ],
+ chunking_options={
+ "overlap_ratio": 0.1,
+ "overlap_tokens": 0,
+ "size": 512,
+ },
+ is_iql=False,
+ scoring_method="auto",
+ top_n=1,
+ )
+ assert_matches_type(Reranking, reranking, path=["response"])
+
+ @pytest.mark.skip()
+ @parametrize
+ async def test_raw_response_create(self, async_client: AsyncIsaacus) -> None:
+ response = await async_client.rerankings.with_raw_response.create(
+ model="kanon-universal-classifier",
+ query="What are the essential elements required to establish a negligence claim?",
+ texts=[
+ "To form a contract, there must be an offer, acceptance, consideration, and mutual intent to be bound.",
+ "Criminal cases involve a completely different standard, requiring proof beyond a reasonable doubt.",
+ "In a negligence claim, the plaintiff must prove duty, breach, causation, and damages.",
+ "Negligence in tort law requires establishing a duty of care that the defendant owed to the plaintiff.",
+ "The concept of negligence is central to tort law, with courts assessing whether a breach of duty caused harm.",
+ ],
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ reranking = await response.parse()
+ assert_matches_type(Reranking, reranking, path=["response"])
+
+ @pytest.mark.skip()
+ @parametrize
+ async def test_streaming_response_create(self, async_client: AsyncIsaacus) -> None:
+ async with async_client.rerankings.with_streaming_response.create(
+ model="kanon-universal-classifier",
+ query="What are the essential elements required to establish a negligence claim?",
+ texts=[
+ "To form a contract, there must be an offer, acceptance, consideration, and mutual intent to be bound.",
+ "Criminal cases involve a completely different standard, requiring proof beyond a reasonable doubt.",
+ "In a negligence claim, the plaintiff must prove duty, breach, causation, and damages.",
+ "Negligence in tort law requires establishing a duty of care that the defendant owed to the plaintiff.",
+ "The concept of negligence is central to tort law, with courts assessing whether a breach of duty caused harm.",
+ ],
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ reranking = await response.parse()
+ assert_matches_type(Reranking, reranking, path=["response"])
+
+ assert cast(Any, response.is_closed) is True