@glydeunity/voice-sdk 1.3.5 → 1.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +10 -2
- package/dist/voice-sdk.es.js +3 -2
- package/dist/voice-sdk.umd.js +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -77,10 +77,18 @@ export declare interface FunctionCallRequest {
|
|
|
77
77
|
* Function call response to send back to Deepgram
|
|
78
78
|
* @see https://developers.deepgram.com/docs/voice-agent-function-call-response
|
|
79
79
|
*/
|
|
80
|
+
/**
|
|
81
|
+
* Function call response to send back to Deepgram Voice Agent
|
|
82
|
+
* @see https://developers.deepgram.com/docs/voice-agent-function-call-response
|
|
83
|
+
*/
|
|
80
84
|
export declare interface FunctionCallResponse {
|
|
81
85
|
type: 'FunctionCallResponse';
|
|
82
|
-
|
|
83
|
-
|
|
86
|
+
/** Unique identifier of the original function call */
|
|
87
|
+
id: string;
|
|
88
|
+
/** Name of the function that was executed */
|
|
89
|
+
name: string;
|
|
90
|
+
/** Text summary or JSON result of the function's output */
|
|
91
|
+
content: string;
|
|
84
92
|
}
|
|
85
93
|
|
|
86
94
|
/**
|
package/dist/voice-sdk.es.js
CHANGED
|
@@ -532,8 +532,9 @@ class y {
|
|
|
532
532
|
}
|
|
533
533
|
const o = {
|
|
534
534
|
type: "FunctionCallResponse",
|
|
535
|
-
|
|
536
|
-
|
|
535
|
+
id: t.id,
|
|
536
|
+
name: t.name,
|
|
537
|
+
content: i
|
|
537
538
|
};
|
|
538
539
|
this.ws && this.ws.readyState === WebSocket.OPEN ? (this.ws.send(JSON.stringify(o)), console.log("[GlydeVoice] Function response sent:", t.name)) : console.error("[GlydeVoice] Cannot send function response - WebSocket not open");
|
|
539
540
|
}
|
package/dist/voice-sdk.umd.js
CHANGED
|
@@ -137,4 +137,4 @@ registerProcessor('audio-playback-processor', AudioPlaybackProcessor);
|
|
|
137
137
|
<p>Context: ${this.config.contextType}</p>
|
|
138
138
|
<button onclick="this.closest('div').remove()">Close</button>
|
|
139
139
|
</div>
|
|
140
|
-
`)}async handleFunctionCallRequest(e){for(const t of e.functions){console.log("[GlydeVoice] Function call request:",t.name,t.arguments);let s={};try{s=t.arguments?JSON.parse(t.arguments):{}}catch(n){console.warn("[GlydeVoice] Failed to parse function arguments:",n)}let i;try{t.name==="end_conversation"?i=await this.handleEndConversation(s):i=await this.executeVoiceFunction(t.name,t.id,s)}catch(n){console.error("[GlydeVoice] Function call error:",n),i=JSON.stringify({error:"Function execution failed",details:n instanceof Error?n.message:String(n)})}const o={type:"FunctionCallResponse",
|
|
140
|
+
`)}async handleFunctionCallRequest(e){for(const t of e.functions){console.log("[GlydeVoice] Function call request:",t.name,t.arguments);let s={};try{s=t.arguments?JSON.parse(t.arguments):{}}catch(n){console.warn("[GlydeVoice] Failed to parse function arguments:",n)}let i;try{t.name==="end_conversation"?i=await this.handleEndConversation(s):i=await this.executeVoiceFunction(t.name,t.id,s)}catch(n){console.error("[GlydeVoice] Function call error:",n),i=JSON.stringify({error:"Function execution failed",details:n instanceof Error?n.message:String(n)})}const o={type:"FunctionCallResponse",id:t.id,name:t.name,content:i};this.ws&&this.ws.readyState===WebSocket.OPEN?(this.ws.send(JSON.stringify(o)),console.log("[GlydeVoice] Function response sent:",t.name)):console.error("[GlydeVoice] Cannot send function response - WebSocket not open")}}async executeVoiceFunction(e,t,s){console.log("[GlydeVoice] Executing voice function via Unity API:",e);try{const i=await fetch(`${this.unityUrl}/api/unity/voice/function`,{method:"POST",headers:this.getAuthHeaders(),body:JSON.stringify({function_name:e,function_call_id:t,input:s,context:{context_id:this.sessionContext.contextId,context_type:this.sessionContext.contextType,current_job_uuid:this.sessionContext.currentJobUuid}})});if(!i.ok){const n=await i.json().catch(()=>({}));throw new Error(n.error?.message||`Function call failed: ${i.status}`)}const o=await i.json();if(o.success&&o.data?.output)return typeof o.data.output=="string"?o.data.output:JSON.stringify(o.data.output);throw new Error("Invalid response from voice function endpoint")}catch(i){return console.error("[GlydeVoice] Voice function error:",i),JSON.stringify({success:!1,error:i instanceof Error?i.message:"Function execution failed",fallback_message:"I apologize, but I'm having trouble with that request right now. Is there something else I can help you with?"})}}async handleEndConversation(e){const t=e.item||"user request";return console.log(`[GlydeVoice] End conversation triggered by: ${t}`),setTimeout(()=>{this.stop()},2e3),JSON.stringify({success:!0,message:"Conversation ending. Say goodbye to the user.",trigger_phrase:t})}setSessionContext(e){this.sessionContext={...this.sessionContext,...e},console.log("[GlydeVoice] Session context updated:",{hasContextId:!!e.contextId,contextType:e.contextType,hasJobUuid:!!e.currentJobUuid})}}c.GlydeVoice=f,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})}));
|