Skip to content

fixes agent language property #534

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 10 additions & 13 deletions deepgram/clients/agent/v1/websocket/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,13 @@ def __getitem__(self, key):
_dict["voice"] = CartesiaVoice.from_dict(_dict["voice"])
return _dict[key]

@dataclass
class Language(BaseResponse):
"""
Define the language for the agent.
"""

type: str = field(default="en")

@dataclass
class Think(BaseResponse):
Expand Down Expand Up @@ -284,6 +291,7 @@ class Agent(BaseResponse):
This class defines any configuration settings for the Agent model.
"""

language: str = field(default="en")
listen: Listen = field(default_factory=Listen)
think: Think = field(default_factory=Think)
speak: Speak = field(default_factory=Speak)
Expand All @@ -293,15 +301,15 @@ class Agent(BaseResponse):

def __getitem__(self, key):
_dict = self.to_dict()
if "language" in _dict and isinstance(_dict["language"], dict):
_dict["language"] = Language.from_dict(_dict["language"])
if "listen" in _dict and isinstance(_dict["listen"], dict):
_dict["listen"] = Listen.from_dict(_dict["listen"])
if "think" in _dict and isinstance(_dict["think"], dict):
_dict["think"] = Think.from_dict(_dict["think"])
if "speak" in _dict and isinstance(_dict["speak"], dict):
_dict["speak"] = Speak.from_dict(_dict["speak"])
return _dict[key]


@dataclass
class Input(BaseResponse):
"""
Expand Down Expand Up @@ -343,16 +351,6 @@ def __getitem__(self, key):
_dict["output"] = Output.from_dict(_dict["output"])
return _dict[key]


@dataclass
class Language(BaseResponse):
"""
Define the language for the agent.
"""

type: str = field(default="en")


@dataclass
class SettingsOptions(BaseResponse):
"""
Expand All @@ -370,7 +368,6 @@ def __getitem__(self, key):
_dict["audio"] = Audio.from_dict(_dict["audio"])
if "agent" in _dict and isinstance(_dict["agent"], dict):
_dict["agent"] = Agent.from_dict(_dict["agent"])
return _dict[key]

def check(self):
"""
Expand Down
2 changes: 1 addition & 1 deletion examples/agent/async_simple/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ async def on_unhandled(self, unhandled, **kwargs):
options.agent.listen.provider.keyterms = ["hello", "goodbye"]
options.agent.listen.provider.model = "nova-3"
options.agent.listen.provider.type = "deepgram"
options.language = "en"
options.agent.language = "en"


print("\n\nPress Enter to stop...\n\n")
Expand Down
4 changes: 2 additions & 2 deletions examples/agent/no_mic/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ def main():
# Agent configuration
options.agent.language = "en"
options.agent.listen.provider.type = "deepgram"
options.agent.listen.model = "nova-3"
options.agent.listen.provider.model = "nova-3"
options.agent.think.provider.type = "open_ai"
options.agent.think.model = "gpt-4o-mini"
options.agent.think.provider.model = "gpt-4o-mini"
options.agent.think.prompt = "You are a friendly AI assistant."
options.agent.speak.provider.type = "deepgram"
options.agent.speak.model = "aura-2-thalia-en"
Expand Down
2 changes: 1 addition & 1 deletion examples/agent/simple/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def on_unhandled(self, unhandled, **kwargs):
options.agent.listen.provider.keyterms = ["hello", "goodbye"]
options.agent.listen.provider.model = "nova-3"
options.agent.listen.provider.type = "deepgram"
options.language = "en"
options.agent.language = "en"
if dg_connection.start(options) is False:
print("Failed to start connection")
return
Expand Down