pub struct GroupChatBuilder { /* private fields */ }Expand description
Builder for a group chat workflow. Rust analogue of GroupChatBuilder.
let workflow = GroupChatBuilder::new()
.participant("writer", writer)
.participant("reviewer", reviewer)
.round_robin()
.max_rounds(4)
.build()?;Implementations§
Source§impl GroupChatBuilder
impl GroupChatBuilder
Sourcepub fn new() -> GroupChatBuilder
pub fn new() -> GroupChatBuilder
Create an empty builder (round-robin manager by default).
Sourcepub fn participant(
self,
name: impl Into<String>,
agent: Arc<dyn SupportsAgentRun>,
) -> GroupChatBuilder
pub fn participant( self, name: impl Into<String>, agent: Arc<dyn SupportsAgentRun>, ) -> GroupChatBuilder
Register a participant (its description defaults to its name).
Sourcepub fn participant_described(
self,
name: impl Into<String>,
description: impl Into<String>,
agent: Arc<dyn SupportsAgentRun>,
) -> GroupChatBuilder
pub fn participant_described( self, name: impl Into<String>, description: impl Into<String>, agent: Arc<dyn SupportsAgentRun>, ) -> GroupChatBuilder
Register a participant with an explicit description (shown to an LLM manager for selection).
Sourcepub fn participants(
self,
participants: impl IntoIterator<Item = (String, Arc<dyn SupportsAgentRun>)>,
) -> GroupChatBuilder
pub fn participants( self, participants: impl IntoIterator<Item = (String, Arc<dyn SupportsAgentRun>)>, ) -> GroupChatBuilder
Register several participants as (name, agent) pairs.
Sourcepub fn round_robin(self) -> GroupChatBuilder
pub fn round_robin(self) -> GroupChatBuilder
Use the built-in round-robin manager (the default).
Sourcepub fn manager(self, manager: Arc<dyn GroupChatManager>) -> GroupChatBuilder
pub fn manager(self, manager: Arc<dyn GroupChatManager>) -> GroupChatBuilder
Use a custom GroupChatManager.
Sourcepub fn manager_fn<F>(self, f: F) -> GroupChatBuilder
pub fn manager_fn<F>(self, f: F) -> GroupChatBuilder
Use a custom synchronous closure to select the next speaker or finish.
Sourcepub fn manager_agent(self, agent: Arc<dyn SupportsAgentRun>) -> GroupChatBuilder
pub fn manager_agent(self, agent: Arc<dyn SupportsAgentRun>) -> GroupChatBuilder
Use an LLM agent as the manager (prompted with
DEFAULT_MANAGER_INSTRUCTIONS and asked for a
ManagerSelectionResponse as JSON).
Sourcepub fn max_rounds(self, max_rounds: usize) -> GroupChatBuilder
pub fn max_rounds(self, max_rounds: usize) -> GroupChatBuilder
Cap the number of manager rounds. When unset, the builder applies
DEFAULT_GROUP_CHAT_MAX_ITERATIONS.
Sourcepub fn termination_condition<F>(self, condition: F) -> GroupChatBuilder
pub fn termination_condition<F>(self, condition: F) -> GroupChatBuilder
Set a termination condition evaluated against the running conversation before each manager turn.
Sourcepub fn manager_name(self, name: impl Into<String>) -> GroupChatBuilder
pub fn manager_name(self, name: impl Into<String>) -> GroupChatBuilder
Override the manager’s display name (used to attribute its messages).
Sourcepub fn name(self, name: impl Into<String>) -> GroupChatBuilder
pub fn name(self, name: impl Into<String>) -> GroupChatBuilder
Set the workflow name.
Sourcepub fn output_from(
self,
names: impl IntoIterator<Item = impl Into<String>>,
) -> GroupChatBuilder
pub fn output_from( self, names: impl IntoIterator<Item = impl Into<String>>, ) -> GroupChatBuilder
Designate participants (by the name passed to
Self::participant/Self::participant_described) as a workflow
output source, forwarded to WorkflowBuilder::output_from.
Divergence from Sequential/Concurrent: unlike those builders, a
group chat compiles to a single orchestrator Executor that runs
the whole manager/participant loop internally (see the module-level
design note) rather than one executor per participant, so there is no
per-participant executor id to route to individually. Naming any
participant here is therefore equivalent to naming every participant:
it simply keeps the orchestrator’s single final yield — the finished
conversation — as the terminal WorkflowEvent::Output
(already the default when no designation is set at all). Its
practical purpose is composing a group chat into a larger workflow:
call Self::intermediate_output_from instead to demote the group
chat’s result to a non-terminal
WorkflowEvent::Intermediate
event, e.g. when this workflow feeds a downstream stage.
Rejected at build() if a name does not match any registered
participant, or if this and Self::intermediate_output_from are
both non-empty (both resolve to the same underlying executor id, so
the id would be designated as both terminal and non-terminal).
Sourcepub fn intermediate_output_from(
self,
names: impl IntoIterator<Item = impl Into<String>>,
) -> GroupChatBuilder
pub fn intermediate_output_from( self, names: impl IntoIterator<Item = impl Into<String>>, ) -> GroupChatBuilder
Designate participants (by name) as an intermediate-output source,
demoting the group chat orchestrator’s single final yield to a
non-terminal WorkflowEvent::Intermediate
event instead of the workflow’s terminal output. See
Self::output_from for the single-executor caveat.