Merge branch 'SciSharp:master' into master
This commit is contained in:
commit
d2636a6eaf
|
|
@ -10,6 +10,18 @@ public class EvaluationRequest : LlmBaseRequest
|
|||
[JsonPropertyName("states")]
|
||||
public IEnumerable<MessageState> States { get; set; } = [];
|
||||
|
||||
[JsonPropertyName("duplicate_limit")]
|
||||
public int DuplicateLimit { get; set; } = 2;
|
||||
|
||||
[JsonPropertyName("max_rounds")]
|
||||
public int MaxRounds { get; set; } = 20;
|
||||
|
||||
|
||||
[JsonPropertyName("additional_instruction")]
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? AdditionalInstruction { get; set; }
|
||||
|
||||
[JsonPropertyName("stop_criteria")]
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? StopCriteria { get; set; }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ public partial class EvaluatingService
|
|||
private async Task<string> SimulateConversation(string initMessage, IEnumerable<string> refDialogs, EvaluationRequest request)
|
||||
{
|
||||
var count = 0;
|
||||
var duplicateCount = 0;
|
||||
var convId = Guid.NewGuid().ToString();
|
||||
var curDialogs = new List<string>();
|
||||
var curUserMsg = initMessage;
|
||||
|
|
@ -79,13 +80,30 @@ public partial class EvaluatingService
|
|||
{
|
||||
{ "ref_conversation", refDialogs },
|
||||
{ "cur_conversation", curDialogs },
|
||||
{ "additional_instruction", request.AdditionalInstruction },
|
||||
{ "stop_criteria", request.StopCriteria }
|
||||
}
|
||||
});
|
||||
|
||||
_logger.LogInformation($"Generated message: {result?.GeneratedMessage}, stop: {result?.Stop}, reason: {result?.Reason}");
|
||||
|
||||
if (curUserMsg.IsEqualTo(prevUserMsg) || curBotMsg.IsEqualTo(prevBotMsg)
|
||||
|| count > request.MaxRounds || (result != null && result.Stop))
|
||||
if (count > request.MaxRounds || (result != null && result.Stop))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (curUserMsg.IsEqualTo(prevUserMsg) || curBotMsg.IsEqualTo(prevBotMsg))
|
||||
{
|
||||
duplicateCount++;
|
||||
}
|
||||
else
|
||||
{
|
||||
duplicateCount = 0;
|
||||
}
|
||||
|
||||
|
||||
if (duplicateCount >= request.DuplicateLimit)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,31 @@ Please take the content in the [REFERENCE CONVERSATION] section as a reference,
|
|||
** You need to take a close look at the content in both [REFERENCE CONVERSATION] and [ONGOING CONVERSATION], and determine whether to generate a text message or stop the ongoing conversation.
|
||||
** When you generate a message, please assume you are the user and reply in the user perceptive.
|
||||
** Please do not generate or append a message with similar meaning that you have already mentioned in the [ONGOING CONVERSATION].
|
||||
|
||||
|
||||
=================
|
||||
[ADDITIONAL INSTRUCTION]
|
||||
{{ "\r\n" }}
|
||||
{%- if additional_instruction != empty -%}
|
||||
{{ additional_instruction }}
|
||||
{%- endif -%}
|
||||
{{ "\r\n" }}
|
||||
|
||||
|
||||
=================
|
||||
[CONVERSATION STOP CRITERIA]
|
||||
{{ "\r\n" }}
|
||||
{%- if stop_criteria != empty -%}
|
||||
{{ stop_criteria }}
|
||||
{%- else -%}
|
||||
** If you see the assistant replies two or more than two similar messages in the [ONGOING CONVERSATION], please stop the conversation immediately.
|
||||
{%- endif -%}
|
||||
{{ "\r\n" }}
|
||||
|
||||
|
||||
=================
|
||||
[OUTPUT JSON FORMAT]
|
||||
|
||||
** The output must be in JSON format:
|
||||
{
|
||||
"generated_message": the generated text message using the user tone,
|
||||
|
|
|
|||
Loading…
Reference in a new issue