Skip to content

Integrate AI capabilities into a DevExpress-powered Office File API Web API application.

License

Notifications You must be signed in to change notification settings

DevExpress-Examples/office-file-api-ai-implementation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Office File API – Integrate AI

The following project integrates AI capabilities into a DevExpress-powered Office File API Web API application. This project uses the following AI services:

  • OpenAI API generates descriptions for images, charts and hyperlinks in Microsoft Word and Excel files.
  • Azure AI Language API detects the language for text paragraphs in Word files.
  • Azure AI Translator API translates paragraph text to the chosen language in Word files.

Note

Before you incorporate this solution in your app, please be sure to read and understand terms and conditions of using AI services.

Implementation Details

The project uses the Azure.AI.OpenAI, Azure.AI.TextAnalytics and Azure.AI.Translation.Text NuGet packages. Azure.AI.OpenAI adapts OpenAI's REST APIs for use in non-Azure OpenAI development. Azure.AI.TextAnalytics and Azure.AI.Translation.Text require an Azure subscription. Once you obtain it, create a Language resource and a Translator resource (or a single multi-service resource) in the Azure portal to get your keys and endpoints for client authentication.

OpenAIController includes endpoints to generate image, chart and hyperlink descriptions. The OpenAIClientImageHelper class sends a request to describe an image and obtains a string with a response. The OpenAIClientHyperlinkHelper class sends a request to describe an hyperlink and obtains a string with a response. The OpenAIClientImageHelper.DescribeImageAsync and OpenAIClientHyperlinkHelper.DescribeHyperlinkAsync methods are executed within the corresponding endpoints. For Excel files, charts are converted to images to obtain relevant descriptions.

LanguageController includes the endpoint to detect the language for text paragraphs and generate paragraph transaltions. The AzureAILanguageHelper class sends a request to detect the language of the specified text and returns the language name in the "ISO 693-1" format. The AzureAITranslationHelper class sends a request to translate the given text to the specified language and returns the transaled text string. The AzureAILanguageHelper.DetectTextLanguage and AzureAITranslationHelper.TranslateText methods are executed in the GenerateLanguageSettingsForParagraphs endpoint.

Files to Review

Documentation

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)