Skip to content

retrieve

Operation

retrieve

retrieve(request: RetrieveInput | RetrieveInputDict | None = None, /, *, plugins: list[Plugin] | None = None, **kwargs: Unpack[RetrieveInputDict]) -> RetrieveOutput

Queries a knowledge base and retrieves information from it.

Parameters:

Name Type Description Default
request RetrieveInput | RetrieveInputDict | 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[RetrieveInputDict]

The input fields as keyword arguments.

{}

Returns:

Type Description
RetrieveOutput

An instance of RetrieveOutput.

retrieve async

retrieve(request: RetrieveInput | RetrieveInputDict | None = None, /, *, plugins: list[Plugin] | None = None, **kwargs: Unpack[RetrieveInputDict]) -> RetrieveOutput

Queries a knowledge base and retrieves information from it.

Parameters:

Name Type Description Default
request RetrieveInput | RetrieveInputDict | 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[RetrieveInputDict]

The input fields as keyword arguments.

{}

Returns:

Type Description
RetrieveOutput

An instance of RetrieveOutput.

Input

Pass the input as keyword arguments, a positional dictionary, or a positional model object. Pass plugins separately as a keyword argument.

RetrieveInputDict

Bases: TypedDict

Dictionary form of RetrieveInput.

Attributes

guardrail_configuration instance-attribute
guardrail_configuration: GuardrailConfiguration | GuardrailConfigurationDict | None

Guardrail settings.

knowledge_base_id instance-attribute
knowledge_base_id: Required[str]

The unique identifier of the knowledge base to query.

next_token instance-attribute
next_token: str | None

If there are more results than can fit in the response, the response returns a nextToken. Use this token in the nextToken field of another request to retrieve the next batch of results.

retrieval_configuration instance-attribute

Contains configurations for the knowledge base query and retrieval process. For more information, see Query configurations.

retrieval_query instance-attribute

Contains the query to send the knowledge base.

user_context instance-attribute
user_context: UserContext | UserContextDict | None

Contains information about the user making the request. This is used for access control filtering to ensure that retrieval results only include documents the user is authorized to access.

RetrieveInput dataclass

Bases: _SerdeShape

Dataclass for RetrieveInput structure.

Attributes

guardrail_configuration class-attribute instance-attribute
guardrail_configuration: GuardrailConfiguration | None = ...

Guardrail settings.

knowledge_base_id class-attribute instance-attribute
knowledge_base_id: str | None = ...

The unique identifier of the knowledge base to query.

next_token class-attribute instance-attribute
next_token: str | None = ...

If there are more results than can fit in the response, the response returns a nextToken. Use this token in the nextToken field of another request to retrieve the next batch of results.

retrieval_configuration class-attribute instance-attribute
retrieval_configuration: KnowledgeBaseRetrievalConfiguration | None = ...

Contains configurations for the knowledge base query and retrieval process. For more information, see Query configurations.

retrieval_query class-attribute instance-attribute
retrieval_query: KnowledgeBaseQuery | None = ...

Contains the query to send the knowledge base.

user_context class-attribute instance-attribute
user_context: UserContext | None = ...

Contains information about the user making the request. This is used for access control filtering to ensure that retrieval results only include documents the user is authorized to access.

Output

RetrieveOutput dataclass

Bases: _SerdeShape

Dataclass for RetrieveOutput structure.

Attributes

guardrail_action class-attribute instance-attribute
guardrail_action: str | None = ...

Specifies if there is a guardrail intervention in the response.

next_token class-attribute instance-attribute
next_token: str | None = ...

If there are more results than can fit in the response, the response returns a nextToken. Use this token in the nextToken field of another request to retrieve the next batch of results.

response_metadata class-attribute instance-attribute
response_metadata: ResponseMetadata = ...

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.

retrieval_results instance-attribute
retrieval_results: list[KnowledgeBaseRetrievalResult]

A list of results from querying the knowledge base.