Skip to content

Commit 3c0443a

Browse files
authored
Merge pull request #148 from hchen2020/master
Fix instruction mode.
2 parents b355839 + 2819749 commit 3c0443a

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/Infrastructure/BotSharp.OpenAPI/Controllers/InstructModeController.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,25 @@ public InstructModeController(IServiceProvider services)
2020
}
2121

2222
[HttpPost("/instruct/{agentId}")]
23-
public async Task<InstructResult> NewConversation([FromRoute] string agentId,
23+
public async Task<InstructResult> InstructCompletion([FromRoute] string agentId,
2424
[FromBody] InstructMessageModel input)
2525
{
2626
var instructor = _services.GetRequiredService<IInstructService>();
2727
var agentService = _services.GetRequiredService<IAgentService>();
2828
Agent agent = await agentService.LoadAgent(agentId);
2929

3030
// switch to different instruction template
31-
if (!string.IsNullOrEmpty(input.TemplateName))
31+
if (!string.IsNullOrEmpty(input.Template))
3232
{
3333
var agentSettings = _services.GetRequiredService<AgentSettings>();
34-
var filePath = Path.Combine(agentService.GetAgentDataDir(agentId), $"{input.TemplateName}.{agentSettings.TemplateFormat}");
34+
var filePath = Path.Combine(agentService.GetAgentDataDir(agentId), $"{input.Template}.{agentSettings.TemplateFormat}");
3535
agent.Instruction = System.IO.File.ReadAllText(filePath);
3636
}
3737

38+
var conv = _services.GetRequiredService<IConversationService>();
39+
conv.States.SetState("provider", input.Provider)
40+
.SetState("model", input.Model);
41+
3842
return await instructor.ExecuteInstruction(agent,
3943
new RoleDialogModel(AgentRole.User, input.Text),
4044
fn => Task.CompletedTask,

src/Infrastructure/BotSharp.OpenAPI/ViewModels/Instructs/InstructMessageModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ namespace BotSharp.OpenAPI.ViewModels.Instructs;
44
public class InstructMessageModel : IncomingMessageModel
55
{
66
public override string Channel { get; set; } = "openapi";
7-
public string? TemplateName { get; set; }
7+
public string? Template { get; set; }
88
}

0 commit comments

Comments
 (0)