Skip to contents

Factory function to create an instance of a ConversationFlow subclass.

Usage

create_conversation_flow(mode, agents, moderator_id, flow_params = list())

Arguments

mode

Character. The type of turn-taking flow to create. Supported: "round_robin", "probabilistic", "desire_based".

agents

A named list of FGAgent objects.

moderator_id

Character. The ID of the moderator agent.

flow_params

List. Additional parameters specific to the chosen flow type. For "probabilistic": initial_propensities (named numeric vector), recovery_increment (numeric). For "desire_based": min_desire_threshold (numeric) and on_desire_failure, "error" (the default) or "random". Under "error" a desire score that cannot be obtained, after its retry, stops the session with an error of class focusgroup_desire_failure. Under "random" the speaker is chosen among the participants with valid scores by the usual rule, and uniformly among the eligible participants only when none has a valid score; the failure is recorded in the selected message's metadata$desire_scoring_failure. Earlier versions always chose uniformly at random when any score failed.

Value

An initialized ConversationFlow object (e.g., RoundRobinFlow, ProbabilisticFlow, DesireBasedFlow).

Examples

cfg <- LLMR::llm_config("groq", "openai/gpt-oss-20b",
                        api_key = LLMR::llm_api_key_env("GROQ_API_KEY"))
agents <- create_agents(
  n_participants = 2, config = cfg,
  direct_persona_descriptions = c("A retired teacher.", "A night-shift nurse."))
flow <- create_conversation_flow("desire_based", agents, "MOD",
                                 flow_params = list(min_desire_threshold = 4))
class(flow)
#> [1] "DesireBasedFlow"  "ConversationFlow" "R6"              
flow$participant_ids
#> [1] "P1" "P2"