feat: interrupt function (#1)
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -33,3 +33,4 @@ yarn-error.log*
|
|||||||
# typescript
|
# typescript
|
||||||
*.tsbuildinfo
|
*.tsbuildinfo
|
||||||
next-env.d.ts
|
next-env.d.ts
|
||||||
|
.idea
|
||||||
|
|||||||
@@ -131,6 +131,16 @@ export default function StreamingAvatar() {
|
|||||||
setInitialized(true);
|
setInitialized(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function handleInterrupt() {
|
||||||
|
if (!initialized || !avatar.current) {
|
||||||
|
setDebug('Avatar API not initialized');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await avatar.current.interrupt({ interruptRequest: { sessionId: data?.sessionId } }).catch((e) => {
|
||||||
|
setDebug(e.message);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
async function endSession() {
|
async function endSession() {
|
||||||
if (!initialized || !avatar.current) {
|
if (!initialized || !avatar.current) {
|
||||||
setDebug("Avatar API not initialized");
|
setDebug("Avatar API not initialized");
|
||||||
@@ -249,6 +259,14 @@ export default function StreamingAvatar() {
|
|||||||
>
|
>
|
||||||
<track kind="captions" />
|
<track kind="captions" />
|
||||||
</video>
|
</video>
|
||||||
|
<Button
|
||||||
|
size="md"
|
||||||
|
onClick={handleInterrupt}
|
||||||
|
className="bg-gradient-to-tr from-indigo-500 to-indigo-300 absolute bottom-20 right-3 text-white rounded-lg"
|
||||||
|
variant="shadow"
|
||||||
|
>
|
||||||
|
Interrupt
|
||||||
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
size="md"
|
size="md"
|
||||||
onClick={endSession}
|
onClick={endSession}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ai-sdk/openai": "^0.0.34",
|
"@ai-sdk/openai": "^0.0.34",
|
||||||
"@heygen/streaming-avatar": "^1.0.10",
|
"@heygen/streaming-avatar": "^1.0.11",
|
||||||
"@nextui-org/button": "2.0.34",
|
"@nextui-org/button": "2.0.34",
|
||||||
"@nextui-org/code": "2.0.29",
|
"@nextui-org/code": "2.0.29",
|
||||||
"@nextui-org/input": "2.2.2",
|
"@nextui-org/input": "2.2.2",
|
||||||
|
|||||||
Reference in New Issue
Block a user