React Common Types - AIProvider
An object responsible for sending requests to an AI service.
import { AIProvider } from "devextreme/common/ai-integration"
Type:
sendRequest
A function that sends a request to an AI service.
Type:
Function parameters:
params:
Request parameters.
Return Value:
An object with AI response.
App.tsx
- import { AIIntegration } from 'devextreme-react/common/ai-integration';
- const provider = {
- sendRequest: ({ prompt }) => {
- const headers = {
- 'Content-Type': 'application/json',
- // Add any custom headers here
- };
- const promise = fetch('https://example.org/post', {
- method: 'POST',
- headers,
- body: JSON.stringify({ prompt }),
- signal: controller.signal,
- })
- .then(async (response) => {
- const result = await response.json();
- return result.output || '';
- });
- return {
- promise,
- abort: () => {
- // Add an abort request
- },
- };
- },
- };
- const aiIntegration = new AIIntegration(provider);