Merge pull request #1069 from yileicn/master
hotfix AddDefaultInstruction
This commit is contained in:
commit
c8149b63e2
|
|
@ -71,13 +71,25 @@ public partial class AgentService
|
|||
|
||||
profile.Plugin = GetPlugin(profile.Id);
|
||||
|
||||
//add default instruction to ChannelInstructions
|
||||
var defaultInstruction = new ChannelInstruction() { Channel = string.Empty, Instruction = profile?.Instruction };
|
||||
profile.ChannelInstructions.Insert(0, defaultInstruction);
|
||||
AddDefaultInstruction(profile, profile.Instruction);
|
||||
|
||||
return profile;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add default instruction to ChannelInstructions
|
||||
/// </summary>
|
||||
private void AddDefaultInstruction(Agent agent, string instruction)
|
||||
{
|
||||
//check if instruction is empty
|
||||
if (string.IsNullOrWhiteSpace(instruction)) return;
|
||||
//check if instruction is already set
|
||||
if (agent.ChannelInstructions.Exists(p => p.Channel == string.Empty)) return;
|
||||
//Add default instruction to ChannelInstructions
|
||||
var defaultInstruction = new ChannelInstruction() { Channel = string.Empty, Instruction = instruction };
|
||||
agent.ChannelInstructions.Insert(0, defaultInstruction);
|
||||
}
|
||||
|
||||
public async Task InheritAgent(Agent agent)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(agent?.InheritAgentId)) return;
|
||||
|
|
@ -98,6 +110,7 @@ public partial class AgentService
|
|||
if (string.IsNullOrWhiteSpace(agent.Instruction))
|
||||
{
|
||||
agent.Instruction = inheritedAgent.Instruction;
|
||||
AddDefaultInstruction(agent, inheritedAgent.Instruction);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue