Skip to content

Commit

Permalink
prevent wrong setup from passing through to server
Browse files Browse the repository at this point in the history
  • Loading branch information
Mahmoudz committed Mar 27, 2024
1 parent 26e9288 commit 0e129eb
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/core/vuic.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,6 @@ class Vuic extends EventEmitter {
}
}

registerFunctions(functionSignatures, functionReferences) {
console.log('--[VUIC]-- registerFunctions');

this.functionSignatures = functionSignatures;
this.functionReferences = functionReferences;
}

startVoiceRecording = async () => {
console.log('--[VUIC]-- startVoiceRecording');

Expand Down Expand Up @@ -114,6 +107,10 @@ class Vuic extends EventEmitter {
_processVoiceCommand = async (audioBlob) => {
console.log('--[VUIC]-- _processVoiceCommand');

if (!this.functionSignatures || this.functionSignatures.length === 0) {
throw new Error('functionSignatures array is empty. Please register your voice activated functions. See docs https://docs.sista.ai`');
}

const formData = new FormData();
formData.append('audio', audioBlob);
formData.append(
Expand Down Expand Up @@ -202,6 +199,10 @@ class Vuic extends EventEmitter {
_executeFunctions = (message) => {
console.log('--[VUIC]-- _executeFunctions');

if (!this.functionReferences || this.functionReferences.length === 0) {
throw new Error('functionReferences array is empty. Please register your voice activated functions. See docs https://docs.sista.ai');
}

if (!message || !message.tool_calls) {
console.error('E1: Invalid API response:', message);
return;
Expand Down

0 comments on commit 0e129eb

Please sign in to comment.