open source
This commit is contained in:
parent
70b6e17c69
commit
a93bfc1ec9
61 changed files with 4013 additions and 126 deletions
|
|
@ -0,0 +1,45 @@
|
|||
from typing import Optional, Union
|
||||
from vocode.streaming.models.telephony import TwilioConfig
|
||||
from vocode.streaming.telephony.hosted.inbound_call_server import InboundCallServer
|
||||
from vocode.streaming.models.agent import (
|
||||
RESTfulAgentEnd,
|
||||
RESTfulAgentInput,
|
||||
RESTfulAgentText,
|
||||
RESTfulUserImplementedAgentConfig,
|
||||
)
|
||||
from vocode.streaming.models.transcriber import (
|
||||
TranscriberConfig,
|
||||
)
|
||||
from vocode.streaming.models.synthesizer import SynthesizerConfig
|
||||
|
||||
|
||||
class InboundCallUserAgentServer(InboundCallServer):
|
||||
def __init__(
|
||||
self,
|
||||
agent_config: RESTfulUserImplementedAgentConfig,
|
||||
transcriber_config: Optional[TranscriberConfig] = None,
|
||||
synthesizer_config: Optional[SynthesizerConfig] = None,
|
||||
response_on_rate_limit: Optional[str] = None,
|
||||
twilio_config: Optional[TwilioConfig] = None,
|
||||
):
|
||||
super().__init__(
|
||||
agent_config=agent_config,
|
||||
transcriber_config=transcriber_config,
|
||||
synthesizer_config=synthesizer_config,
|
||||
response_on_rate_limit=response_on_rate_limit,
|
||||
twilio_config=twilio_config,
|
||||
)
|
||||
assert isinstance(
|
||||
agent_config, RESTfulUserImplementedAgentConfig
|
||||
), "agent_config must be a RESTfulUserImplementedAgentConfig"
|
||||
self.app.post("/respond")(self.respond_rest)
|
||||
|
||||
async def respond(
|
||||
self, human_input, conversation_id
|
||||
) -> Union[RESTfulAgentText, RESTfulAgentEnd]:
|
||||
raise NotImplementedError
|
||||
|
||||
async def respond_rest(
|
||||
self, request: RESTfulAgentInput
|
||||
) -> Union[RESTfulAgentText, RESTfulAgentEnd]:
|
||||
return await self.respond(request.human_input, request.conversation_id)
|
||||
Loading…
Add table
Add a link
Reference in a new issue