Merge pull request #135 from hchen2020/master

Define new InstructMessageModel.
This commit is contained in:
Haiping 2023-09-07 19:55:04 -05:00 committed by GitHub
commit 33955865d9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 1 deletions

View file

@ -59,6 +59,21 @@ public partial class ConversationService
}, onMessageReceived);
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;

View file

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