Skip to content

DevExpress-Examples/devextreme-datagrid-ai-integration

Repository files navigation

DevExtreme DataGrid – Azure OpenAI Integration (.NET)

This example uses an ASP.NET Web API backend to configure the following AI-powered DevExtreme DataGrid features:

Example image

Implementation Details

The AIIntegrationServer backend exposes separate endpoints for AI columns and the AI Assistant:

const _SERVER_URL = 'http://localhost:5005/api/ai';

const AI_COLUMN_URL = `${_SERVER_URL}/grid-column`;
const AI_ASSISTANT_URL = `${_SERVER_URL}/assistant`;

This example uses endpoint URLs in a factory function to configure two AIIntegration instances:

function createSendRequest(url) {
    return ({ prompt, data }) => {
        const controller = new AbortController();
        const signal = controller.signal;

        const promise = fetch(url, {
            method: 'POST',
            headers: { 'Content-Type': 'application/json' },
            body: JSON.stringify({ prompt, data }),
            signal,
        })
            .then(response => response.json())
            .then(result => {
                return result.content;
            });

        return {
            promise,
            abort: () => controller.abort(),
        };
    };
}

const columnAiIntegration = new DevExpress.aiIntegration.AIIntegration({
    sendRequest: createSendRequest(AI_COLUMN_URL),
});

const assistantAiIntegration = new DevExpress.aiIntegration.AIIntegration({
    sendRequest: createSendRequest(AI_ASSISTANT_URL),
});

Run the Server

To run the backend, follow the instructions in the following README: AIIntegrationServer.

Files to Review

Documentation

More Examples

Does This Example Address Your Development Requirements/Objectives?

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

About

This example uses an ASP.NET Web API backend to configure AI-powered DevExtreme DataGrid features.

Topics

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Contributors