Define new InstructMessageModel.

This commit is contained in:
hchen 2023-09-07 17:06:41 -05:00
parent 1e89b0162f
commit 760a047d71
3 changed files with 25 additions and 1 deletions

View file

@ -59,6 +59,21 @@ public partial class ConversationService
}, onMessageReceived); }, onMessageReceived);
return; return;
} }
else if (fn.StopCompletion)
{
var message = new RoleDialogModel(AgentRole.Assistant, fn.Content)
{
CurrentAgentId = fn.CurrentAgentId,
Channel = fn.Channel,
ExecutionData = fn.ExecutionData,
ExecutionResult = fn.ExecutionResult
};
await HandleAssistantMessage(message, onMessageReceived);
_storage.Append(_conversationId, agent.Id, message);
return;
}
fn.Content = fn.FunctionArgs.Replace("\r", " ").Replace("\n", " ").Trim() + " => " + fn.ExecutionResult; fn.Content = fn.FunctionArgs.Replace("\r", " ").Replace("\n", " ").Trim() + " => " + fn.ExecutionResult;

View file

@ -4,6 +4,7 @@ using BotSharp.Abstraction.Conversations.Models;
using BotSharp.Abstraction.Instructs; using BotSharp.Abstraction.Instructs;
using BotSharp.Abstraction.Instructs.Models; using BotSharp.Abstraction.Instructs.Models;
using BotSharp.OpenAPI.ViewModels.Conversations; using BotSharp.OpenAPI.ViewModels.Conversations;
using BotSharp.OpenAPI.ViewModels.Instructs;
namespace BotSharp.OpenAPI.Controllers; namespace BotSharp.OpenAPI.Controllers;
@ -23,7 +24,7 @@ public class InstructModeController : ControllerBase, IApiAdapter
[HttpPost("/instruct/{agentId}")] [HttpPost("/instruct/{agentId}")]
public async Task<InstructResult> NewConversation([FromRoute] string agentId, public async Task<InstructResult> NewConversation([FromRoute] string agentId,
[FromBody] NewMessageModel input) [FromBody] InstructMessageModel input)
{ {
var response = new InstructResult(); var response = new InstructResult();
var instructor = _services.GetRequiredService<IInstructService>(); var instructor = _services.GetRequiredService<IInstructService>();

View file

@ -0,0 +1,8 @@
using BotSharp.OpenAPI.ViewModels.Conversations;
namespace BotSharp.OpenAPI.ViewModels.Instructs;
public class InstructMessageModel : NewMessageModel
{
public string? TemplateName { get; set; }
}