KnowledgeBaseRetrievalClient Class

KnowledgeBaseRetrievalClient.

Constructor

KnowledgeBaseRetrievalClient(endpoint: str, credential: AzureKeyCredential | TokenCredential, **kwargs: Any)

Parameters

Name Description
endpoint
Required
str

The endpoint URL of the search service. Required.

credential
Required

Credential used to authenticate requests to the service. Is either a key credential type or a token credential type. Required.

knowledge_base_name
Required
str

The name of the knowledge base. Required.

Keyword-Only Parameters

Name Description
api_version

The API version to use for this operation. Known values are listed on the ApiVersion enum. Default value is ApiVersion.V2026_10_01. Note that overriding this default value may result in unsupported behavior.

audience
str

Sets the Audience to use for authentication with Microsoft Entra ID. The audience is not considered when using a shared key. If audience is not provided, the public cloud audience will be assumed.

Methods

close
retrieve

KnowledgeBase retrieves relevant data from backing stores.

retrieve_stream

Retrieves relevant data from backing stores and streams progress and results as server-sent events.

Process the response incrementally using server-sent event framing. Each event contains an event name and a JSON-encoded data payload. The stream ends with either a response.completed event or an error event. OpenAPI 2.0 represents the response body as a string, so generated clients may expose the raw response without typed event parsing. Do not deserialize the complete response body as a single JSON document.

send_request

Runs the network request through the client's chained policies.


>>> from azure.core.rest import HttpRequest
>>> request = HttpRequest("GET", "https://www.example.org/")
<HttpRequest [GET], url: 'https://www.example.org/'>
>>> response = client.send_request(request)
<HttpResponse: 200 OK>

For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request

close

close() -> None

retrieve

KnowledgeBase retrieves relevant data from backing stores.

retrieve(retrieval_request: KnowledgeBaseRetrievalRequest | KnowledgeBaseRetrievalRequest | IO[bytes], *, query_source_authorization: str | None = None, **kwargs: Any) -> KnowledgeBaseRetrievalResponse

Parameters

Name Description
retrieval_request
Required

The retrieval request to process. Is either a KnowledgeBaseRetrievalRequest type or a IO[bytes] type. Required.

Keyword-Only Parameters

Name Description
query_source_authorization
str

Token identifying the user for which the query is being executed. This token is used to enforce security restrictions on documents. Default value is None.

Default value: None

Returns

Type Description

KnowledgeBaseRetrievalResponse. The KnowledgeBaseRetrievalResponse is compatible with MutableMapping

Exceptions

Type Description

retrieve_stream

Retrieves relevant data from backing stores and streams progress and results as server-sent events.

Process the response incrementally using server-sent event framing. Each event contains an event name and a JSON-encoded data payload. The stream ends with either a response.completed event or an error event. OpenAPI 2.0 represents the response body as a string, so generated clients may expose the raw response without typed event parsing. Do not deserialize the complete response body as a single JSON document.

retrieve_stream(retrieval_request: KnowledgeBaseRetrievalRequest | KnowledgeBaseRetrievalRequest | IO[bytes], *, query_source_authorization: str | None = None, **kwargs: Any) -> Stream[KnowledgeBaseRetrievalStartedEvent | KnowledgeBaseActivityStartedEvent | KnowledgeBaseActivityRecord | KnowledgeBaseAnswerCompletedEvent | list[azure.search.documents.knowledgebases.models._models.KnowledgeBaseReference] | KnowledgeBaseStreamErrorEvent | KnowledgeBaseResponseCompletedEvent]

Parameters

Name Description
retrieval_request
Required

The retrieval request to process. Is either a KnowledgeBaseRetrievalRequest type or a IO[bytes] type. Required.

Keyword-Only Parameters

Name Description
query_source_authorization
str

Token identifying the user for which the query is being executed. This token is used to enforce security restrictions on documents. Default value is None.

Default value: None

Returns

Type Description
<xref:azure.search.documents.Stream>[KnowledgeBaseRetrievalStartedEvent,

An instance of Stream that iterates over KnowledgeBaseRetrievalStartedEvent or KnowledgeBaseActivityStartedEvent or KnowledgeBaseActivityRecord or KnowledgeBaseAnswerCompletedEvent or list of KnowledgeBaseReference or KnowledgeBaseStreamErrorEvent or KnowledgeBaseResponseCompletedEvent

Exceptions

Type Description

send_request

Runs the network request through the client's chained policies.


>>> from azure.core.rest import HttpRequest
>>> request = HttpRequest("GET", "https://www.example.org/")
<HttpRequest [GET], url: 'https://www.example.org/'>
>>> response = client.send_request(request)
<HttpResponse: 200 OK>

For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request

send_request(request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse

Parameters

Name Description
request
Required

The network request you want to make. Required.

Keyword-Only Parameters

Name Description
stream

Whether the response payload will be streamed. Defaults to False.

Default value: False

Returns

Type Description

The response of your network call. Does not do error handling on your response.