@azure/search-documents
Version:
Azure client library to use AI Search for node.js and browser.
25 lines • 1.29 kB
JavaScript
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { logger } from "../../logger.js";
import { getClient } from "@azure-rest/core-client";
export function createKnowledgeBaseRetrieval(endpointParam, credential, knowledgeBaseName, options = {}) {
const endpointUrl = options.endpoint ?? String(endpointParam);
const prefixFromOptions = options?.userAgentOptions?.userAgentPrefix;
const userAgentInfo = `azsdk-js-search-documents/13.0.0`;
const userAgentPrefix = prefixFromOptions
? `${prefixFromOptions} azsdk-js-api ${userAgentInfo}`
: `azsdk-js-api ${userAgentInfo}`;
const { apiVersion: _, ...updatedOptions } = {
...options,
userAgentOptions: { userAgentPrefix },
loggingOptions: { logger: options.loggingOptions?.logger ?? logger.info },
credentials: {
scopes: options.credentials?.scopes ?? ["https://search.azure.com/.default"],
apiKeyHeaderName: options.credentials?.apiKeyHeaderName ?? "api-key",
},
};
const clientContext = getClient(endpointUrl, credential, updatedOptions);
const apiVersion = options.apiVersion;
return { ...clientContext, apiVersion, knowledgeBaseName };
}
//# sourceMappingURL=knowledgeBaseRetrievalContext.js.map