Skip to content

Commit

Permalink
resolved code review
Browse files Browse the repository at this point in the history
  • Loading branch information
jpvajda committed Jan 30, 2025
1 parent c64c37d commit 3cbbd82
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 9 deletions.
1 change: 0 additions & 1 deletion deepgram/clients/agent/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class AgentWebSocketEvents(StrEnum):
FunctionCallRequest: str = "FunctionCallRequest"
AgentStartedSpeaking: str = "AgentStartedSpeaking"
AgentAudioDone: str = "AgentAudioDone"
EndOfThought: str = "EndOfThought"
Error: str = "Error"
Unhandled: str = "Unhandled"

Expand Down
12 changes: 12 additions & 0 deletions deepgram/clients/agent/v1/websocket/async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,18 @@ async def _process_text(self, message: str) -> None:
function_calling=function_calling_result,
**dict(cast(Dict[Any, Any], self._kwargs)),
)
case AgentWebSocketEvents.FunctionCallRequest:
function_call_request_result: FunctionCallRequest = (
FunctionCallRequest.from_json(message)
)
self._logger.verbose(
"FunctionCallRequest: %s", function_call_request_result
)
await self._emit(
AgentWebSocketEvents(AgentWebSocketEvents.FunctionCallRequest),
function_call_request=function_call_request_result,
**dict(cast(Dict[Any, Any], self._kwargs)),
)
case AgentWebSocketEvents.AgentStartedSpeaking:
agent_started_speaking_result: AgentStartedSpeakingResponse = (
AgentStartedSpeakingResponse.from_json(message)
Expand Down
8 changes: 8 additions & 0 deletions deepgram/clients/agent/v1/websocket/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,14 @@ def _process_text(self, message: str) -> None:
function_calling=function_calling_result,
**dict(cast(Dict[Any, Any], self._kwargs)),
)
case AgentWebSocketEvents.FunctionCallRequest:
function_call_request_result: FunctionCallRequest = FunctionCallRequest.from_json(message)
self._logger.verbose("FunctionCallRequest: %s", function_call_request_result)
self._emit(
AgentWebSocketEvents(AgentWebSocketEvents.FunctionCallRequest),
function_call_request=function_call_request_result,
**dict(cast(Dict[Any, Any], self._kwargs)),
)
case AgentWebSocketEvents.AgentStartedSpeaking:
agent_started_speaking_result: AgentStartedSpeakingResponse = (
AgentStartedSpeakingResponse.from_json(message)
Expand Down
4 changes: 0 additions & 4 deletions examples/agent/async_simple/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,6 @@ async def on_agent_started_speaking(self, agent_started_speaking, **kwargs):
async def on_agent_audio_done(self, agent_audio_done, **kwargs):
print(f"\n\n{agent_audio_done}\n\n")

async def on_end_of_thought(self, end_of_thought, **kwargs):
print(f"\n\n{end_of_thought}\n\n")

async def on_close(self, close, **kwargs):
print(f"\n\n{close}\n\n")

Expand All @@ -108,7 +105,6 @@ async def on_unhandled(self, unhandled, **kwargs):
AgentWebSocketEvents.AgentStartedSpeaking, on_agent_started_speaking
)
dg_connection.on(AgentWebSocketEvents.AgentAudioDone, on_agent_audio_done)
dg_connection.on(AgentWebSocketEvents.EndOfThought, on_end_of_thought)
dg_connection.on(AgentWebSocketEvents.Close, on_close)
dg_connection.on(AgentWebSocketEvents.Error, on_error)
dg_connection.on(AgentWebSocketEvents.Unhandled, on_unhandled)
Expand Down
4 changes: 0 additions & 4 deletions examples/agent/simple/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,6 @@ def on_agent_started_speaking(self, agent_started_speaking, **kwargs):
def on_agent_audio_done(self, agent_audio_done, **kwargs):
print(f"\n\n{agent_audio_done}\n\n")

def on_end_of_thought(self, end_of_thought, **kwargs):
print(f"\n\n{end_of_thought}\n\n")

def on_close(self, close, **kwargs):
print(f"\n\n{close}\n\n")

Expand All @@ -129,7 +126,6 @@ def on_unhandled(self, unhandled, **kwargs):
AgentWebSocketEvents.AgentStartedSpeaking, on_agent_started_speaking
)
dg_connection.on(AgentWebSocketEvents.AgentAudioDone, on_agent_audio_done)
dg_connection.on(AgentWebSocketEvents.EndOfThought, on_end_of_thought)
dg_connection.on(AgentWebSocketEvents.Close, on_close)
dg_connection.on(AgentWebSocketEvents.Error, on_error)
dg_connection.on(AgentWebSocketEvents.Unhandled, on_unhandled)
Expand Down

0 comments on commit 3cbbd82

Please sign in to comment.