Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.Net: Fix to ensure OpenAIPromptExecutionSettings ChatSystemPrompt is not ignored #4530

Conversation

markwallace-microsoft
Copy link
Member

Motivation and Context

Resolves issue #4510

Description

Add a system message using the chat system prompt if no system message is included in the chat history

Contribution Checklist

@markwallace-microsoft markwallace-microsoft requested a review from a team as a code owner January 9, 2024 10:19
@markwallace-microsoft markwallace-microsoft self-assigned this Jan 9, 2024
@shawncal shawncal added .NET Issue or Pull requests regarding .NET code kernel Issues or pull requests impacting the core kernel kernel.core documentation labels Jan 9, 2024
@github-actions github-actions bot changed the title Users/markwallace/issue 4510 .Net: Users/markwallace/issue 4510 Jan 9, 2024
@markwallace-microsoft markwallace-microsoft changed the title .Net: Users/markwallace/issue 4510 .Net: Fix to ensure OpenAIPromptExecutionSettings ChatSystemPrompt is not ignored Jan 9, 2024
@markwallace-microsoft markwallace-microsoft added this pull request to the merge queue Jan 10, 2024
Merged via the queue into microsoft:main with commit abc900e Jan 10, 2024
18 checks passed
@markwallace-microsoft markwallace-microsoft deleted the users/markwallace/issue_4510 branch January 10, 2024 12:50
@lil-kita
Copy link

Hi everybody @markwallace-microsoft @dmytrostruk @SergeyMenshykh
chat system prompt is still ignored

<PackageVersion Include="Microsoft.SemanticKernel" Version="1.1.0" />

// Kernel _kernel is resolved using DI

OpenAIPromptExecutionSettings settings = new();
settings.ChatSystemPrompt = "You are batman. If asked who you are, say 'I am Batman!'";
string prompt = "Who are you?";

KernelFunction function = _kernel.CreateFunctionFromPrompt(prompt, settings);
FunctionResult result = await _kernel.InvokeAsync(function, cancellationToken: cancellationToken);

string text = result.GetValue<string>();
// "I am a language model AI developed by OpenAI, designed to assist and provide information on a wide range of topics. How can I assist you today?"

It works fine in this version
<PackageVersion Include="Microsoft.SemanticKernel" Version="1.0.0-rc3" />

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kernel Issues or pull requests impacting the core kernel .NET Issue or Pull requests regarding .NET code
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

6 participants