deepgram.clients.agent.v1.websocket.response

  1# Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved.
  2# Use of this source code is governed by a MIT license that can be found in the LICENSE file.
  3# SPDX-License-Identifier: MIT
  4
  5from typing import List, Optional, Dict, Any
  6
  7from dataclasses import dataclass
  8
  9# common websocket response
 10from ....common import (
 11    BaseResponse,
 12    OpenResponse,
 13    CloseResponse,
 14    ErrorResponse,
 15    UnhandledResponse,
 16)
 17
 18# unique
 19
 20
 21@dataclass
 22class WelcomeResponse(BaseResponse):
 23    """
 24    The server will send a Welcome message as soon as the websocket opens.
 25    """
 26
 27    type: str
 28    session_id: str
 29
 30
 31@dataclass
 32class SettingsAppliedResponse(BaseResponse):
 33    """
 34    The server will send a SettingsApplied message as soon as the settings are applied.
 35    """
 36
 37    type: str
 38
 39
 40@dataclass
 41class ConversationTextResponse(BaseResponse):
 42    """
 43    The server will send a ConversationText message every time the agent hears the user say something, and every time the agent speaks something itself.
 44    """
 45
 46    type: str
 47    role: str
 48    content: str
 49
 50
 51@dataclass
 52class UserStartedSpeakingResponse(BaseResponse):
 53    """
 54    The server will send a UserStartedSpeaking message every time the user begins a new utterance.
 55    """
 56
 57    type: str
 58
 59
 60@dataclass
 61class AgentThinkingResponse(BaseResponse):
 62    """
 63    The server will send an AgentThinking message to inform the client of a non-verbalized agent thought.
 64    """
 65
 66    type: str
 67    content: str
 68
 69
 70@dataclass
 71class FunctionCalling(BaseResponse):
 72    """
 73    The server will sometimes send FunctionCalling messages when making function calls to help the client developer debug function calling workflows.
 74    """
 75
 76    type: str
 77
 78
 79@dataclass
 80class FunctionCallRequest(BaseResponse):
 81    """
 82    The FunctionCallRequest message is used to call a function from the server to the client.
 83    """
 84
 85    type: str
 86    function_name: str
 87    function_call_id: str
 88    input: str
 89
 90
 91@dataclass
 92class AgentStartedSpeakingResponse(BaseResponse):
 93    """
 94    The server will send an AgentStartedSpeaking message when it begins streaming an agent audio response to the client for playback.
 95    """
 96
 97    total_latency: float
 98    tts_latency: float
 99    ttt_latency: float
100
101
102@dataclass
103class AgentAudioDoneResponse(BaseResponse):
104    """
105    The server will send an AgentAudioDone message immediately after it sends the last audio message in a piece of agent speech.
106    """
107
108    type: str
109
110
111@dataclass
112class InjectionRefusedResponse(BaseResponse):
113    """
114    The server will send an InjectionRefused message when an InjectAgentMessage request is ignored because it arrived while the user was speaking or while the server was sending audio for an agent response.
115    """
116
117    type: str
@dataclass
class WelcomeResponse(deepgram.clients.common.v1.shared_response.BaseResponse):
22@dataclass
23class WelcomeResponse(BaseResponse):
24    """
25    The server will send a Welcome message as soon as the websocket opens.
26    """
27
28    type: str
29    session_id: str

The server will send a Welcome message as soon as the websocket opens.

WelcomeResponse(type: str, session_id: str)
type: str
session_id: str
@dataclass
class SettingsAppliedResponse(deepgram.clients.common.v1.shared_response.BaseResponse):
32@dataclass
33class SettingsAppliedResponse(BaseResponse):
34    """
35    The server will send a SettingsApplied message as soon as the settings are applied.
36    """
37
38    type: str

The server will send a SettingsApplied message as soon as the settings are applied.

