You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: AIIntegrationServer/README.md
+10-8Lines changed: 10 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,16 +1,18 @@
1
1
# AIIntegrationServer
2
2
3
-
AIIntegrationServer is an API-only Web API that acts as a proxy between a DevExtreme DataGrid `AIIntegration` component and [Azure OpenAI](https://azure.microsoft.com/en-us/pricing/details/azure-openai/). It exposes endpoints for AI-powered grid column transformations and an assistant chat, forwarding prompts to Azure OpenAI and returning the model response.
3
+
AIIntegrationServer is an API-only backend that connects [Azure OpenAI](https://azure.microsoft.com/en-us/pricing/details/azure-openai/) with AI-powered DevExtreme DataGrid features:
-**Feature-specific endpoints** - Separate routes for AI columns and the AI assistant
10
13
-**Stateless** - No session storage, each request is independent
11
14
-**CORS enabled** - Allows cross-origin requests from client applications
12
-
-**snake_case JSON** - Request/response payloads use `snake_case` property naming
13
-
-**Port 5005** - Runs on HTTP port 5005 and HTTPS port 5006
15
+
-**HTTP/HTTPS Support** - Runs on HTTP port 5005 and HTTPS port 5006
14
16
15
17
## Project Structure
16
18
@@ -35,11 +37,11 @@ AIIntegrationServer/
35
37
36
38
### POST /api/ai/grid-column
37
39
38
-
Runs a chat completion for grid column transformations (temperature `0.7`).
40
+
Runs chat completions for AI columns. Uses `0.7` temperature value.
39
41
40
42
### POST /api/ai/assistant
41
43
42
-
Runs a chat completion for the AI assistant (temperature`0.0`). If the request `data` contains a `responseSchema`property, it is forwarded to Azure OpenAI as a JSON schema response format; otherwise the response is returned as plain JSON.
44
+
Runs chat completions for the AI assistant. Uses`0.0` temperature value. Returns responses in JSON schemas (specified in a request's `responseSchema`parameter). If `responseSchema`is not specified in a request, returns a plain JSON response.
This example demonstrates how to enhance the [DevExtreme DataGrid](https://js.devexpress.com/Documentation/Guide/UI_Components/DataGrid/Overview/) with two AI-powered features: an [AI column](https://js.devexpress.com/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/columns/ai/) that fills cells with values generated from row context, and the [AI Assistant](https://js.devexpress.com/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/aiAssistant/) chat that lets end users control the grid (sort, filter, search, group, page, etc.) through natural-language requests.
9
+
This example uses a minimal ASP.NET Web API backend to configure the following AI-powered [DevExtreme DataGrid](https://js.devexpress.com/Documentation/Guide/UI_Components/DataGrid/Overview/) features:
This example includes a pre-configured ASP.NET Core Web API server (see [AIIntegrationServer](/AIIntegrationServer/)) that acts as a proxy between the client and [Azure OpenAI](https://azure.microsoft.com/en-us/pricing/details/azure-openai/). The server runs at `http://localhost:5005` and exposes the following endpoints:
18
-
-`/api/ai/grid-column` (POST) - Used by the DataGrid AI column to generate cell values.
19
-
-`/api/ai/assistant` (POST) - Used by the AI Assistant to translate chat messages into DataGrid commands. When the request body contains a `responseSchema`, the server forwards it to Azure OpenAI as a structured JSON response format.
20
-
21
-
Credentials are read from [appsettings.json](AIIntegrationServer/appsettings.json) under the `AzureOpenAI` section (`Endpoint`, `ApiKey`, `ModelName`). The sample is preconfigured to use the public DevExpress demo endpoint; replace those values with your own Azure OpenAI deployment for production use. CORS is enabled for `http://localhost:5050` (the ASP.NET Core front-end) and the framework client dev servers.
22
-
23
-
### Configure the AIIntegration object
24
-
25
-
All framework projects share the same client-side pattern:
26
-
27
-
1. A `sendRequest` factory wraps `fetch` and posts `{ prompt, data }` to the chosen endpoint. The request is aborted via `AbortController` if the user cancels, and oversized prompts (≥ 5000 characters) are rejected before any network call.
28
-
29
-
2. Two separate [AIIntegration](https://js.devexpress.com/Documentation/ApiReference/Common_Types/AIIntegration) instances are created with `new DevExpress.aiIntegration.AIIntegration({ sendRequest })` - one bound to the column endpoint, one to the assistant endpoint. They are passed to the DataGrid via the [aiIntegration](https://js.devexpress.com/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/#aiIntegration) option and the [aiAssistant.aiIntegration](https://js.devexpress.com/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/aiAssistant/#aiIntegration) sub-option respectively.
30
-
31
-
### Configure the DataGrid AI column
32
-
33
-
A column with `type: 'ai'` enables automatic cell value generation. The [ai](https://js.devexpress.com/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/columns/ai/) sub-options describe how the model should fill values:
18
+
The [AIIntegrationServer](/AIIntegrationServer/) backend exposes separate endpoints for AI columns and the AI Assistant:
34
19
35
-
-`prompt` - The natural-language instruction sent to the model with row data as context.
36
-
-`mode` - `'auto'` runs the AI for every visible row automatically; `'manual'` waits for user action.
37
-
-`noDataText` - Placeholder shown while values are being generated.
20
+
```js
21
+
const_SERVER_URL='http://localhost:5005/api/ai';
38
22
39
-
### Configure the DataGrid AI Assistant
23
+
constAI_COLUMN_URL=`${_SERVER_URL}/grid-column`;
24
+
constAI_ASSISTANT_URL=`${_SERVER_URL}/assistant`;
25
+
```
40
26
41
-
The [aiAssistant](https://js.devexpress.com/Documentation/ApiReference/UI_Components/dxDataGrid/Configuration/aiAssistant/) option turns on a chat panel that issues structured commands to the grid. The embedded [Chat](https://js.devexpress.com/Documentation/ApiReference/UI_Components/dxChat/) is configured with:
27
+
This example uses endpoint URLs in a factory function to configure two [AIIntegration](https://js.devexpress.com/Documentation/ApiReference/Common_Types/AIIntegration) instances:
42
28
43
-
-`user` - Identifies the end user in the chat data source.
44
-
-`suggestions.items` - Quick-action chips (Help, Filter, Sort, Group). Each item carries a `prompt` payload.
45
-
-`suggestions.onItemClick` - Pushes the suggestion's prompt into the chat data source as a new user (or `help`) message.
46
-
-`onInitialized` - Stores the chat instance reference so suggestions can append messages directly to its data source.
0 commit comments