Skip to content

Commit

Permalink
fix: error on switchToThread / switchToNewThread (#732)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yonom authored Sep 5, 2024
1 parent 8ec5acc commit 800eb9e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/spicy-bananas-sin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@assistant-ui/react": patch
---

fix: error on switchToThread / switchToNewThread
8 changes: 6 additions & 2 deletions packages/react/src/runtimes/local/LocalThreadRuntime.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ export class LocalThreadRuntime implements ThreadRuntime {

private _options!: LocalRuntimeOptions;

public get options() {
return this._options;
}

public set options({ initialMessages, ...options }: LocalRuntimeOptions) {
this._options = options;

Expand Down Expand Up @@ -175,7 +179,7 @@ export class LocalThreadRuntime implements ThreadRuntime {
this.notifySubscribers();
};

const maxToolRoundtrips = this._options.maxToolRoundtrips ?? 1;
const maxToolRoundtrips = this.options.maxToolRoundtrips ?? 1;
const toolRoundtrips = message.metadata?.roundtrips?.length ?? 0;
if (toolRoundtrips > maxToolRoundtrips) {
// reached max tool roundtrips
Expand Down Expand Up @@ -294,7 +298,7 @@ export class LocalThreadRuntime implements ThreadRuntime {
private _utterance: SpeechSynthesisAdapter.Utterance | undefined;

public speak(messageId: string) {
const adapter = this._options.adapters?.speech;
const adapter = this.options.adapters?.speech;
if (!adapter) throw new Error("Speech adapter not configured");

const { message } = this.repository.getMessage(messageId);
Expand Down

0 comments on commit 800eb9e

Please sign in to comment.