Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 51 additions & 14 deletions cmd/lk/simulate.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@
simulateProjectConfig = pc
return nil, nil
},
Action: runSimulate,
Action: func(ctx context.Context, cmd *cli.Command) error {
return runSimulate(ctx, cmd, livekit.SimulationMode_SIMULATION_MODE_TEXT)
},
Commands: []*cli.Command{simulateAudioCommand},
Flags: []cli.Flag{
&cli.IntFlag{
Name: "num-simulations",
Expand All @@ -85,10 +88,6 @@
Name: "scenarios",
Usage: "Path to a scenarios `FILE` (yaml). If omitted, scenarios are generated from the agent's source",
},
&cli.BoolFlag{
Name: "audio",
Usage: "Simulate speech-to-speech interactions using the agent's full audio pipeline. By default, simulations run in text-only mode.",
},
&cli.BoolFlag{
Name: "yes",
Aliases: []string{"y"},
Expand All @@ -109,6 +108,34 @@
},
}

// simulateAudioCommand inherits every flag on `simulate`: flags there are
// persistent (cli.FlagBase.Local defaults to false), so they parse on either
// side of the subcommand name.
var simulateAudioCommand = &cli.Command{
Name: "audio",
Usage: "Simulate speech-to-speech interactions using the agent's full audio pipeline",
Description: "Options on lk agent simulate apply here too, e.g. --scenarios and --agent-name.",
ArgsUsage: "[entrypoint]",
HideHelpCommand: true,
Action: func(ctx context.Context, cmd *cli.Command) error {
return runSimulate(ctx, cmd, livekit.SimulationMode_SIMULATION_MODE_AUDIO)
},
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "background-noise",
Usage: "Mix ambient noise into the simulated user's audio",
},
&cli.BoolFlag{
Name: "low-quality-microphone",
Usage: "Publish the simulated user's audio as a low-quality microphone would capture it",
},
&cli.BoolFlag{
Name: "packet-loss",
Usage: "Drop packets from the simulated user's audio track",
},
},
}

// writeGeneratedScenariosTemp writes a generated run's scenarios to a temp
// scenarios.yaml; "" when the run carries none.
func writeGeneratedScenariosTemp(run *livekit.SimulationRun) (string, error) {
Expand Down Expand Up @@ -189,6 +216,12 @@
viewModeRunID string // non-empty when --view opens a pre-existing run
liveAgent bool // --agent-name: run against an already-running agent, don't spawn one
warnings []string // config-level warnings surfaced at setup (e.g. ignored flags)

// impairments on the simulated user's audio, set only in SIMULATION_MODE_AUDIO
backgroundNoise bool
lowQualityMicrophone bool
packetLoss bool

// TODO (steveyoon): add agent deployment support
// agentDeployment string
}
Expand Down Expand Up @@ -273,7 +306,7 @@
return ok, nil
}

