Allow override model for ExecutingDirectly.
This commit is contained in:
parent
4c1af4c710
commit
ab70a4d447
|
|
@ -0,0 +1,9 @@
|
|||
namespace BotSharp.Abstraction.Conversations.Enums;
|
||||
|
||||
public class ConversationChannel
|
||||
{
|
||||
public const string WebChat = "webchat";
|
||||
public const string OpenAPI = "openapi";
|
||||
public const string Phone = "phone";
|
||||
public const string Messenger = "messenger";
|
||||
}
|
||||
|
|
@ -17,6 +17,8 @@ public class Conversation
|
|||
|
||||
public string Status { get; set; } = ConversationStatus.Open;
|
||||
|
||||
public string Channel { get; set; } = ConversationChannel.OpenAPI;
|
||||
|
||||
public DateTime UpdatedTime { get; set; } = DateTime.UtcNow;
|
||||
public DateTime CreatedTime { get; set; } = DateTime.UtcNow;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ public class FunctionCallFromLlm : RoutingArgs
|
|||
public JsonDocument? Arguments { get; set; }
|
||||
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.Always)]
|
||||
public bool IsExecutionOnce { get; set; }
|
||||
public bool ExecutingDirectly { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -19,5 +19,5 @@ public interface IRoutingService
|
|||
/// <param name="agent"></param>
|
||||
/// <param name="message"></param>
|
||||
/// <returns></returns>
|
||||
Task<RoleDialogModel> ExecuteOnce(Agent agent, RoleDialogModel message);
|
||||
Task<RoleDialogModel> ExecuteDirectly(Agent agent, RoleDialogModel message);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ public partial class ConversationService
|
|||
|
||||
var response = agentId == settings.RouterId ?
|
||||
await routing.InstructLoop(message) :
|
||||
await routing.ExecuteOnce(agent, message);
|
||||
await routing.ExecuteDirectly(agent, message);
|
||||
|
||||
await HandleAssistantMessage(response, onMessageReceived);
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ using BotSharp.Abstraction.Functions.Models;
|
|||
using BotSharp.Abstraction.Planning;
|
||||
using BotSharp.Abstraction.Repositories;
|
||||
using BotSharp.Abstraction.Routing.Models;
|
||||
using BotSharp.Abstraction.Routing.Settings;
|
||||
using BotSharp.Abstraction.Templating;
|
||||
|
||||
namespace BotSharp.Core.Planning;
|
||||
|
|
@ -28,7 +29,10 @@ public class HFPlanner : IPlaner
|
|||
RoleDialogModel response = default;
|
||||
var inst = new FunctionCallFromLlm();
|
||||
|
||||
var completion = CompletionProvider.GetChatCompletion(_services);
|
||||
var routerSetting = _services.GetRequiredService<RoutingSettings>();
|
||||
var completion = CompletionProvider.GetChatCompletion(_services,
|
||||
provider: routerSetting.Provider,
|
||||
model: routerSetting.Model);
|
||||
|
||||
int retryCount = 0;
|
||||
while (retryCount < 3)
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ public class RouteToAgentRoutingHandler : RoutingHandlerBase, IRoutingHandler
|
|||
var agent = await agentService.LoadAgent(agentId);
|
||||
inst.AgentName = agent.Name;
|
||||
|
||||
if (inst.IsExecutionOnce)
|
||||
if (inst.ExecutingDirectly)
|
||||
{
|
||||
message.Content = inst.Question;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,8 +21,7 @@ public partial class RoutingService
|
|||
var agentService = _services.GetRequiredService<IAgentService>();
|
||||
var agent = await agentService.LoadAgent(agentId);
|
||||
|
||||
var settings = _services.GetRequiredService<ChatCompletionSetting>();
|
||||
var chatCompletion = CompletionProvider.GetChatCompletion(_services, provider: settings.Provider, model: settings.Model);
|
||||
var chatCompletion = CompletionProvider.GetChatCompletion(_services);
|
||||
|
||||
var message = dialogs.Last();
|
||||
var response = chatCompletion.GetChatCompletions(agent, dialogs);
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ public partial class RoutingService : IRoutingService
|
|||
_logger = logger;
|
||||
}
|
||||
|
||||
public async Task<RoleDialogModel> ExecuteOnce(Agent agent, RoleDialogModel message)
|
||||
public async Task<RoleDialogModel> ExecuteDirectly(Agent agent, RoleDialogModel message)
|
||||
{
|
||||
var handlers = _services.GetServices<IRoutingHandler>();
|
||||
|
||||
|
|
@ -48,7 +48,7 @@ public partial class RoutingService : IRoutingService
|
|||
Reason = message.Content,
|
||||
AgentName = agent.Name,
|
||||
OriginalAgent = agent.Name,
|
||||
IsExecutionOnce = true
|
||||
ExecutingDirectly = true
|
||||
};
|
||||
|
||||
var result = await handler.Handle(this, inst, message);
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
using BotSharp.Abstraction.Conversations.Enums;
|
||||
using BotSharp.Abstraction.Conversations.Models;
|
||||
using BotSharp.OpenAPI.ViewModels.Users;
|
||||
using System.Text.Json.Serialization;
|
||||
|
|
@ -20,6 +21,7 @@ public class ConversationViewModel
|
|||
|
||||
public string Event { get; set; }
|
||||
|
||||
public string Channel { get; set; } = ConversationChannel.OpenAPI;
|
||||
public string Status { get; set; }
|
||||
|
||||
[JsonPropertyName("updated_time")]
|
||||
|
|
@ -38,6 +40,7 @@ public class ConversationViewModel
|
|||
},
|
||||
AgentId = sess.AgentId,
|
||||
Title = sess.Title,
|
||||
Channel = sess.Channel,
|
||||
Status = sess.Status,
|
||||
CreatedTime = sess.CreatedTime,
|
||||
UpdatedTime = sess.UpdatedTime
|
||||
|
|
|
|||
Loading…
Reference in a new issue