rerank¶
Operation¶
rerank
¶
rerank(request: RerankInput | RerankInputDict | None = None, /, *, plugins: list[Plugin] | None = None, **kwargs: Unpack[RerankInputDict]) -> RerankOutput
Reranks the relevance of sources based on queries. For more information, see Improve the relevance of query responses with a reranker model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
RerankInput | RerankInputDict | None
|
The input as a model or dictionary. Pass this or keyword arguments, not both. |
None
|
plugins
|
list[Plugin] | None
|
A list of callables that modify the configuration dynamically. Changes made by these plugins only apply for the duration of the operation execution and will not affect any other operation invocations. |
None
|
**kwargs
|
Unpack[RerankInputDict]
|
The input fields as keyword arguments. |
{}
|
Returns:
| Type | Description |
|---|---|
RerankOutput
|
An instance of |
rerank
async
¶
rerank(request: RerankInput | RerankInputDict | None = None, /, *, plugins: list[Plugin] | None = None, **kwargs: Unpack[RerankInputDict]) -> RerankOutput
Reranks the relevance of sources based on queries. For more information, see Improve the relevance of query responses with a reranker model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
RerankInput | RerankInputDict | None
|
The input as a model or dictionary. Pass this or keyword arguments, not both. |
None
|
plugins
|
list[Plugin] | None
|
A list of callables that modify the configuration dynamically. Changes made by these plugins only apply for the duration of the operation execution and will not affect any other operation invocations. |
None
|
**kwargs
|
Unpack[RerankInputDict]
|
The input fields as keyword arguments. |
{}
|
Returns:
| Type | Description |
|---|---|
RerankOutput
|
An instance of |
Input¶
Pass the input as keyword arguments, a positional dictionary, or a positional model object. Pass plugins separately as a keyword argument.
RerankInputDict
¶
Bases: TypedDict
Dictionary form of RerankInput.
Attributes¶
next_token
instance-attribute
¶
next_token: str | None
If the total number of results was greater than could fit in a response,
a token is returned in the nextToken field. You can enter that token
in this field to return the next batch of results.
queries
instance-attribute
¶
queries: Required[Sequence[RerankQuery | RerankQueryDict]]
An array of objects, each of which contains information about a query to submit to the reranker model.
reranking_configuration
instance-attribute
¶
reranking_configuration: Required[RerankingConfiguration | RerankingConfigurationDict]
Contains configurations for reranking.
sources
instance-attribute
¶
sources: Required[Sequence[RerankSource | RerankSourceDict]]
An array of objects, each of which contains information about the sources to rerank.
RerankInput
dataclass
¶
Bases: _SerdeShape
Dataclass for RerankInput structure.
Attributes¶
next_token
class-attribute
instance-attribute
¶
next_token: str | None = ...
If the total number of results was greater than could fit in a response,
a token is returned in the nextToken field. You can enter that token
in this field to return the next batch of results.
queries
class-attribute
instance-attribute
¶
queries: list[RerankQuery] | None = ...
An array of objects, each of which contains information about a query to submit to the reranker model.
reranking_configuration
class-attribute
instance-attribute
¶
reranking_configuration: RerankingConfiguration | None = ...
Contains configurations for reranking.
sources
class-attribute
instance-attribute
¶
sources: list[RerankSource] | None = ...
An array of objects, each of which contains information about the sources to rerank.
Output¶
RerankOutput
dataclass
¶
Bases: _SerdeShape
Dataclass for RerankOutput structure.
Attributes¶
next_token
class-attribute
instance-attribute
¶
next_token: str | None = ...
If the total number of results is greater than can fit in the response,
use this token in the nextToken field when making another request to
return the next batch of results.
response_metadata
class-attribute
instance-attribute
¶
Metadata about the response that produced this output. Use this to recover the request identifiers a service's support team needs in order to investigate a call. Members of the metadata are individually optional.
results
instance-attribute
¶
results: list[RerankResult]
An array of objects, each of which contains information about the results of reranking.