-
Notifications
You must be signed in to change notification settings - Fork 122
Description
Summary
Add fully typed, documented response models for Audio Intelligence features (topics, intents, sentiment, summaries) that provide IDE autocompletion and type safety when accessing intelligence results from transcription responses.
Problem it solves
When developers use Audio Intelligence features (topics, intents, sentiment) in the Python SDK, the response data is returned as loosely-typed dictionaries or generic objects. This means no IDE autocompletion, no type checking, and developers must constantly reference the API docs to know what fields are available. For example, accessing topic results requires knowing the exact nested structure (response.results.topics.segments[0].topics[0].topic) without any IDE guidance. Typed models would make Audio Intelligence features significantly easier to discover and use correctly.
Proposed API
from deepgram import DeepgramClient, PrerecordedOptions
client = DeepgramClient()
response = await client.listen.rest.v("1").transcribe_url(
{"url": audio_url},
PrerecordedOptions(topics=True, intents=True, sentiment=True)
)
# Fully typed access with IDE autocompletion
for segment in response.results.topics.segments:
for topic in segment.topics:
print(f"Topic: {topic.topic} (confidence: {topic.confidence_score})")
for segment in response.results.intents.segments:
for intent in segment.intents:
print(f"Intent: {intent.intent} (confidence: {intent.confidence_score})")
for segment in response.results.sentiments.segments:
print(f"Sentiment: {segment.sentiment} ({segment.sentiment_score})")
# Type hints work for all nested fields
topic: TopicResult # has .topic: str, .confidence_score: float
intent: IntentResult # has .intent: str, .confidence_score: float
sentiment: SentimentSegment # has .sentiment: str, .sentiment_score: float, .text: strAcceptance criteria
- Typed models for Topics, Intents, Sentiment, and Summary response data
- IDE autocompletion works for all Intelligence result fields
- Documented with usage example showing typed access patterns
- Compatible with existing API (no breaking changes)
- Includes type stubs or inline type hints for mypy/pyright compatibility
Raised by the DX intelligence system.