Fix RichContent pass alway bug.
This commit is contained in:
parent
8ed35691f9
commit
ed5049ccb2
|
|
@ -28,6 +28,7 @@ public class Agent
|
|||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public List<string> Samples { get; set; }
|
||||
= new List<string>();
|
||||
|
||||
/// <summary>
|
||||
/// Functions
|
||||
|
|
@ -70,6 +71,7 @@ public class Agent
|
|||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public Dictionary<string, object> TemplateDict { get; set; }
|
||||
= new Dictionary<string, object>();
|
||||
|
||||
public override string ToString()
|
||||
=> $"{Name} {Id}";
|
||||
|
|
|
|||
|
|
@ -38,6 +38,15 @@ public static class StringExtensions
|
|||
public static T? JsonContent<T>(this string text)
|
||||
{
|
||||
text = JsonContent(text);
|
||||
return JsonSerializer.Deserialize<T>(text);
|
||||
|
||||
var options = new JsonSerializerOptions
|
||||
{
|
||||
PropertyNameCaseInsensitive = true,
|
||||
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
|
||||
WriteIndented = true,
|
||||
AllowTrailingCommas = true
|
||||
};
|
||||
|
||||
return JsonSerializer.Deserialize<T>(text, options);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -464,9 +464,6 @@ public class FileRepository : IBotSharpRepository
|
|||
}
|
||||
#endregion
|
||||
|
||||
#if !DEBUG
|
||||
[MemoryCache(10 * 60)]
|
||||
#endif
|
||||
public List<string> GetAgentResponses(string agentId, string prefix, string intent)
|
||||
{
|
||||
var responses = new List<string>();
|
||||
|
|
|
|||
|
|
@ -23,15 +23,22 @@ public partial class RoutingService
|
|||
var settings = _services.GetRequiredService<ChatCompletionSetting>();
|
||||
var chatCompletion = CompletionProvider.GetChatCompletion(_services, provider: settings.Provider, model: settings.Model);
|
||||
|
||||
RoleDialogModel response = chatCompletion.GetChatCompletions(agent, dialogs);
|
||||
var message = dialogs.Last();
|
||||
var response = chatCompletion.GetChatCompletions(agent, dialogs);
|
||||
|
||||
if (response.Role == AgentRole.Function)
|
||||
{
|
||||
await InvokeFunction(agent, response, dialogs);
|
||||
message = RoleDialogModel.From(message,
|
||||
role: AgentRole.Function);
|
||||
message.FunctionName = response.FunctionName;
|
||||
message.FunctionArgs = response.FunctionArgs;
|
||||
await InvokeFunction(agent, message, dialogs);
|
||||
}
|
||||
else
|
||||
{
|
||||
dialogs.Add(response);
|
||||
dialogs.Add(RoleDialogModel.From(message,
|
||||
role: AgentRole.Assistant,
|
||||
content: response.Content));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -298,7 +298,7 @@ public class ChatCompletionProvider : IChatCompletion
|
|||
{
|
||||
var functions = string.Join("\r\n", chatCompletionsOptions.Functions.Select(x =>
|
||||
{
|
||||
return $"{x.Name}: {x.Description}\r\n{x.Parameters}";
|
||||
return $"\r\n{x.Name}: {x.Description}\r\n{x.Parameters}";
|
||||
}));
|
||||
prompt += $"\r\n[FUNCTIONS]\r\n{functions}\r\n";
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue