mirror of
https://github.com/hanzoai/azure-sdk-for-js.git
synced 2026-10-30 19:51:51 +00:00
Overhauls tests and samples for Azure Cognitive Services for Language SDKs by implementing safe secret standards: - Updates `test-resources.bicep` to not output API keys nor SAS tokens - Updates the tests to retrieve API keys using the arm client - Updates the tests to create SAS tokens for Storage container access - Updates the samples and snippets to use Entra ID authentication - Fix live tests by enabling SAS access to the persistent storage account Live tests run: https://dev.azure.com/azure-sdk/internal/_build/results?buildId=4694655&view=results
47 lines
1.6 KiB
JavaScript
47 lines
1.6 KiB
JavaScript
// Copyright (c) Microsoft Corporation.
|
|
// Licensed under the MIT License.
|
|
|
|
/**
|
|
* This sample shows how to get the full information about a custom model by its model ID, including information about
|
|
* the document types in the model and their field schemas.
|
|
*
|
|
* @summary get information about a model by its ID
|
|
*/
|
|
|
|
const DocumentIntelligence = require("@azure-rest/ai-document-intelligence").default,
|
|
{ isUnexpected } = require("@azure-rest/ai-document-intelligence");
|
|
const { DefaultAzureCredential } = require("@azure/identity");
|
|
require("dotenv/config");
|
|
|
|
async function main() {
|
|
const client = DocumentIntelligence(
|
|
process.env["DOCUMENT_INTELLIGENCE_ENDPOINT"] || "<cognitive services endpoint>",
|
|
new DefaultAzureCredential(),
|
|
);
|
|
|
|
// The model ID to query. This can be any model ID, not just a custom model, so for example
|
|
// the following sample uses `"prebuilt-idDocument"`, but you can change it to any model ID
|
|
// you'd like to inspect.
|
|
const modelId = "prebuilt-idDocument";
|
|
const model = await client.path("/documentModels/{modelId}", modelId).get();
|
|
|
|
if (isUnexpected(model)) {
|
|
throw model.body.error;
|
|
}
|
|
|
|
console.log("ID", model.body.modelId);
|
|
console.log("Created:", model.body.createdDateTime);
|
|
console.log("Description: ", model.body.description || "<none>");
|
|
|
|
console.log("Document Types:");
|
|
for (const [docType, { fieldSchema }] of Object.entries(model.body.docTypes || {})) {
|
|
// We can also programmatically access a schema of the fields.
|
|
console.log("-", docType, JSON.stringify(fieldSchema, undefined, 2));
|
|
}
|
|
}
|
|
|
|
main().catch((error) => {
|
|
console.error("An error occurred:", error);
|
|
process.exit(1);
|
|
});
|