Skip to content

Commit 9b6f922

Browse files
Integrated latest changes at 09-27-2025 10:30:20 AM
1 parent 9652e4f commit 9b6f922

File tree

7 files changed

+47
-31
lines changed

7 files changed

+47
-31
lines changed

ej2-javascript-toc.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@
172172
<a href="/ej2-javascript/ai-assistview/ai-integrations/gemini-integration">Integration with Google Gemini</a>
173173
</li>
174174
<li>
175-
<a href="/ej2-javascript/ai-assistview/ai-integrations/openai-integration">Integration with Open AI</a>
175+
<a href="/ej2-javascript/ai-assistview/ai-integrations/openai-integration">Integration with Azure Open AI</a>
176176
</li>
177177
</ul>
178178
</li>

ej2-javascript/ai-assistview/ai-integrations/openai-integration.md

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
---
22
layout: post
3-
title: Open AI in ##Platform_Name## AI AssistView control | Syncfusion
4-
description: Checkout and learn about Integration of ChatGPT Open AI with ##Platform_Name## AI AssistView control of Syncfusion Essential JS 2 and more.
3+
title: Azure Open AI in ##Platform_Name## AI AssistView control | Syncfusion
4+
description: Checkout and learn about Integration of Azure Open AI with ##Platform_Name## AI AssistView control of Syncfusion Essential JS 2 and more.
55
platform: ej2-javascript
66
control: AI AssistView
77
publishingplatform: ##Platform_Name##
88
documentation: ug
99
domainurl: ##DomainURL##
1010
---
1111

12-
# Integration of Open AI With ##Platform_Name## AI AssistView control
12+
# Integration of Azure Open AI With ##Platform_Name## AI AssistView control
1313

14-
The Syncfusion AI AssistView supports integration with [OpenAI](https://platform.openai.com/docs/overview), enabling advanced conversational AI features in your React applications.
14+
The Syncfusion AI AssistView supports integration with [Azure Open AI](https://microsoft.github.io/PartnerResources/skilling/ai-ml-academy/resources/openai), enabling advanced conversational AI features in your applications.
1515

1616
## Getting Started with the ##Platform_Name## AI AssistView control
1717

18-
Before integrating Open AI, ensure that the Syncfusion AI AssistView control is correctly rendered in your React app:
18+
Before integrating Azure Open AI, ensure that the Syncfusion AI AssistView control is correctly rendered in your app:
1919

2020
[##Platform_Name## Getting Started Guide](../getting-started)
2121

2222
## Prerequisites
2323

2424
* Requires `Node.js` (v16 or higher) and `npm`.
25-
* OpenAI account to generate an API key for accessing the `OpenAI` API
25+
* An Azure account with access to `Azure Open AI` services and a generated API key.
2626
* Syncfusion AI AssistView for ##Platform_Name## `@syncfusion/ej2-interactive-chat` installed in your project.
2727

2828
## Install Dependencies
@@ -37,25 +37,28 @@ npm install @syncfusion/ej2-react-interactive-chat --save
3737

3838
## Generate API Key
3939

40-
1. Go to [Open AI](https://platform.openai.com/docs/overview) and sign in with your Google account. If you don’t have one, create a new account.
40+
1. Log in to the [Azure Portal](https://portal.azure.com/#home) and navigate to your Azure Open AI resource.
4141

42-
2. Once logged in, click on your profile icon in the top-right corner and select `API Keys` from the dropdown menu.
42+
2. Under Resource Management, select Keys and Endpoint to retrieve your API key and endpoint URL.
4343

44-
3. Click the `+ Create new secret key` button. You’ll be prompted to name the key (optional). Confirm to generate the key.
44+
3. Copy the API key, endpoint, and deployment name (e.g., gpt-4o-mini). Ensure the API version (e.g., 2024-07-01-preview) matches your resource configuration.
4545

46-
4. Your API key will be displayed once. Copy it and store it securely, as it won’t be shown again.
46+
4. Store these values securely, as they will be used in your application.
4747

48-
> `Security Note`: Never commit the API key to version control. Use environment variables or a secret manager for production.
48+
> `Security Note`: Never expose your API key in client-side code for production applications. Use a server-side proxy or environment variables to manage sensitive information securely.
4949
5050
## Integration Open AI with ##Platform_Name## AI AssistView control
5151

52-
Create ##Platform_Name## application to integrate the Open AI with AI AssistView component with the respective files
52+
Create ##Platform_Name## application to integrate the Open AI with AI AssistView component with the respective files:
5353

54-
* Add your generated `API Key` at the line
54+
* Update the following configuration values with your Azure Open AI details:
5555

5656
```bash
5757

58-
const openaiApiKey = 'Place your API key here';
58+
const azureOpenAIApiKey = 'Your_Azure_OpenAI_API_Key';
59+
const azureOpenAIEndpoint = 'Your_Azure_OpenAI_Endpoint';
60+
const azureOpenAIApiVersion = 'Your_Azure_OpenAI_API_Version';
61+
const azureDeploymentName = 'Your_Deployment_Name';
5962

6063
```
6164

@@ -96,4 +99,4 @@ npm start
9699

97100
```
98101

99-
Open `http://localhost:3000` to interact with your Open AI for dynamic response.
102+
Open `http://localhost:3000` to interact with your Azure Open AI for dynamic response.

ej2-javascript/code-snippet/ai-assistview/ai-integrations/gemini-ai/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ import { AIAssistView } from '@syncfusion/ej2-interactive-chat';
5757
stopStreaming = false;
5858
await streamResponse(response);
5959
} catch (error) {
60-
console.error('Error fetching Gemini response:', error);
6160
aiAssistView.addPromptResponse(
6261
'⚠️ Something went wrong while connecting to the AI service. Please check your API key or try again later.'
6362
);

ej2-javascript/code-snippet/ai-assistview/ai-integrations/gemini-ai/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ async function onPromptRequest(args: any) {
6060
stopStreaming = false;
6161
await streamResponse(response);
6262
} catch (error) {
63-
console.error('Error fetching Gemini response:', error);
6463
aiAssistView.addPromptResponse(
6564
'⚠️ Something went wrong while connecting to the AI service. Please check your API key or try again later.'
6665
);

ej2-javascript/code-snippet/ai-assistview/ai-integrations/open-ai/index.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import { AIAssistView } from '@syncfusion/ej2-interactive-chat';
22
import marked from 'marked';
33

4-
// Initialize Gemini API (using OpenAI API in this case)
5-
let openaiApiKey = ''; // Replace with your actual API key
4+
const azureOpenAIApiKey = ''; // replace your key
5+
const azureOpenAIEndpoint = ''; // replace your endpoint
6+
const azureOpenAIApiVersion = ''; // replace to match your resource
7+
const azureDeploymentName = ''; // your Azure OpenAI deployment name
68
let stopStreaming = false;
79
let suggestions = [
810
'What are the best tools for organizing my tasks?',
@@ -48,11 +50,16 @@ async function streamResponse(response) {
4850
}
4951

5052
function onPromptRequest(args) {
51-
fetch('https://api.openai.com/v1/chat/completions', {
53+
const url =
54+
azureOpenAIEndpoint.replace(/\/$/, '') +
55+
`/openai/deployments/${encodeURIComponent(azureDeploymentName)}/chat/completions` +
56+
`?api-version=${encodeURIComponent(azureOpenAIApiVersion)}`;
57+
58+
fetch(url, {
5259
method: 'POST',
5360
headers: {
5461
'Content-Type': 'application/json',
55-
Authorization: `Bearer ${openaiApiKey}`,
62+
Authorization: azureOpenAIApiKey,
5663
},
5764
body: JSON.stringify({
5865
model: 'gpt-4o-mini',
@@ -68,8 +75,8 @@ function onPromptRequest(args) {
6875
streamResponse(responseText);
6976
})
7077
.catch(error => {
71-
aiAssistView.addPromptResponse('⚠️ Something went wrong while connecting to the AI service. Please check your API key or try again later.');
72-
stopStreaming = true; // Ensure streaming is stopped
78+
aiAssistView.addPromptResponse('⚠️ Something went wrong while connecting to the AI service. Please check your API key, Deployment model, endpoint or try again later.', true);
79+
stopStreaming = true;
7380
});
7481
}
7582

ej2-javascript/code-snippet/ai-assistview/ai-integrations/open-ai/index.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ import { AIAssistView } from '@syncfusion/ej2-interactive-chat';
22
import marked from 'marked';
33

44
// Initialize Gemini API (using OpenAI API in this case)
5-
let openaiApiKey = ''; // Replace with your actual API key
5+
const azureOpenAIApiKey = ''; // replace your key
6+
const azureOpenAIEndpoint = ''; // replace your endpoint
7+
const azureOpenAIApiVersion = ''; // replace to match your resource
8+
const azureDeploymentName = ''; // your Azure OpenAI deployment name
69
let stopStreaming = false;
710
let suggestions = [
811
'What are the best tools for organizing my tasks?',
@@ -48,11 +51,16 @@ async function streamResponse(response: string) {
4851
}
4952

5053
function onPromptRequest(args:any) {
51-
fetch('https://api.openai.com/v1/chat/completions', {
54+
const url =
55+
azureOpenAIEndpoint.replace(/\/$/, '') +
56+
`/openai/deployments/${encodeURIComponent(azureDeploymentName)}/chat/completions` +
57+
`?api-version=${encodeURIComponent(azureOpenAIApiVersion)}`;
58+
59+
fetch(url, {
5260
method: 'POST',
5361
headers: {
5462
'Content-Type': 'application/json',
55-
Authorization: `Bearer ${openaiApiKey}`,
63+
Authorization: azureOpenAIApiKey,
5664
},
5765
body: JSON.stringify({
5866
model: 'gpt-4o-mini',
@@ -67,9 +75,9 @@ function onPromptRequest(args:any) {
6775
stopStreaming = false;
6876
streamResponse(responseText);
6977
})
70-
.catch(error => {
71-
aiAssistView.addPromptResponse('⚠️ Something went wrong while connecting to the AI service. Please check your API key or try again later.');
72-
stopStreaming = true; // Ensure streaming is stopped
78+
.catch((error: unknown) => {
79+
aiAssistView.addPromptResponse('⚠️ Something went wrong while connecting to the AI service. Please check your API key, Deployment model, endpoint or try again later.', true);
80+
stopStreaming = true;
7381
});
7482
}
7583

ej2-typescript-toc.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@
177177
<a href="/ej2-typescript/ai-assistview/ai-integrations/gemini-integration">Integration with Google Gemini</a>
178178
</li>
179179
<li>
180-
<a href="/ej2-typescript/ai-assistview/ai-integrations/openai-integration">Integration with Open AI</a>
180+
<a href="/ej2-typescript/ai-assistview/ai-integrations/openai-integration">Integration with Azure Open AI</a>
181181
</li>
182182
</ul>
183183
</li>

0 commit comments

Comments
 (0)