Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Added interrupt option to Conversation and useConversation #18

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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 packages/client/src/index.ts
Original file line number Diff line number Diff line change
@@ -438,6 +438,11 @@ export class Conversation {
this.lastFeedbackEventId = this.currentEventId;
this.updateCanSendFeedback();
};

public interrupt = () => {
this.lastInterruptTimestamp = this.currentEventId
return this.fadeOutAudio()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should set the lastInterruptionTimestamp to the currentEventId to prevent future audio chunks streamed for the current agent response from canceling the fadeout

};
}

export function postOverallFeedback(
3 changes: 3 additions & 0 deletions packages/react/src/index.ts
Original file line number Diff line number Diff line change
@@ -128,6 +128,9 @@ export function useConversation<T extends HookOptions & ControlledState>(props:
sendFeedback: (like: boolean) => {
conversationRef.current?.sendFeedback(like);
},
interrupt: () => {
conversationRef.current?.interrupt();
},
getId: () => {
return conversationRef.current?.getId();
},