Skip to content
Merged
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
4 changes: 2 additions & 2 deletions .fern/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
"skip_validation": true
}
},
"originGitCommit": "7d90d34144ca944bba2a570780fad2d53fdc5c4d",
"originGitCommitIsDirty": false,
"originGitCommit": "56f50652950bce4294c5388be6f25055749f55a7",
"originGitCommitIsDirty": true,
"invokedBy": "manual",
"sdkVersion": "7.16.0"
}
8 changes: 8 additions & 0 deletions .fernignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ src/deepgram/requests/shared_intents.py
src/deepgram/agent/v1/types/agent_v1conversation_text.py
src/deepgram/agent/v1/requests/agent_v1conversation_text.py

# Deepgram Think shares the title "Deepgram" with the Speak provider in the
# AsyncAPI overrides. Fern therefore emits the Speak model and its speed /
# expressivity controls here instead of the Think contract. Preserve the actual
# Think models and temperature / reasoning_mode / voice_prompt_opt_out fields.
# [temporarily frozen — remove after Fern disambiguates the provider titles]
src/deepgram/types/think_settings_v1provider.py
src/deepgram/requests/think_settings_v1provider.py

# WebSocket socket clients:
# - except Exception broad catch (supports custom transports, generator narrows to WebSocketException)
# - _sanitize_numeric_types in agent socket client (float→int for API)
Expand Down
63 changes: 63 additions & 0 deletions examples/34-voice-agent-deepgram-think.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
"""Configure a Voice Agent with a Deepgram-hosted Think model."""

import threading

from dotenv import load_dotenv

from deepgram import DeepgramClient
from deepgram.agent.v1.types import (
AgentV1Settings,
AgentV1SettingsAgent,
AgentV1SettingsAgentListen,
AgentV1SettingsAgentListenProvider_V2,
AgentV1SettingsAudio,
AgentV1SettingsAudioInput,
)
from deepgram.core.events import EventType
from deepgram.types.speak_settings_v1 import SpeakSettingsV1
from deepgram.types.speak_settings_v1provider import SpeakSettingsV1Provider_Deepgram
from deepgram.types.think_settings_v1 import ThinkSettingsV1
from deepgram.types.think_settings_v1provider import ThinkSettingsV1Provider_Deepgram

load_dotenv()
client = DeepgramClient()

settings = AgentV1Settings(
audio=AgentV1SettingsAudio(input=AgentV1SettingsAudioInput(encoding="linear16", sample_rate=24000)),
# think-fast requires Model Improvement Program participation.
# With mip_opt_out=True, use phonellm-mini-alpha-2-fp8 or the service returns INVALID_SETTINGS.
mip_opt_out=True,
agent=AgentV1SettingsAgent(
listen=AgentV1SettingsAgentListen(
provider=AgentV1SettingsAgentListenProvider_V2(type="deepgram", model="flux-general-en")
),
think=ThinkSettingsV1(
provider=ThinkSettingsV1Provider_Deepgram(
type="deepgram",
model="phonellm-mini-alpha-2-fp8",
temperature=0.2,
reasoning_mode="none",
),
prompt="You are helpful and concise.",
),
speak=SpeakSettingsV1(
provider=SpeakSettingsV1Provider_Deepgram(type="deepgram", model="aura-2-asteria-en")
),
),
)

with client.agent.v1.connect() as agent:
settings_applied = threading.Event()

def on_message(message: object) -> None:
message_type = getattr(message, "type", "Unknown")
print(f"Received {message_type}")
if message_type == "SettingsApplied":
settings_applied.set()

agent.on(EventType.MESSAGE, on_message)
threading.Thread(target=agent.start_listening, daemon=True).start()
agent.send_settings(settings)

