Skip to content

Commit 9f2e99b

Browse files
committed
chore(common): add readme
1 parent e473ed6 commit 9f2e99b

File tree

1 file changed

+35
-0
lines changed
  • common/integration-with-microsoft-extensions-ai/AIPromptIntegrationWithMicrosoftExtensionsAI/AIPromptIntegrationWithMicrosoftExtensionsAI

1 file changed

+35
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# AIPrompt integration with Microsoft.Extensions.AI
2+
3+
## Overview
4+
5+
This project demonstrates the [integration of the `Microsoft.Extensions.AI` package with the `AIPrompt` component](https://www.telerik.com/blazor-ui/documentation/common-features/microsoft-extensions-ai-integration). The integration enables AI-powered interactions using **Azure OpenAI**, leveraging the built-in [`IChatClient` service](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.ai.ichatclient?view=net-9.0-pp).
6+
7+
## About `Microsoft.Extensions.AI`
8+
9+
The [`Microsoft.Extensions.AI` package](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.ai?view=net-9.0-pp) provides an abstraction for AI-powered services, making it easy to integrate large language models (LLMs) into .NET applications. It simplifies AI interaction by offering dependency injection support and a structured way to handle AI-based workflows.
10+
11+
## Integration with `AIPrompt` Component
12+
13+
- The [`AIPrompt` component](https://www.telerik.com/blazor-ui/documentation/components/aiprompt/overview) is configured to use `Microsoft.Extensions.AI` for AI-driven prompts.
14+
- The project registers an [`IChatClient` service](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.ai.ichatclient?view=net-9.0-pp) in the `Program.cs` file.
15+
- The [`OnPromptRequest` event](https://www.telerik.com/blazor-ui/documentation/components/aiprompt/events#onpromptrequest) of the `AIPrompt` is not handled, so the component will automatically use the registered `IChatClient` service for to generate a response.
16+
- **Azure OpenAI** is used as the AI provider for generating responses.
17+
18+
## Setup & Configuration
19+
20+
To run the project successfully, you need to provide your **Azure OpenAI URI** and **API key**.
21+
22+
### Steps:
23+
24+
1. Open the `Program.cs` file.
25+
2. Locate the `IChatClient` service registration.
26+
3. Uncomment the service registration.
27+
3. Replace the placeholder values with your actual Azure OpenAI endpoint and API key:
28+
29+
```csharp
30+
new Uri("YOUR_AZURE_OPENAI_ENDPOINT"),
31+
new AzureKeyCredential("YOUR_AZURE_OPENAI_CREDENTIAL"))
32+
```
33+
34+
4. Run the application and interact with the `AIPrompt` component.
35+

0 commit comments

Comments
 (0)