Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions .changeset/live-model-swaps.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@livekit/agents': patch
---

Add `updateOptions` support to inference LLM for live model swaps.
21 changes: 21 additions & 0 deletions agents/src/inference/llm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,27 @@ export class LLM extends llm.LLM {
return new LLM({ model: modelString });
}

/**
* Update LLM configuration options used by the next chat call.
*
* `modelOptions` replaces the persistent options object instead of merging;
* pass `{}` to clear it.
*/
updateOptions({
model,
modelOptions,
}: {
model?: LLMModels;
modelOptions?: ChatCompletionOptions;
}): void {
if (model !== undefined) {
this.opts.model = model;
}
if (modelOptions !== undefined) {
this.opts.modelOptions = { ...modelOptions };
}
}

chat({
chatCtx,
toolCtx,
Expand Down
Loading