Skip to content

Commit 054b898

Browse files
authored
Merge pull request #395 from iceljc/features/enable-plugin-by-dependency
patch state source
2 parents b7c80cf + d530b59 commit 054b898

1 file changed

Lines changed: 14 additions & 14 deletions

File tree

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

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ public async Task<InstructResult> InstructCompletion([FromRoute] string agentId,
2222
[FromBody] InstructMessageModel input)
2323
{
2424
var state = _services.GetRequiredService<IConversationStateService>();
25-
input.States.ForEach(x => state.SetState(x.Key, x.Value, activeRounds: x.ActiveRounds));
26-
state.SetState("provider", input.Provider)
27-
.SetState("model", input.Model)
28-
.SetState("model_id", input.ModelId)
29-
.SetState("instruction", input.Instruction)
30-
.SetState("input_text", input.Text);
25+
input.States.ForEach(x => state.SetState(x.Key, x.Value, activeRounds: x.ActiveRounds, source: StateSource.External));
26+
state.SetState("provider", input.Provider, source: StateSource.External)
27+
.SetState("model", input.Model, source: StateSource.External)
28+
.SetState("model_id", input.ModelId, source: StateSource.External)
29+
.SetState("instruction", input.Instruction, source: StateSource.External)
30+
.SetState("input_text", input.Text,source: StateSource.External);
3131

3232
var instructor = _services.GetRequiredService<IInstructService>();
3333
var result = await instructor.Execute(agentId,
@@ -44,10 +44,10 @@ public async Task<InstructResult> InstructCompletion([FromRoute] string agentId,
4444
public async Task<string> TextCompletion([FromBody] IncomingMessageModel input)
4545
{
4646
var state = _services.GetRequiredService<IConversationStateService>();
47-
input.States.ForEach(x => state.SetState(x.Key, x.Value, activeRounds: x.ActiveRounds));
48-
state.SetState("provider", input.Provider)
49-
.SetState("model", input.Model)
50-
.SetState("model_id", input.ModelId);
47+
input.States.ForEach(x => state.SetState(x.Key, x.Value, activeRounds: x.ActiveRounds, source: StateSource.External));
48+
state.SetState("provider", input.Provider, source: StateSource.External)
49+
.SetState("model", input.Model, source: StateSource.External)
50+
.SetState("model_id", input.ModelId, source: StateSource.External);
5151

5252
var textCompletion = CompletionProvider.GetTextCompletion(_services);
5353
return await textCompletion.GetCompletion(input.Text, Guid.Empty.ToString(), Guid.NewGuid().ToString());
@@ -57,10 +57,10 @@ public async Task<string> TextCompletion([FromBody] IncomingMessageModel input)
5757
public async Task<string> ChatCompletion([FromBody] IncomingMessageModel input)
5858
{
5959
var state = _services.GetRequiredService<IConversationStateService>();
60-
input.States.ForEach(x => state.SetState(x.Key, x.Value, activeRounds: x.ActiveRounds));
61-
state.SetState("provider", input.Provider)
62-
.SetState("model", input.Model)
63-
.SetState("model_id", input.ModelId);
60+
input.States.ForEach(x => state.SetState(x.Key, x.Value, activeRounds: x.ActiveRounds, source: StateSource.External));
61+
state.SetState("provider", input.Provider, source: StateSource.External)
62+
.SetState("model", input.Model, source: StateSource.External)
63+
.SetState("model_id", input.ModelId, source: StateSource.External);
6464

6565
var textCompletion = CompletionProvider.GetChatCompletion(_services);
6666
var message = await textCompletion.GetChatCompletions(new Agent()

0 commit comments

Comments
 (0)