if not settings_applied.wait(10):
raise TimeoutError("Timed out waiting for Deepgram Think settings to apply")
1 change: 1 addition & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ This directory contains comprehensive examples demonstrating how to use the Deep
- **31-voice-agent-session-recording.py** - Record selected Voice Agent events as JSON
- **32-voice-agent-force-end-turn.py** - End an active Voice Agent Flux turn with ForceEndTurn
- **33-voice-agent-think-live.py** - Configure Think Live, update it in-session, and observe dynamic Agent events
- **34-voice-agent-deepgram-think.py** - Configure Deepgram-hosted Think with an MIP-safe model

### 40-49: Text Intelligence (Read)

Expand Down
30 changes: 15 additions & 15 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions src/deepgram/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
DeepgramListenProviderV1,
DeepgramListenProviderV2,
DeepgramModel,
DeepgramReasoningMode,
DeepgramThinkLiveProviderV1,
DeleteAgentConfigurationV1Response,
DeleteAgentVariableV1Response,
Expand Down Expand Up @@ -242,6 +243,7 @@
ThinkSettingsV1Provider,
ThinkSettingsV1Provider_Anthropic,
ThinkSettingsV1Provider_AwsBedrock,
ThinkSettingsV1Provider_Deepgram,
ThinkSettingsV1Provider_Google,
ThinkSettingsV1Provider_Groq,
ThinkSettingsV1Provider_OpenAi,
Expand Down Expand Up @@ -418,6 +420,7 @@
ThinkSettingsV1ProviderParams,
ThinkSettingsV1Provider_AnthropicParams,
ThinkSettingsV1Provider_AwsBedrockParams,
ThinkSettingsV1Provider_DeepgramParams,
ThinkSettingsV1Provider_GoogleParams,
ThinkSettingsV1Provider_GroqParams,
ThinkSettingsV1Provider_OpenAiParams,
Expand Down Expand Up @@ -509,6 +512,7 @@
"DeepgramListenProviderV2Params": ".requests",
"DeepgramModel": ".types",
"DeepgramParams": ".requests",
"DeepgramReasoningMode": ".types",
"DeepgramThinkLiveProviderV1": ".types",
"DeepgramThinkLiveProviderV1Params": ".requests",
"DefaultAioHttpClient": "._default_clients",
Expand Down Expand Up @@ -831,6 +835,8 @@
"ThinkSettingsV1Provider_AnthropicParams": ".requests",
"ThinkSettingsV1Provider_AwsBedrock": ".types",
"ThinkSettingsV1Provider_AwsBedrockParams": ".requests",
"ThinkSettingsV1Provider_Deepgram": ".types",
"ThinkSettingsV1Provider_DeepgramParams": ".requests",
"ThinkSettingsV1Provider_Google": ".types",
"ThinkSettingsV1Provider_GoogleParams": ".requests",
"ThinkSettingsV1Provider_Groq": ".types",
Expand Down Expand Up @@ -997,6 +1003,7 @@ def __dir__():
"DeepgramListenProviderV2Params",
"DeepgramModel",
"DeepgramParams",
"DeepgramReasoningMode",
"DeepgramThinkLiveProviderV1",
"DeepgramThinkLiveProviderV1Params",
"DefaultAioHttpClient",
Expand Down Expand Up @@ -1319,6 +1326,8 @@ def __dir__():
"ThinkSettingsV1Provider_AnthropicParams",
"ThinkSettingsV1Provider_AwsBedrock",
"ThinkSettingsV1Provider_AwsBedrockParams",
"ThinkSettingsV1Provider_Deepgram",
"ThinkSettingsV1Provider_DeepgramParams",
"ThinkSettingsV1Provider_Google",
"ThinkSettingsV1Provider_GoogleParams",
"ThinkSettingsV1Provider_Groq",
Expand Down
3 changes: 3 additions & 0 deletions src/deepgram/requests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@
ThinkSettingsV1ProviderParams,
ThinkSettingsV1Provider_AnthropicParams,
ThinkSettingsV1Provider_AwsBedrockParams,
ThinkSettingsV1Provider_DeepgramParams,
ThinkSettingsV1Provider_GoogleParams,
ThinkSettingsV1Provider_GroqParams,
ThinkSettingsV1Provider_OpenAiParams,
Expand Down Expand Up @@ -370,6 +371,7 @@
"ThinkSettingsV1ProviderParams": ".think_settings_v1provider",
"ThinkSettingsV1Provider_AnthropicParams": ".think_settings_v1provider",
"ThinkSettingsV1Provider_AwsBedrockParams": ".think_settings_v1provider",
"ThinkSettingsV1Provider_DeepgramParams": ".think_settings_v1provider",
"ThinkSettingsV1Provider_GoogleParams": ".think_settings_v1provider",
"ThinkSettingsV1Provider_GroqParams": ".think_settings_v1provider",
"ThinkSettingsV1Provider_OpenAiParams": ".think_settings_v1provider",
Expand Down Expand Up @@ -579,6 +581,7 @@ def __dir__():
"ThinkSettingsV1ProviderParams",
"ThinkSettingsV1Provider_AnthropicParams",
"ThinkSettingsV1Provider_AwsBedrockParams",
"ThinkSettingsV1Provider_DeepgramParams",
"ThinkSettingsV1Provider_GoogleParams",
"ThinkSettingsV1Provider_GroqParams",
"ThinkSettingsV1Provider_OpenAiParams",
Expand Down
11 changes: 11 additions & 0 deletions src/deepgram/requests/think_settings_v1provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import typing_extensions
from ..types.anthropic_model import AnthropicModel
from ..types.aws_bedrock_think_provider_model import AwsBedrockThinkProviderModel
from ..types.deepgram_reasoning_mode import DeepgramReasoningMode
from ..types.google_model import GoogleModel
from ..types.google_version import GoogleVersion
from ..types.groq_reasoning_mode import GroqReasoningMode
Expand Down Expand Up @@ -52,10 +53,20 @@ class ThinkSettingsV1Provider_GroqParams(typing_extensions.TypedDict):
reasoning_mode: typing_extensions.NotRequired[GroqReasoningMode]


