KnowledgeRetrievalClient class
Class used to perform operations against a knowledge base.
Constructors
| Knowledge |
Creates an instance of KnowledgeRetrievalClient. Example usage:
|
Properties
| endpoint | The endpoint of the search service |
| knowledge |
The name of the knowledge base |
| pipeline | A reference to the internal HTTP pipeline for use with raw requests |
| service |
The service version to use when communicating with the service. |
Methods
| retrieve(Knowledge |
Retrieves relevant data from the backing stores configured by the knowledge base. |
| retrieve |
Retrieves relevant data from the backing stores, streaming progress and results as server-sent events as they become available instead of waiting for the full retrieval to complete. The returned async iterable yields events until the terminal Example Iterate typed retrieval events.
|
Constructor Details
KnowledgeRetrievalClient(string, string, KeyCredential | TokenCredential, KnowledgeRetrievalClientOptions)
Creates an instance of KnowledgeRetrievalClient.
Example usage:
import { KnowledgeRetrievalClient, AzureKeyCredential } from "@azure/search-documents";
const knowledgeRetrievalClient = new KnowledgeRetrievalClient(
"<endpoint>",
"<knowledgeBaseName>",
new AzureKeyCredential("<apiKey>"),
);
new KnowledgeRetrievalClient(endpoint: string, knowledgeBaseName: string, credential: KeyCredential | TokenCredential, options?: KnowledgeRetrievalClientOptions)
Parameters
- endpoint
-
string
The endpoint of the search service
- knowledgeBaseName
-
string
The name of the knowledge base
- credential
Used to authenticate requests to the service.
- options
- KnowledgeRetrievalClientOptions
Used to configure the Search client.
Property Details
endpoint
The endpoint of the search service
endpoint: string
Property Value
string
knowledgeBaseName
The name of the knowledge base
knowledgeBaseName: string
Property Value
string
pipeline
A reference to the internal HTTP pipeline for use with raw requests
pipeline: Pipeline
Property Value
serviceVersion
The service version to use when communicating with the service.
serviceVersion: string
Property Value
string
Method Details
retrieve(KnowledgeBaseRetrievalRequest, RetrieveOptions)
Retrieves relevant data from the backing stores configured by the knowledge base.
function retrieve(retrievalRequest: KnowledgeBaseRetrievalRequest, options?: RetrieveOptions): Promise<KnowledgeBaseRetrievalResponse>
Parameters
- retrievalRequest
- KnowledgeBaseRetrievalRequest
The retrieval request to process.
- options
- RetrieveOptions
Options to the retrieve operation.
Returns
Promise<KnowledgeBaseRetrievalResponse>
The completed retrieval response.
retrieveStream(KnowledgeBaseRetrievalRequest, RetrieveStreamOptions)
Retrieves relevant data from the backing stores, streaming progress and results as server-sent events as they become available instead of waiting for the full retrieval to complete.
The returned async iterable yields events until the terminal response.completed event, or
an error event if the retrieval fails after the stream has started. Narrow on the event
property to access the typed payload.
Example
Iterate typed retrieval events.
import { KnowledgeRetrievalClient, AzureKeyCredential } from "@azure/search-documents";
const client = new KnowledgeRetrievalClient(
"<endpoint>",
"<knowledgeBaseName>",
new AzureKeyCredential("<apiKey>"),
);
for await (const event of await client.retrieveStream({
intents: [{ type: "semantic", search: "Summarize the indexed information." }],
includeActivity: true,
})) {
if (event.event === "activity.completed") {
console.log(`Activity ${event.data.id} took ${event.data.elapsedInMs}ms`);
} else if (event.event === "response.completed") {
console.log(event.data.response.response);
} else if (event.event === "error") {
throw new Error(event.data.error.message);
}
}
function retrieveStream(retrievalRequest: KnowledgeBaseRetrievalRequest, options?: RetrieveStreamOptions): Promise<AsyncIterable<KnowledgeBaseRetrievalStreamEvent>>
Parameters
- retrievalRequest
- KnowledgeBaseRetrievalRequest
The retrieval request to process.
- options
- RetrieveStreamOptions
Options to the retrieve stream operation.
Returns
Promise<AsyncIterable<KnowledgeBaseRetrievalStreamEvent>>
An async iterable of typed server-sent events.