File tree Expand file tree Collapse file tree 2 files changed +8
-7
lines changed
src/Infrastructure/BotSharp.Core/Agents/Services Expand file tree Collapse file tree 2 files changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -70,6 +70,11 @@ public async Task<Agent> GetAgent(string id)
70
70
}
71
71
72
72
profile . Plugin = GetPlugin ( profile . Id ) ;
73
+
74
+ //add default instruction to ChannelInstructions
75
+ var defaultInstruction = new ChannelInstruction ( ) { Channel = string . Empty , Instruction = profile ? . Instruction } ;
76
+ profile . ChannelInstructions . Insert ( 0 , defaultInstruction ) ;
77
+
73
78
return profile ;
74
79
}
75
80
Original file line number Diff line number Diff line change @@ -71,14 +71,10 @@ private void OverrideInstructionByChannel(Agent agent)
71
71
72
72
var state = _services . GetRequiredService < IConversationStateService > ( ) ;
73
73
var channel = state . GetState ( "channel" ) ;
74
-
75
- if ( string . IsNullOrWhiteSpace ( channel ) )
76
- {
77
- return ;
78
- }
79
-
74
+
80
75
var found = instructions . FirstOrDefault ( x => x . Channel . IsEqualTo ( channel ) ) ;
81
- agent . Instruction = ! string . IsNullOrWhiteSpace ( found ? . Instruction ) ? found . Instruction : agent . Instruction ;
76
+ var defaultInstruction = instructions . FirstOrDefault ( x => x . Channel == string . Empty ) ;
77
+ agent . Instruction = ! string . IsNullOrWhiteSpace ( found ? . Instruction ) ? found . Instruction : defaultInstruction ? . Instruction ;
82
78
}
83
79
84
80
private void PopulateState ( Dictionary < string , object > dict )
You can’t perform that action at this time.
0 commit comments