class ThinkSettingsV1Provider_DeepgramParams(typing_extensions.TypedDict):
type: typing.Literal["deepgram"]
version: typing_extensions.NotRequired[typing.Literal["v1"]]
model: typing.Union[typing.Literal["think-fast", "phonellm-mini-alpha-2-fp8"], typing.Any]
temperature: typing_extensions.NotRequired[float]
reasoning_mode: typing_extensions.NotRequired[DeepgramReasoningMode]
voice_prompt_opt_out: typing_extensions.NotRequired[bool]


ThinkSettingsV1ProviderParams = typing.Union[
ThinkSettingsV1Provider_OpenAiParams,
ThinkSettingsV1Provider_AwsBedrockParams,
ThinkSettingsV1Provider_AnthropicParams,
ThinkSettingsV1Provider_GoogleParams,
ThinkSettingsV1Provider_GroqParams,
ThinkSettingsV1Provider_DeepgramParams,
]
6 changes: 6 additions & 0 deletions src/deepgram/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
from .deepgram_listen_provider_v1 import DeepgramListenProviderV1
from .deepgram_listen_provider_v2 import DeepgramListenProviderV2
from .deepgram_model import DeepgramModel
from .deepgram_reasoning_mode import DeepgramReasoningMode
from .deepgram_think_live_provider_v1 import DeepgramThinkLiveProviderV1
from .delete_agent_configuration_v1response import DeleteAgentConfigurationV1Response
from .delete_agent_variable_v1response import DeleteAgentVariableV1Response
Expand Down Expand Up @@ -276,6 +277,7 @@
ThinkSettingsV1Provider,
ThinkSettingsV1Provider_Anthropic,
ThinkSettingsV1Provider_AwsBedrock,
ThinkSettingsV1Provider_Deepgram,
ThinkSettingsV1Provider_Google,
ThinkSettingsV1Provider_Groq,
ThinkSettingsV1Provider_OpenAi,
Expand Down Expand Up @@ -332,6 +334,7 @@
"DeepgramListenProviderV1": ".deepgram_listen_provider_v1",
"DeepgramListenProviderV2": ".deepgram_listen_provider_v2",
"DeepgramModel": ".deepgram_model",
"DeepgramReasoningMode": ".deepgram_reasoning_mode",
"DeepgramThinkLiveProviderV1": ".deepgram_think_live_provider_v1",
"DeleteAgentConfigurationV1Response": ".delete_agent_configuration_v1response",
"DeleteAgentVariableV1Response": ".delete_agent_variable_v1response",
Expand Down Expand Up @@ -526,6 +529,7 @@
"ThinkSettingsV1Provider": ".think_settings_v1provider",
"ThinkSettingsV1Provider_Anthropic": ".think_settings_v1provider",
"ThinkSettingsV1Provider_AwsBedrock": ".think_settings_v1provider",
"ThinkSettingsV1Provider_Deepgram": ".think_settings_v1provider",
"ThinkSettingsV1Provider_Google": ".think_settings_v1provider",
"ThinkSettingsV1Provider_Groq": ".think_settings_v1provider",
"ThinkSettingsV1Provider_OpenAi": ".think_settings_v1provider",
Expand Down Expand Up @@ -626,6 +630,7 @@ def __dir__():
"DeepgramListenProviderV1",
"DeepgramListenProviderV2",
"DeepgramModel",
"DeepgramReasoningMode",
"DeepgramThinkLiveProviderV1",
"DeleteAgentConfigurationV1Response",
"DeleteAgentVariableV1Response",
Expand Down Expand Up @@ -820,6 +825,7 @@ def __dir__():
"ThinkSettingsV1Provider",
"ThinkSettingsV1Provider_Anthropic",
"ThinkSettingsV1Provider_AwsBedrock",
"ThinkSettingsV1Provider_Deepgram",
"ThinkSettingsV1Provider_Google",
"ThinkSettingsV1Provider_Groq",
"ThinkSettingsV1Provider_OpenAi",
Expand Down
5 changes: 5 additions & 0 deletions src/deepgram/types/deepgram_reasoning_mode.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# This file was auto-generated by Fern from our API Definition.

