Merge pull request #96 from hchen2020/master
Support agent switch based on state.
This commit is contained in:
commit
692f6b76fb
|
|
@ -41,7 +41,7 @@ public abstract class ConversationCompletionHookBase : IConversationCompletionHo
|
|||
return this;
|
||||
}
|
||||
|
||||
public virtual Task OnStateLoaded(ConversationState state)
|
||||
public virtual Task OnStateLoaded(ConversationState state, Action<Agent, string>? onAgentSwitched = null)
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ public interface IConversationCompletionHook
|
|||
IChatCompletion ChatCompletion { get; }
|
||||
IConversationCompletionHook SetChatCompletion(IChatCompletion chatCompletion);
|
||||
|
||||
Task OnStateLoaded(ConversationState state);
|
||||
Task OnStateLoaded(ConversationState state, Action<Agent, string>? onAgentSwitched = null);
|
||||
Task BeforeCompletion();
|
||||
Task OnFunctionExecuting(string name, string args);
|
||||
Task AfterCompletion(RoleDialogModel message);
|
||||
|
|
|
|||
|
|
@ -149,7 +149,11 @@ public class ConversationService : IConversationService
|
|||
.SetDialogs(wholeDialogs)
|
||||
.SetChatCompletion(chatCompletion);
|
||||
|
||||
await hook.OnStateLoaded(state);
|
||||
await hook.OnStateLoaded(state, onAgentSwitched: (x, prompt) =>
|
||||
{
|
||||
agent = x;
|
||||
wholeDialogs.Add(new RoleDialogModel("user", prompt));
|
||||
});
|
||||
await hook.BeforeCompletion();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue