Skip to content

Commit

Permalink
[Document Intelligence] Release 1.0.0 GA (#31746)
Browse files Browse the repository at this point in the history
## Release
Marks the GA 1.0.0 release for `@azure-rest/ai-document-intelligence`
## Codegen
Regenerated from
https://github.com/Azure/azure-rest-api-specs/tree/main/specification/ai/DocumentIntelligence
**Commit Id**:
[67c84bd51ccfca841c39f274b9147347abed3f66](Azure/azure-rest-api-specs@67c84bd)
**API Version**: 2024-11-30
## Changelog

### Features Added
- New `parseOperationIdFromResponse` method has been added to parse
`operationId` from the initial response of batch analysis requests which
can later be used to get the analysis results.
  ```js
      // Example
      const initialResponse = await client
.path("/documentModels/{modelId}:analyzeBatch", "prebuilt-layout")
        .post({
          contentType: "application/json",
          body: {
            azureBlobSource: {
              containerUrl: batchTrainingFilesContainerUrl(),
            },
            resultContainerUrl: batchTrainingFilesResultContainerUrl(),
            resultPrefix: "result",
          },
        });

      if (isUnexpected(initialResponse)) {
        throw initialResponse.body.error;
      }
const batchOperationId = parseOperationIdFromResponse(initialResponse);

      const response = await client
        .path(
          "/documentModels/{modelId}/analyzeBatchResults/{resultId}",
          "prebuilt-layout",
          batchOperationId,
        )
        .get();
  ```
Look at changelog for more features and changes.

---------

Co-authored-by: Deyaaeldeen Almahallawi <[email protected]>
  • Loading branch information
HarshaNalluru and deyaaeldeen authored Dec 17, 2024
1 parent 203036d commit 7644726
Show file tree
Hide file tree
Showing 78 changed files with 1,948 additions and 1,374 deletions.
58 changes: 52 additions & 6 deletions common/config/rush/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

119 changes: 103 additions & 16 deletions sdk/documentintelligence/ai-document-intelligence-rest/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,114 @@
# Release History

## 1.0.0 (Unreleased)
## 1.0.0 (2024-12-16)

### Features Added

- Exports method `streamToUint8Array` to support converting a `NodeJS.ReadableStream` to a `Uint8Array`. This is necessary to read the pdf and png responses from the results of an analysis.
```js
- Adds `streamToUint8Array`, a convenience function that buffers a `NodeJS.ReadableStream` in a `Uint8Array`. It can be used to read the pdf and png responses from the results of an analysis.

```ts
import DocumentIntelligence from "@azure-rest/ai-document-intelligence";
import { streamToUint8Array } from "@azure-rest/ai-document-intelligence";

const client = DocumentIntelligence("<DOCUMENT_INTELLIGENCE_ENDPOINT>", {
key: "<DOCUMENT_INTELLIGENCE_API_KEY>",
});

// Do analysis on you document and get the resultId, figureId

// Example for the figures api that provides an image output
const output = await client
.path(
"/documentModels/{modelId}/analyzeResults/{resultId}/figures/{figureId}",
"prebuilt-layout",
operationId,
figureId,
)
.get()
.asNodeStream();

if (output.status !== "200" || !output.body) {
throw new Error("The response was unexpected.");
}
const output = await client
.path(
"/documentModels/{modelId}/analyzeResults/{resultId}/figures/{figureId}",
"prebuilt-layout",
resultId,
figureId
)
.get()
.asNodeStream(); // output.body would be NodeJS.ReadableStream

if (output.status !== "200" || !output.body) {
throw new Error("The response was unexpected, expected NodeJS.ReadableStream in the body.");
}

const imageData = await streamToUint8Array(output.body);
fs.promises.writeFile(`./figures/${figureId}.png`, imageData); // Or you can consume the NodeJS.ReadableStream directly
```

- Adds `parseResultIdFromResponse`, a convenience function that extracts the `operationId` from the batch analysis response.

```js
// Example
const initialResponse = await client
.path("/documentModels/{modelId}:analyzeBatch", "prebuilt-layout")
.post({
contentType: "application/json",
body: {
azureBlobSource: {
containerUrl: batchTrainingFilesContainerUrl(),
},
resultContainerUrl: batchTrainingFilesResultContainerUrl(),
resultPrefix: "result",
},
});

if (isUnexpected(initialResponse)) {
throw initialResponse.body.error;
}
const batchResultId = parseResultIdFromResponse(initialResponse);

const response = await client
.path(
"/documentModels/{modelId}/analyzeBatchResults/{resultId}",
"prebuilt-layout",
batchResultId
)
.get();
```

- Changes the following interfaces as follows:

- `AnalyzeBatchDocumentsBodyParam`:
- Updates `body` to be required.
- `AnalyzeBatchOperationOutput`:
- Adds `resultId`.
- `AnalyzeDocumentBodyParam`:
- Changes `body` from optional to required.
- `DocumentClassifierDetailsOutput`:
- Adds `modifiedDateTime`.
- `DocumentModelDetailsOutput`:
- Adds `modifiedDateTime`.

- Introduces new interfaces to define query parameters for document analysis requests, allowing customizable `style` and `explode` options:
- **AnalyzeBatchDocumentsFeaturesQueryParam**: Accepts DocumentAnalysisFeature[] values.
- **AnalyzeBatchDocumentsOutputQueryParam**: Accepts AnalyzeOutputOption[] values.
- **AnalyzeBatchDocumentsQueryFieldsQueryParam**: Accepts string[] values.
- **AnalyzeDocumentFeaturesQueryParam**: Accepts DocumentAnalysisFeature[] values.
- **AnalyzeDocumentFromStreamFeaturesQueryParam**: Accepts DocumentAnalysisFeature[] values.

### Breaking Changes

- Removes the `poller.getOperationId()` for a given polling operation. Use `parseResultIdFromResponse` to extract the `operationId` directly.
- `getLongRunningPoller` function is not async anymore, do not `await` on it.

### Other Changes

The following types are renamed

- `CopyAuthorization` to `ModelCopyAuthorization`
- `ErrorResponseOutput` to `DocumentIntelligenceErrorResponseOutput`
- `ErrorModelOutput` to `DocumentIntelligenceErrorOutput`
- `InnerErrorOutput` to `DocumentIntelligenceInnerErrorOutput`
- `WarningOutput` to `DocumentIntelligenceWarningOutput`
- `ContentFormat` to `DocumentContentFormat`
- `ContentFormatOutput` to `DocumentContentFormatOutput`
- `OperationDetailsOutputParent` to `DocumentIntelligenceOperationDetailsOutputParent`
- `OperationDetailsOutput` to `DocumentIntelligenceOperationDetailsOutput`
- `OperationStatusOutput` to `DocumentIntelligenceOperationStatusOutput`
- `ResourceDetailsOutput` to `DocumentIntelligenceResourceDetailsOutput`
- `PagedOperationDetailsOutput` to `PagedDocumentIntelligenceOperationDetailsOutput`
- `GetResourceInfo` to `GetResourceDetails`

## 1.0.0-beta.3 (2024-08-20)

### Features Added
Expand Down
Loading

0 comments on commit 7644726

Please sign in to comment.