Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions MAUIDataForm/MAUIDataForm/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ public partial class App : Application
public App()
{
InitializeComponent();

MainPage = new AppShell();
MainPage = new MainPage();
}
}
14 changes: 0 additions & 14 deletions MAUIDataForm/MAUIDataForm/AppShell.xaml

This file was deleted.

9 changes: 0 additions & 9 deletions MAUIDataForm/MAUIDataForm/AppShell.xaml.cs

This file was deleted.

2 changes: 1 addition & 1 deletion MAUIDataForm/MAUIDataForm/MAUIDataForm.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="$(MauiVersion)" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0-rc.2.23479.6" />
<PackageReference Include="Azure.AI.OpenAI" Version="1.0.0-beta.15" />
<PackageReference Include="Microsoft.SemanticKernel" Version="1.0.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="Syncfusion.Maui.DataForm" Version="*" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion MAUIDataForm/MAUIDataForm/MainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
MaximumHeightRequest="550"
VerticalOptions="Start"
HorizontalOptions="Center"
WidthRequest="550"
WidthRequest="{OnPlatform MacCatalyst=550, WinUI=450, iOS=400, Android=350}"
Padding="10">

<Grid BackgroundColor="{DynamicResource SfDataFormNormalBackground}">
Expand Down
4 changes: 2 additions & 2 deletions MAUIDataForm/MAUIDataForm/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public MainPage()
}

string clipboardText;
private AzureOpenAIService azureAIService = new AzureOpenAIService();
SemanticKernelService semanticKernelService = new SemanticKernelService();

private async void OnSmartPasteButtonClicked(object sender, EventArgs e)
{
Expand All @@ -37,7 +37,7 @@ private async void OnSmartPasteButtonClicked(object sender, EventArgs e)
$"\n3. Final output must be Json format" +
$"\n4. No need any explanation or comments in the output" +
$"\n Please provide the valid JSON object without any additional formatting characters like backticks or newlines";
string finalResponse = await this.azureAIService.GetResponseFromGPT(prompt);
string finalResponse = await this.semanticKernelService.GetResponseFromGPT(prompt);
this.ProcessSmartPasteData(finalResponse);
}

Expand Down
58 changes: 0 additions & 58 deletions MAUIDataForm/MAUIDataForm/Service/AzureOpenAIService.cs

This file was deleted.

54 changes: 54 additions & 0 deletions MAUIDataForm/MAUIDataForm/Service/SemanticKernelService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
namespace MAUIDataForm
{
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.ChatCompletion;
using Microsoft.SemanticKernel.Connectors.OpenAI;

internal class SemanticKernelService
{
const string endpoint = "https://{YOUR_END_POINT}.openai.azure.com";
const string deploymentName = "GPT35Turbo";
string key = "API key";

IChatCompletionService chatCompletionService;
Kernel kernel;

internal SemanticKernelService()
{

}

internal async Task<string> GetResponseFromGPT(string userPrompt)
{
var builder = Kernel.CreateBuilder().AddAzureOpenAIChatCompletion(deploymentName, endpoint, key);
this.kernel = builder.Build();
if (this.kernel != null)
{
var chatHistory = new ChatHistory();
chatHistory.Clear();

// Add the user's prompt as a user message to the conversation.
chatHistory.AddSystemMessage("You are a predictive analytics assistant.");

// Add the user's prompt as a user message to the conversation.
chatHistory.AddUserMessage(userPrompt);

// Get the chat completions from kernal.
chatCompletionService = kernel.GetRequiredService<IChatCompletionService>();
OpenAIPromptExecutionSettings openAIPromptExecutionSettings = new OpenAIPromptExecutionSettings();
openAIPromptExecutionSettings.ToolCallBehavior = ToolCallBehavior.AutoInvokeKernelFunctions;
try
{
var response = await chatCompletionService.GetChatMessageContentAsync(chatHistory, executionSettings: openAIPromptExecutionSettings, kernel: kernel);
return response.ToString();
}
catch
{
return "";
}
}

return "";
}
}
}
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# Integrate-openai-powered-smart-paste-into-DataForm-for-Seamless-Data-Entry
# Integrate OpenAI-Powered Smart Paste into DataForm for Seamless Data Entry

This repository contains sample code demonstrating how to integrate OpenAI-powered Smart Paste into a Syncfusion MAUI DataForm. The AI-driven feature streamlines data entry by processing and formatting pasted content, enhancing efficiency and accuracy.

![image](https://github.com/user-attachments/assets/987ccf81-b954-4c99-8479-b80828c2acf1)
Loading