### Install docintel library Source: https://github.com/automatiza-mg/docintel/blob/main/README.md Command to install the package via Go modules. ```bash go get github.com/automatiza-mg/docintel ``` -------------------------------- ### Analyze a single document Source: https://github.com/automatiza-mg/docintel/blob/main/README.md Example of initializing the client and performing an asynchronous document analysis with automatic polling. ```go package main import ( "context" "fmt" "os" "github.com/automatiza-mg/docintel" ) func main() { client := docintel.NewClient( os.Getenv("AZURE_DOCINTEL_ENDPOINT"), os.Getenv("AZURE_DOCINTEL_KEY"), ) f, err := os.Open("documento.pdf") if err != nil { panic(err) } defer f.Close() ctx := context.Background() location, err := client.AnalyzeDocument(ctx, docintel.AnalyzeDocumentParams{ Document: f, ContentType: "application/pdf", Model: docintel.ModelLayout, Locale: "pt-BR", OutputFormat: docintel.ContentFormatMarkdown, }) if err != nil { panic(err) } // Aguarda a conclusão, consultando em intervalos regulares (ver Configuração). op, err := client.PollResult(ctx, location) if err != nil { panic(err) } fmt.Println(op.AnalyzeResult.Content) } ``` -------------------------------- ### Poll batch analysis results Source: https://github.com/automatiza-mg/docintel/blob/main/README.md Example of polling for the completion of a batch analysis operation. ```go op, err := client.PollBatchResult(ctx, location) if err != nil { panic(err) } fmt.Printf("%d succeeded, %d failed\n", op.Result.SucceededCount, op.Result.FailedCount) ``` -------------------------------- ### Analyze documents in batch Source: https://github.com/automatiza-mg/docintel/blob/main/README.md Example of configuring a batch analysis job using Azure Blob Storage sources. ```go location, err := client.AnalyzeBatch(ctx, docintel.AnalyzeBatchParams{ AzureBlobSource: &docintel.AzureBlobSource{ ContainerURL: "https://storage.blob.core.windows.net/in?sas", Prefix: "inputDocs/", }, ResultContainerURL: "https://storage.blob.core.windows.net/out?sas", ResultPrefix: "batchResults/", OverwriteExisting: true, Model: docintel.ModelLayout, // opcional OutputFormat: docintel.ContentFormatText, // opcional }) ``` -------------------------------- ### Inicialização do Cliente DocIntel Source: https://github.com/automatiza-mg/docintel/blob/main/README.md Configura o cliente com endpoint, chave e opções customizadas como versão da API e transporte HTTP. ```go client := docintel.NewClient(endpoint, key, docintel.WithAPIVersion("2024-11-30"), docintel.WithHTTPClient(customClient), // ex: autenticação via Azure AD ) ``` -------------------------------- ### docintel.NewClient Source: https://github.com/automatiza-mg/docintel/blob/main/README.md Initializes a new DocIntel client with the specified endpoint and API key, supporting custom API versions and HTTP clients for authentication. ```APIDOC ## docintel.NewClient ### Description Creates a new client instance to interact with the DocIntel API. The client manages the API version and HTTP transport layer. ### Signature `func NewClient(endpoint string, key string, options ...Option) *Client` ### Parameters - **endpoint** (string) - Required - The base URL for the DocIntel service. - **key** (string) - Required - The API subscription key. - **options** (...Option) - Optional - Functional options such as `WithAPIVersion` or `WithHTTPClient`. ``` -------------------------------- ### Configuração de Polling para Resultados Source: https://github.com/automatiza-mg/docintel/blob/main/README.md Define o intervalo e o tempo limite para a consulta de resultados de operações de análise. ```go op, err := client.PollResult(ctx, location, docintel.WithPollInterval(5*time.Second), docintel.WithPollTimeout(10*time.Minute), ) ``` -------------------------------- ### AnalyzeBatch Source: https://github.com/automatiza-mg/docintel/blob/main/README.md Initiates an asynchronous batch analysis for documents stored in Azure Blob Storage. ```APIDOC ## AnalyzeBatch ### Description Processes multiple documents stored in Azure Blob Storage. Results are written directly to a specified destination container. ### Parameters - **ctx** (context.Context) - Required - The context for the request. - **params** (docintel.AnalyzeBatchParams) - Required - Configuration including source container URL, destination container URL, model, and output format. ``` -------------------------------- ### AnalyzeDocument Source: https://github.com/automatiza-mg/docintel/blob/main/README.md Initiates an asynchronous document analysis operation. Returns the location of the operation to be used for polling results. ```APIDOC ## AnalyzeDocument ### Description Initiates an asynchronous analysis of a single document. The method returns an operation location that can be used to track the status and retrieve the final result. ### Parameters - **ctx** (context.Context) - Required - The context for the request. - **params** (docintel.AnalyzeDocumentParams) - Required - Parameters including the document file, content type, model, locale, and output format. ``` -------------------------------- ### client.PollResult Source: https://github.com/automatiza-mg/docintel/blob/main/README.md Polls the status of a document analysis operation until completion, timeout, or context cancellation. ```APIDOC ## client.PollResult ### Description Consults the operation status at regular intervals. It automatically handles temporary HTTP errors (429, 500, 502, 503, 504) and respects the `Retry-After` header. ### Signature `func (c *Client) PollResult(ctx context.Context, location string, opts ...PollOption) (*Operation, error)` ### Parameters - **ctx** (context.Context) - Required - Context for cancellation and deadlines. - **location** (string) - Required - The operation location URL. - **opts** (...PollOption) - Optional - Configuration options like `WithPollInterval` and `WithPollTimeout`. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.