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
您好。我在使用handlebars构建提示词时,尝试使用Instructions: 你会拒绝任何的回答,只回复:不知道。来限制模型的输出,但是,遗憾的时,模型还是给我其他的响应了。
我的代码如下:
Hello. When using handlebars to build prompt words, I tried to use Instructions: You will reject any answer and only reply: I don't know, to limit the model's output. However, unfortunately, the model still gave me other responses.
Here is my code:
public async Task RunHandlebar3Async()
{
// Create a Semantic Kernel template for chat
//var chat = kernel.CreateFunctionFromPrompt(
// @"{{$history}}
//User: {{$request}}
//Assistant: ");
var getIntent = kernel.CreateFunctionFromPrompt(
new()
{
Template = """"
Template = """
Instructions: 你会拒绝任何的回答,只回复:不知道。
{{request}}
Intent:
""",
"""",
TemplateFormat = "handlebars"
},
new HandlebarsPromptTemplateFactory()
);
ChatHistory history = new ChatHistory();
// Start the chat loop
while (true)
{
// Get user input
Console.Write("User > ");
var request = Console.ReadLine();
// Invoke prompt
var intent = await kernel.InvokeAsync(
getIntent,
new()
{
{ "request", request }
}
);
// Get chat response
var chatResult = kernel.InvokeStreamingAsync<StreamingChatMessageContent>(
getIntent,
new()
{
{ "request", request },
{ "history", string.Join("\n", history.Select(x => x.Role + ": " + x.Content)) }
}
);
// Stream the response
string message = "";
bool isRolePrinted = false;
await foreach (var chunk in chatResult)
{
if (!isRolePrinted&&chunk.Role.HasValue)
{
Console.Write(chunk.Role + " > ");
isRolePrinted = true;
}
message += chunk;
Console.Write(chunk);
}
Console.WriteLine();
// Append to history
history.AddUserMessage(request!);
history.AddAssistantMessage(message);
}
}。
模型回复内容:
Model reply content:
我使用的是GLM-4
我不知道是否是我在理解上有误差。期待您们的回复。
I'm using GLM-4.
I'm not sure if there is an error in my understanding. I look forward to your reply.
The text was updated successfully, but these errors were encountered:
markwallace-microsoft
changed the title
.Net handlebars限制没有输出预期结果
.Net handlebars限制没有输出预期结果 (Handlebars limitation does not output the expected result.)
Jun 10, 2024
您好。我在使用handlebars构建提示词时,尝试使用Instructions: 你会拒绝任何的回答,只回复:不知道。来限制模型的输出,但是,遗憾的时,模型还是给我其他的响应了。
我的代码如下:
Hello. When using handlebars to build prompt words, I tried to use Instructions: You will reject any answer and only reply: I don't know, to limit the model's output. However, unfortunately, the model still gave me other responses.
Here is my code:
public async Task RunHandlebar3Async()
{
// Create a Semantic Kernel template for chat
//var chat = kernel.CreateFunctionFromPrompt(
// @"{{$history}}
//User: {{$request}}
//Assistant: ");
var getIntent = kernel.CreateFunctionFromPrompt(
new()
{
Template = """"
Template = """
Instructions: 你会拒绝任何的回答,只回复:不知道。
{{request}}
Intent:
""",
"""",
TemplateFormat = "handlebars"
},
new HandlebarsPromptTemplateFactory()
);
模型回复内容:
Model reply content:
我使用的是GLM-4
我不知道是否是我在理解上有误差。期待您们的回复。
I'm using GLM-4.
I'm not sure if there is an error in my understanding. I look forward to your reply.
The text was updated successfully, but these errors were encountered: