- Python
- TypeScript
Rarely needed. This callback fires for every utterance spoken by the agent. Most implementations will not need it and should instead rely on higher-level callbacks like
on_question or on_task_complete. It is most useful for implementing call surveillance or real-time transcription logging.AgentSpeechEvent is a pydantic model imported from guava.events:from guava.events import AgentSpeechEvent
class AgentSpeechEvent(BaseEvent):
event_type: Literal["agent-speech"] = "agent-speech"
utterance: str
interrupted: bool = False
Rarely needed. This callback fires for every utterance spoken by the agent. Most implementations will not need it and should instead rely on higher-level callbacks like
onQuestion or onTaskComplete. It is most useful for implementing call surveillance or real-time transcription logging.AgentSpeechEvent has the following shape:type AgentSpeechEvent = {
event_type: "agent-speech";
utterance: string;
interrupted: boolean; // default: false
};
Signature
- Python
- TypeScript
signature
@agent.on_agent_speech
def on_agent_speech(call: guava.Call, event: AgentSpeechEvent) -> None:
...
| Parameter | Type | Description |
|---|---|---|
call | Call | The active call object. |
event | AgentSpeechEvent | Contains utterance (string) and interrupted (boolean) fields. |
Nonesignature
agent.onAgentSpeech((call: guava.Call, event: AgentSpeechEvent) => void);
| Parameter | Type | Description |
|---|---|---|
call | Call | The active call object. |
event | AgentSpeechEvent | Contains utterance (string) and interrupted (boolean) fields. |
voidExample
- Python
- TypeScript
controller.py
import logging
from guava.events import AgentSpeechEvent
logger = logging.getLogger(__name__)
@agent.on_agent_speech
def on_agent_speech(call: guava.Call, event: AgentSpeechEvent):
logger.info("agent speech event: %s", event)
# Output:
# [INFO 15:02:29] agent speech event: sequence=None event_type='agent-speech'
# utterance='Hi, thank you for calling Thai Palace. My name is Grace.
# I can help you with the waitlist. ' interrupted=False
controller.ts
import * as guava from "@guava-ai/guava-sdk";
import { AgentSpeechEvent } from "@guava-ai/guava-sdk/events";
agent.onAgentSpeech((_call: guava.Call, event: AgentSpeechEvent) => {
console.log("agent speech event:", JSON.stringify(event));
});