-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ebb6b10
commit a89b6fc
Showing
6 changed files
with
86 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
ChatRoom/ChatRoom.Common/Orleans/AutoGenOrchestratorObserver.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using AutoGen.Core; | ||
|
||
namespace ChatRoom.SDK.Orleans; | ||
|
||
internal class AutoGenOrchestratorObserver : IOrchestratorObserver | ||
{ | ||
private readonly AutoGen.Core.IOrchestrator _orchestrator; | ||
public AutoGenOrchestratorObserver(AutoGen.Core.IOrchestrator orchestrator) | ||
{ | ||
_orchestrator = orchestrator; | ||
} | ||
|
||
public async Task<string?> GetNextSpeaker(AgentInfo[] members, ChatMsg[] messages) | ||
{ | ||
var autogenMessages = messages.Select(msg => msg.ToAutoGenMessage()).ToArray(); | ||
var dummyAgents = members.Select(x => new DummyAgent(x)).ToArray(); | ||
|
||
var context = new OrchestrationContext() | ||
{ | ||
Candidates = dummyAgents, | ||
ChatHistory = autogenMessages, | ||
}; | ||
|
||
var nextAgent = await _orchestrator.GetNextSpeakerAsync(context); | ||
|
||
return nextAgent?.Name; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters