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: blazor/smart-ai-solutions/ai/azure-openai.md
+49-45Lines changed: 49 additions & 45 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
---
2
2
layout: post
3
-
title: Using Azure OpenAI with Syncfusion Blazor AI | Syncfusion
3
+
title: Azure OpenAI Integration with Syncfusion Blazor AI | Syncfusion
4
4
description: Learn how to set up and use Syncfusion.Blazor.AI with Azure OpenAI for AI-powered features in your Blazor apps, including configuration and examples.
5
5
platform: Blazor
6
6
control: AI Integration
@@ -9,15 +9,12 @@ documentation: ug
9
9
10
10
# Azure OpenAI Integration with Syncfusion® Blazor AI
11
11
12
-
## Introduction
13
-
14
-
This section demonstrates configuring and using the [Syncfusion.Blazor.AI](https://www.nuget.org/packages/Syncfusion.Blazor.AI) package with [Azure OpenAI](https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/create-resource) to enable AI functionalities in Blazor applications. The package provides seamless integration with Azure OpenAI's API, empowering Syncfusion<supstyle="font-size:70%">®</sup> Blazor components with intelligent features such as natural language querying, data analysis, and content processing.
12
+
The [Syncfusion Blazor AI](https://www.nuget.org/packages/Syncfusion.Blazor.AI) library enables seamless integration with [Azure OpenAI](https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/create-resource) to add AI-driven features to Blazor applications. These features include natural language querying (converting plain English queries to structured data filters), data analysis (processing and summarizing datasets), and content processing (generating or refining text).
15
13
16
14
## Prerequisites
17
15
18
-
Before integrating Azure OpenAI with your Blazor application, ensure you have:
19
-
20
-
* Installed the following NuGet packages:
16
+
To integrate Azure OpenAI with a Blazor WebApp Server, ensure the following:
*[Deployed an Azure OpenAI Service resource and model](https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/create-resource) to obtain values for `apiKey`, `deploymentName` and `endpoint`
32
-
* Met the [System Requirements](https://blazor.syncfusion.com/documentation/system-requirements)for Syncfusion<supstyle="font-size:70%">®</sup> Blazor components
33
-
* Configured secure credential storage using Azure Key Vault or environment variables
28
+
- An [Azure OpenAI Service resource and model](https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/create-resource)is deployed to obtain `apiKey`, `deploymentName`, and `endpoint` values.
29
+
- The [Syncfusion Blazor system requirements](https://blazor.syncfusion.com/documentation/system-requirements)are met.
30
+
- Credentials are stored securely using Azure Key Vault or environment variables (see [Microsoft’s guide on secure storage](https://learn.microsoft.com/en-us/aspnet/core/security/app-secrets)).
34
31
35
32
## Configuration Steps
36
33
37
-
Follow these steps to configure Azure OpenAI as your AI provider:
38
-
39
34
### Register AI Services in Program.cs
40
35
41
-
Open your Blazor application's `Program.cs` file and add the following configuration:
36
+
To configure Azure OpenAI in a Blazor WebApp Server, update the `Program.cs` file as follows:
This example demonstrates using the **Syncfusion.Blazor.AI** package with Azure OpenAI to enable natural language querying in a Blazor application. The application features a Syncfusion<supstyle="font-size:70%">®</sup> Tab component with a textarea for entering natural language queries, a QueryBuilder component to visualize the generated query rules, and a Grid component to display filtered results based on the query processed by Azure OpenAI.
68
-
69
-
### Prerequisites
62
+
This example demonstrates using the Syncfusion Blazor AI library with Azure OpenAI to enable natural language querying. The application uses a Syncfusion Tab component with a textarea for entering natural language queries, a QueryBuilder component to visualize generated query rules, and a Grid component to display filtered results based on the Azure OpenAI-processed query.
### Register Syncfusion<supstyle="font-size:70%">®</sup> Blazor Service
94
+
### Register Syncfusion Blazor Service
101
95
102
-
Register the Syncfusion<supstyle="font-size:70%">®</sup> Blazor Service in the **~/Program.cs** file of your Blazor Web App.
96
+
Register the SyncfusionBlazor service in the `~/Program.cs` file based on the interactive render mode.
103
97
104
-
If the **Interactive Render Mode** is set to `WebAssembly` or `Auto`, you need to register the Syncfusion<supstyle="font-size:70%">®</sup> Blazor service in both **~/Program.cs** files of your Blazor Web App.
98
+
**For WebAssembly or Auto Render Mode**:
99
+
If the **Interactive Render Mode** is set to `WebAssembly` or `Auto`, the Syncfusion<supstyle="font-size:70%">®</sup> Blazor service should be registered in both **~/Program.cs** files.
If the **Interactive Render Mode** is set to `Server`, your project will contain a single **~/Program.cs** file. So, you should register the Syncfusion<supstyle="font-size:70%">®</sup> Blazor Service only in that **~/Program.cs** file.
132
+
**For Server Render Mode**:
133
+
If the **Interactive Render Mode** is set to `Server`, the project will contain a single **~/Program.cs** file. In this case, the Syncfusion<supstyle="font-size:70%">®</sup> Blazor Service should be registered within that `~/Program.cs` file.

353
+

357
354
358
355
## How It Works
359
356
360
-
The example above demonstrates how to use Azure OpenAI with Syncfusion<supstyle="font-size:70%">®</sup> Blazor components for natural language query processing:
357
+
This example illustrates how the Syncfusion Blazor AI library integrates with Azure OpenAI to process natural language queries:
361
358
362
-
1.**Setup**: Configuring the Azure OpenAI service in `Program.cs`with appropriate credentials.
363
-
2.**Component Integration**: Using the `IChatInferenceService` to process natural language queries.
364
-
3.**Prompt Engineering**: Creating appropriate prompts for the AI model to convert natural language to SQL.
365
-
4.**Response Processing**: Parsing the SQL response and applying it to the QueryBuilder component.
359
+
1.**Setup**: Configure Azure OpenAI in `Program.cs`using a secure API key, endpoint, and deployed model (e.g., `gpt-4`).
360
+
2.**Component Integration**: Inject `IChatInferenceService` to process user queries entered in a textarea.
361
+
3.**Prompt Engineering**: Craft a prompt to convert natural language input into a valid SQL query for filtering data.
362
+
4.**Response Processing**: Parse the SQL query from Azure OpenAI, apply it to the QueryBuilder component, and update the Grid with filtered results.
366
363
367
364
### Key Components
368
-
369
-
-**IChatInferenceService**: Injected to interact with the Azure OpenAI models.
370
-
-**ChatParameters**: Configures the AI request, including system prompt and user messages.
371
-
-**GenerateResponseAsync**: Sends the request to Azure OpenAI and retrieves the response asynchronously.
372
-
-**UI Components**: Syncfusion<supstyle="font-size:70%">®</sup> Tab, QueryBuilder, and Grid components work together with the AI service.
365
+
-**IChatInferenceService**: Injected service for interacting with Azure OpenAI models.
366
+
-**ChatParameters**: Configures the AI request with prompts and user messages.
367
+
-**GenerateResponseAsync**: Sends asynchronous requests to Azure OpenAI and retrieves responses.
368
+
-**UI Components**: Syncfusion Tab, QueryBuilder, and Grid components integrate with the AI service for dynamic query processing.
369
+
370
+
## Error Handling
371
+
-**Invalid Credentials**: Ensure the API key, endpoint, and model are valid and correctly configured in environment variables or Azure Key Vault.
372
+
-**Rate Limits**: Azure OpenAI usage may be limited based on your subscription. Check [Azure OpenAI pricing documentation](https://azure.microsoft.com/en-us/pricing/details/cognitive-services/openai-service/) for details.
title: Using Custom AI Services with Syncfusion Blazor AI | Syncfusion
4
-
description: Learn how to set up and use Syncfusion.Blazor.AI with custom AI providers, including configuration, integration steps, and practical examples.
3
+
title: Custom AI Service Integration with Syncfusion Blazor AI | Syncfusion
4
+
description: Learn how to configure and use SyncfusionBlazorAI with custom AI providers, such as DeepSeek, to enable AI-driven features in Blazor applications.
5
5
platform: Blazor
6
6
control: AI Integration
7
7
documentation: ug
8
8
---
9
9
10
10
# Custom AI Service Integration with Syncfusion® Blazor AI
11
11
12
-
## Introduction
13
-
14
-
This section demonstrates configuring and using the [Syncfusion.Blazor.AI](https://www.nuget.org/packages/Syncfusion.Blazor.AI) package with a **custom AI service** by implementing the `IChatInferenceService` interface, using DeepSeek as an example. This extensibility feature empowers developers to integrate any AI provider into Blazor applications, enabling Syncfusion<supstyle="font-size:70%">®</sup> Blazor components to work with specialized or proprietary AI services beyond the standard providers.
12
+
The [Syncfusion Blazor AI](https://www.nuget.org/packages/Syncfusion.Blazor.AI) library enables integration with custom AI providers by implementing the `IChatInferenceService` interface, using DeepSeek as an example. This extensibility feature allows developers to connect Blazor applications to proprietary or specialized AI services, such as enterprise-specific models or local AI servers, enhancing Syncfusion Blazor components with tailored AI functionality like text generation or data processing.
15
13
16
14
## Prerequisites
17
15
18
-
Before integrating a custom AI service with your Blazor application, ensure you have:
19
-
20
-
* Installed the following NuGet packages:
16
+
To integrate a custom AI service with a Blazor application, ensure the following:
* Obtained an API key from your chosen AI provider (DeepSeek in this example) from the [DeepSeek platform](https://platform.deepseek.com)
29
-
* Met the [System Requirements](https://blazor.syncfusion.com/documentation/system-requirements)for Syncfusion<supstyle="font-size:70%">®</sup> Blazor components
30
-
* Understanding of HTTP client usage and JSON serialization in .NET applications
25
+
- An API key is obtained from the chosen AI provider (e.g., DeepSeek via the [DeepSeek API documentation](https://platform.deepseek.com)).
26
+
- The [Syncfusion Blazor system requirements](https://blazor.syncfusion.com/documentation/system-requirements)are met.
27
+
- Familiarity with HTTP client usage and JSON serialization in .NET applications.
31
28
32
29
## Configuration Steps
33
30
34
-
Follow these steps to integrate a custom AI service with Syncfusion<supstyle="font-size:70%">®</sup> Blazor AI:
35
-
36
31
### Implement the Custom AI Service
37
32
38
-
Create a class that implements the `IChatInferenceService` interface for your custom AI provider. The implementation below demonstrates DeepSeek integration using `AIServiceCredentials` for secure configuration management.
39
-
33
+
Create a class that implements the `IChatInferenceService` interface for the custom AI provider. The example below demonstrates DeepSeek integration using `AIServiceCredentials` for secure configuration management.
0 commit comments