import typing

DeepgramReasoningMode = typing.Union[typing.Literal["none", "minimal", "low", "medium", "high"], typing.Any]
20 changes: 20 additions & 0 deletions src/deepgram/types/think_settings_v1provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from .anthropic_model import AnthropicModel
from .aws_bedrock_think_provider_credentials import AwsBedrockThinkProviderCredentials
from .aws_bedrock_think_provider_model import AwsBedrockThinkProviderModel
from .deepgram_reasoning_mode import DeepgramReasoningMode
from .google_model import GoogleModel
from .google_version import GoogleVersion
from .groq_reasoning_mode import GroqReasoningMode
Expand Down Expand Up @@ -100,13 +101,32 @@ class Config:
extra = pydantic.Extra.allow


class ThinkSettingsV1Provider_Deepgram(UncheckedBaseModel):
type: typing.Literal["deepgram"] = "deepgram"
version: typing.Optional[typing.Literal["v1"]] = None
model: typing.Union[typing.Literal["think-fast", "phonellm-mini-alpha-2-fp8"], typing.Any]
temperature: typing.Optional[float] = None
reasoning_mode: typing.Optional[DeepgramReasoningMode] = None
voice_prompt_opt_out: typing.Optional[bool] = None

if IS_PYDANTIC_V2:
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
else:

class Config:
frozen = True
smart_union = True
extra = pydantic.Extra.allow


ThinkSettingsV1Provider = typing_extensions.Annotated[
typing.Union[
ThinkSettingsV1Provider_OpenAi,
ThinkSettingsV1Provider_AwsBedrock,
ThinkSettingsV1Provider_Anthropic,
ThinkSettingsV1Provider_Google,
ThinkSettingsV1Provider_Groq,
ThinkSettingsV1Provider_Deepgram,
],
UnionMetadata(discriminant="type"),
]
Loading
Loading