SettingsAppliedResponse(type: str)
type: str
@dataclass
class ConversationTextResponse(deepgram.clients.common.v1.shared_response.BaseResponse):
41@dataclass
42class ConversationTextResponse(BaseResponse):
43    """
44    The server will send a ConversationText message every time the agent hears the user say something, and every time the agent speaks something itself.
45    """
46
47    type: str
48    role: str
49    content: str

The server will send a ConversationText message every time the agent hears the user say something, and every time the agent speaks something itself.

ConversationTextResponse(type: str, role: str, content: str)
type: str
role: str
content: str
@dataclass
class UserStartedSpeakingResponse(deepgram.clients.common.v1.shared_response.BaseResponse):
52@dataclass
53class UserStartedSpeakingResponse(BaseResponse):
54    """
55    The server will send a UserStartedSpeaking message every time the user begins a new utterance.
56    """
57
58    type: str

The server will send a UserStartedSpeaking message every time the user begins a new utterance.

UserStartedSpeakingResponse(type: str)
type: str
@dataclass
class AgentThinkingResponse(deepgram.clients.common.v1.shared_response.BaseResponse):
61@dataclass
62class AgentThinkingResponse(BaseResponse):
63    """
64    The server will send an AgentThinking message to inform the client of a non-verbalized agent thought.
65    """
66
67    type: str
68    content: str

The server will send an AgentThinking message to inform the client of a non-verbalized agent thought.

AgentThinkingResponse(type: str, content: str)
type: str
content: str
@dataclass
class FunctionCalling(deepgram.clients.common.v1.shared_response.BaseResponse):
71@dataclass
72class FunctionCalling(BaseResponse):
73    """
74    The server will sometimes send FunctionCalling messages when making function calls to help the client developer debug function calling workflows.
75    """
76
77    type: str

The server will sometimes send FunctionCalling messages when making function calls to help the client developer debug function calling workflows.

FunctionCalling(type: str)
type: str
@dataclass
class FunctionCallRequest(deepgram.clients.common.v1.shared_response.BaseResponse):
80@dataclass
81class FunctionCallRequest(BaseResponse):
82    """
83    The FunctionCallRequest message is used to call a function from the server to the client.
84    """
85
86    type: str
87    function_name: str
88    function_call_id: str
89    input: str

The FunctionCallRequest message is used to call a function from the server to the client.

FunctionCallRequest(type: str, function_name: str, function_call_id: str, input: str)
type: str
function_name: str
function_call_id: str
input: str
@dataclass
class AgentStartedSpeakingResponse(deepgram.clients.common.v1.shared_response.BaseResponse):
 92@dataclass
 93class AgentStartedSpeakingResponse(BaseResponse):
 94    """
 95    The server will send an AgentStartedSpeaking message when it begins streaming an agent audio response to the client for playback.
 96    """
 97
 98    total_latency: float
 99    tts_latency: float
100    ttt_latency: float

The server will send an AgentStartedSpeaking message when it begins streaming an agent audio response to the client for playback.

AgentStartedSpeakingResponse(total_latency: float, tts_latency: float, ttt_latency: float)
total_latency: float
tts_latency: float
ttt_latency: float
@dataclass
class AgentAudioDoneResponse(deepgram.clients.common.v1.shared_response.BaseResponse):
103@dataclass
104class AgentAudioDoneResponse(BaseResponse):
105    """
106    The server will send an AgentAudioDone message immediately after it sends the last audio message in a piece of agent speech.
107    """
108
109    type: str

The server will send an AgentAudioDone message immediately after it sends the last audio message in a piece of agent speech.

AgentAudioDoneResponse(type: str)
type: str
@dataclass
class InjectionRefusedResponse(deepgram.clients.common.v1.shared_response.BaseResponse):
112@dataclass
113class InjectionRefusedResponse(BaseResponse):
114    """
115    The server will send an InjectionRefused message when an InjectAgentMessage request is ignored because it arrived while the user was speaking or while the server was sending audio for an agent response.
116    """
117
118    type: str

The server will send an InjectionRefused message when an InjectAgentMessage request is ignored because it arrived while the user was speaking or while the server was sending audio for an agent response.

InjectionRefusedResponse(type: str)
type: str