func runSimulate(ctx context.Context, cmd *cli.Command) error {
func runSimulate(ctx context.Context, cmd *cli.Command, simulationMode livekit.SimulationMode) error {
pc := simulateProjectConfig

// --export is a one-shot read of a finished run, so it short-circuits
Expand Down Expand Up @@ -368,11 +401,6 @@

simClient := lksdk.NewAgentSimulationClient(serverURL, pc.APIKey, pc.APISecret)

simulationMode := livekit.SimulationMode_SIMULATION_MODE_TEXT
if cmd.Bool("audio") {
simulationMode = livekit.SimulationMode_SIMULATION_MODE_AUDIO
}

simCfg := &simulateConfig{
ctx: ctx,
client: simClient,
Expand All @@ -392,6 +420,12 @@
warnings: simulateConfigWarnings(mode, numSimulations),
}

if simulationMode == livekit.SimulationMode_SIMULATION_MODE_AUDIO {
simCfg.backgroundNoise = cmd.Bool("background-noise")
simCfg.lowQualityMicrophone = cmd.Bool("low-quality-microphone")
simCfg.packetLoss = cmd.Bool("packet-loss")
}

if !isInteractive() {
return runSimulateCI(ctx, simCfg)
}
Expand Down Expand Up @@ -522,9 +556,12 @@

func createSimulationRun(ctx context.Context, c *simulateConfig) (string, *livekit.PresignedPostRequest, error) {
req := &livekit.SimulationRun_Create_Request{
AgentName: c.agentName,
NumSimulations: c.numSimulations,
Mode: c.simulationMode,
AgentName: c.agentName,
NumSimulations: c.numSimulations,
Mode: c.simulationMode,
BackgroundNoise: c.backgroundNoise,

Check failure on line 562 in cmd/lk/simulate.go

View workflow job for this annotation

GitHub Actions / lk agent with python agent on ubuntu-latest

unknown field BackgroundNoise in struct literal of type livekit.SimulationRun_Create_Request

Check failure on line 562 in cmd/lk/simulate.go

View workflow job for this annotation

GitHub Actions / lk agent with node agent on ubuntu-latest

unknown field BackgroundNoise in struct literal of type livekit.SimulationRun_Create_Request

Check failure on line 562 in cmd/lk/simulate.go

View workflow job for this annotation

GitHub Actions / lk agent with node agent on macos-latest

unknown field BackgroundNoise in struct literal of type livekit.SimulationRun_Create_Request

Check failure on line 562 in cmd/lk/simulate.go

View workflow job for this annotation

GitHub Actions / lk agent with python agent on macos-latest

unknown field BackgroundNoise in struct literal of type livekit.SimulationRun_Create_Request

Check failure on line 562 in cmd/lk/simulate.go

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unknown field BackgroundNoise in struct literal of type livekit.SimulationRun_Create_Request

Check failure on line 562 in cmd/lk/simulate.go

View workflow job for this annotation

GitHub Actions / Cross-build Windows artifacts (zig)

unknown field BackgroundNoise in struct literal of type livekit.SimulationRun_Create_Request

Check failure on line 562 in cmd/lk/simulate.go

View workflow job for this annotation

GitHub Actions / test (macos-latest)

unknown field BackgroundNoise in struct literal of type livekit.SimulationRun_Create_Request

Check failure on line 562 in cmd/lk/simulate.go

View workflow job for this annotation

GitHub Actions / Build darwin (native)

unknown field BackgroundNoise in struct literal of type livekit.SimulationRun_Create_Request

Check failure on line 562 in cmd/lk/simulate.go

View workflow job for this annotation

GitHub Actions / Cross-build Windows artifacts (zig)

unknown field BackgroundNoise in struct literal of type livekit.SimulationRun_Create_Request
LowQualityMicrophone: c.lowQualityMicrophone,

Check failure on line 563 in cmd/lk/simulate.go

View workflow job for this annotation

GitHub Actions / lk agent with python agent on ubuntu-latest

unknown field LowQualityMicrophone in struct literal of type livekit.SimulationRun_Create_Request

Check failure on line 563 in cmd/lk/simulate.go

View workflow job for this annotation

GitHub Actions / lk agent with node agent on ubuntu-latest

unknown field LowQualityMicrophone in struct literal of type livekit.SimulationRun_Create_Request

Check failure on line 563 in cmd/lk/simulate.go

View workflow job for this annotation

GitHub Actions / lk agent with node agent on macos-latest

unknown field LowQualityMicrophone in struct literal of type livekit.SimulationRun_Create_Request

Check failure on line 563 in cmd/lk/simulate.go

View workflow job for this annotation

GitHub Actions / lk agent with python agent on macos-latest

unknown field LowQualityMicrophone in struct literal of type livekit.SimulationRun_Create_Request

Check failure on line 563 in cmd/lk/simulate.go

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unknown field LowQualityMicrophone in struct literal of type livekit.SimulationRun_Create_Request

Check failure on line 563 in cmd/lk/simulate.go

View workflow job for this annotation

GitHub Actions / Cross-build Windows artifacts (zig)

unknown field LowQualityMicrophone in struct literal of type livekit.SimulationRun_Create_Request

Check failure on line 563 in cmd/lk/simulate.go

View workflow job for this annotation

GitHub Actions / test (macos-latest)

unknown field LowQualityMicrophone in struct literal of type livekit.SimulationRun_Create_Request

Check failure on line 563 in cmd/lk/simulate.go

View workflow job for this annotation

GitHub Actions / Build darwin (native)

unknown field LowQualityMicrophone in struct literal of type livekit.SimulationRun_Create_Request

Check failure on line 563 in cmd/lk/simulate.go

View workflow job for this annotation

GitHub Actions / Cross-build Windows artifacts (zig)

unknown field LowQualityMicrophone in struct literal of type livekit.SimulationRun_Create_Request
PacketLoss: c.packetLoss,

Check failure on line 564 in cmd/lk/simulate.go

View workflow job for this annotation

GitHub Actions / lk agent with python agent on ubuntu-latest

unknown field PacketLoss in struct literal of type livekit.SimulationRun_Create_Request

Check failure on line 564 in cmd/lk/simulate.go

View workflow job for this annotation

GitHub Actions / lk agent with node agent on ubuntu-latest

unknown field PacketLoss in struct literal of type livekit.SimulationRun_Create_Request

Check failure on line 564 in cmd/lk/simulate.go

View workflow job for this annotation

GitHub Actions / lk agent with node agent on macos-latest

unknown field PacketLoss in struct literal of type livekit.SimulationRun_Create_Request

Check failure on line 564 in cmd/lk/simulate.go

View workflow job for this annotation

GitHub Actions / lk agent with python agent on macos-latest

unknown field PacketLoss in struct literal of type livekit.SimulationRun_Create_Request

Check failure on line 564 in cmd/lk/simulate.go

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

unknown field PacketLoss in struct literal of type livekit.SimulationRun_Create_Request (typecheck)

Check failure on line 564 in cmd/lk/simulate.go

View workflow job for this annotation

GitHub Actions / Cross-build Windows artifacts (zig)

unknown field PacketLoss in struct literal of type livekit.SimulationRun_Create_Request

Check failure on line 564 in cmd/lk/simulate.go

View workflow job for this annotation

GitHub Actions / test (macos-latest)

unknown field PacketLoss in struct literal of type livekit.SimulationRun_Create_Request (typecheck)

Check failure on line 564 in cmd/lk/simulate.go

View workflow job for this annotation

GitHub Actions / Build darwin (native)

unknown field PacketLoss in struct literal of type livekit.SimulationRun_Create_Request

Check failure on line 564 in cmd/lk/simulate.go

View workflow job for this annotation

GitHub Actions / Cross-build Windows artifacts (zig)

unknown field PacketLoss in struct literal of type livekit.SimulationRun_Create_Request
}
if c.concurrency > 0 {
req.Concurrency = &c.concurrency
Expand Down
Loading