deepgram.clients.common.v1.rest_response

  1# Copyright 2024 Deepgram SDK contributors. All Rights Reserved.
  2# Use of this source code is governed by a MIT license that can be found in the LICENSE file.
  3# SPDX-License-Identifier: MIT
  4
  5from typing import List, Optional, Dict, Any
  6
  7from dataclasses import dataclass, field
  8from dataclasses_json import config as dataclass_config
  9
 10from .enums import Sentiment
 11from .shared_response import BaseResponse
 12
 13
 14# Analyze Response Types:
 15
 16
 17@dataclass
 18class IntentsInfo(BaseResponse):
 19    """
 20    Intents Info
 21    """
 22
 23    model_uuid: str = ""
 24    input_tokens: int = 0
 25    output_tokens: int = 0
 26
 27
 28@dataclass
 29class SentimentInfo(BaseResponse):
 30    """
 31    Sentiment Info
 32    """
 33
 34    model_uuid: str = ""
 35    input_tokens: int = 0
 36    output_tokens: int = 0
 37
 38
 39@dataclass
 40class SummaryInfo(BaseResponse):
 41    """
 42    Summary Info
 43    """
 44
 45    model_uuid: str = ""
 46    input_tokens: int = 0
 47    output_tokens: int = 0
 48
 49
 50@dataclass
 51class TopicsInfo(BaseResponse):
 52    """
 53    Topics Info
 54    """
 55
 56    model_uuid: str = ""
 57    input_tokens: int = 0
 58    output_tokens: int = 0
 59
 60
 61@dataclass
 62class Average(BaseResponse):
 63    """
 64    Average
 65    """
 66
 67    sentiment: Sentiment
 68    sentiment_score: float = 0
 69
 70    def __getitem__(self, key):
 71        _dict = self.to_dict()
 72        if "sentiment" in _dict:
 73            _dict["sentiment"] = Sentiment.from_dict(_dict["sentiment"])
 74        return _dict[key]
 75
 76
 77@dataclass
 78class Topic(BaseResponse):
 79    """
 80    Topic
 81    """
 82
 83    topic: str = ""
 84    confidence_score: float = 0
 85
 86
 87@dataclass
 88class Intent(BaseResponse):
 89    """
 90    Intent
 91    """
 92
 93    intent: str = ""
 94    confidence_score: float = 0
 95
 96
 97@dataclass
 98class Segment(BaseResponse):
 99    """
100    Segment
101    """
102
103    text: str = ""
104    start_word: int = 0
105    end_word: int = 0
106    sentiment: Optional[Sentiment] = field(
107        default=None, metadata=dataclass_config(exclude=lambda f: f is None)
108    )
109    sentiment_score: Optional[float] = field(
110        default=None, metadata=dataclass_config(exclude=lambda f: f is None)
111    )
112    intents: Optional[List[Intent]] = field(
113        default=None, metadata=dataclass_config(exclude=lambda f: f is None)
114    )
115    topics: Optional[List[Topic]] = field(
116        default=None, metadata=dataclass_config(exclude=lambda f: f is None)
117    )
118
119    def __getitem__(self, key):
120        _dict = self.to_dict()
121        if "sentiment" in _dict:
122            _dict["sentiment"] = Sentiment.from_dict(_dict["sentiment"])
123        if "intents" in _dict:
124            _dict["intents"] = Intent.from_dict(_dict["intents"])
125        if "topics" in _dict:
126            _dict["topics"] = Topic.from_dict(_dict["topics"])
127        return _dict[key]
128
129
130@dataclass
131class Sentiments(BaseResponse):
132    """
133    Sentiments
134    """
135
136    average: Average
137    segments: List[Segment] = field(default_factory=list)
138
139    def __getitem__(self, key):
140        _dict = self.to_dict()
141        if "segments" in _dict:
142            _dict["segments"] = [
143                Segment.from_dict(segments) for segments in _dict["segments"]
144            ]
145        if "average" in _dict:
146            _dict["average"] = Average.from_dict(_dict["average"])
147        return _dict[key]
148
149
150@dataclass
151class Topics(BaseResponse):
152    """
153    Topics
154    """
155
156    segments: List[Segment] = field(default_factory=list)
157
158    def __getitem__(self, key):
159        _dict = self.to_dict()
160        if "segments" in _dict:
161            _dict["segments"] = [
162                Segment.from_dict(segments) for segments in _dict["segments"]
163            ]
164        return _dict[key]
165
166
167@dataclass
168class Intents(BaseResponse):
169    """
170    Intents
171    """
172
173    segments: List[Segment] = field(default_factory=list)
174
175    def __getitem__(self, key):
176        _dict = self.to_dict()
177        if "segments" in _dict:
178            _dict["segments"] = [
179                Segment.from_dict(segments) for segments in _dict["segments"]
180            ]
181        return _dict[key]
@dataclass
class IntentsInfo(deepgram.clients.common.v1.shared_response.BaseResponse):
18@dataclass
19class IntentsInfo(BaseResponse):
20    """
21    Intents Info
22    """
23
24    model_uuid: str = ""
25    input_tokens: int = 0
26    output_tokens: int = 0

Intents Info

IntentsInfo(model_uuid: str = '', input_tokens: int = 0, output_tokens: int = 0)
model_uuid: str = ''
input_tokens: int = 0
output_tokens: int = 0
@dataclass
class SentimentInfo(deepgram.clients.common.v1.shared_response.BaseResponse):
29@dataclass
30class SentimentInfo(BaseResponse):
31    """
32    Sentiment Info
33    """
34
35    model_uuid: str = ""
36    input_tokens: int = 0
37    output_tokens: int = 0

Sentiment Info

SentimentInfo(model_uuid: str = '', input_tokens: int = 0, output_tokens: int = 0)
model_uuid: str = ''
input_tokens: int = 0
output_tokens: int = 0
@dataclass
class SummaryInfo(deepgram.clients.common.v1.shared_response.BaseResponse):
40@dataclass
41class SummaryInfo(BaseResponse):
42    """
43    Summary Info
44    """
45
46    model_uuid: str = ""
47    input_tokens: int = 0
48    output_tokens: int = 0

Summary Info

SummaryInfo(model_uuid: str = '', input_tokens: int = 0, output_tokens: int = 0)
model_uuid: str = ''
input_tokens: int = 0
output_tokens: int = 0
@dataclass
class TopicsInfo(deepgram.clients.common.v1.shared_response.BaseResponse):
51@dataclass
52class TopicsInfo(BaseResponse):
53    """
54    Topics Info
55    """
56
57    model_uuid: str = ""
58    input_tokens: int = 0
59    output_tokens: int = 0

Topics Info

TopicsInfo(model_uuid: str = '', input_tokens: int = 0, output_tokens: int = 0)
model_uuid: str = ''
input_tokens: int = 0
output_tokens: int = 0
@dataclass
class Average(deepgram.clients.common.v1.shared_response.BaseResponse):
62@dataclass
63class Average(BaseResponse):
64    """
65    Average
66    """
67
68    sentiment: Sentiment
69    sentiment_score: float = 0
70
71    def __getitem__(self, key):
72        _dict = self.to_dict()
73        if "sentiment" in _dict:
74            _dict["sentiment"] = Sentiment.from_dict(_dict["sentiment"])
75        return _dict[key]

Average

Average( sentiment: deepgram.clients.common.Sentiment, sentiment_score: float = 0)
sentiment_score: float = 0
@dataclass
class Topic(deepgram.clients.common.v1.shared_response.BaseResponse):
78@dataclass
79class Topic(BaseResponse):
80    """
81    Topic
82    """
83
84    topic: str = ""
85    confidence_score: float = 0

Topic

Topic(topic: str = '', confidence_score: float = 0)
topic: str = ''
confidence_score: float = 0
@dataclass
class Intent(deepgram.clients.common.v1.shared_response.BaseResponse):
88@dataclass
89class Intent(BaseResponse):
90    """
91    Intent
92    """
93
94    intent: str = ""
95    confidence_score: float = 0

Intent

Intent(intent: str = '', confidence_score: float = 0)
intent: str = ''
confidence_score: float = 0
@dataclass
class Segment(deepgram.clients.common.v1.shared_response.BaseResponse):
 98@dataclass
 99class Segment(BaseResponse):
100    """
101    Segment
102    """
103
104    text: str = ""
105    start_word: int = 0
106    end_word: int = 0
107    sentiment: Optional[Sentiment] = field(
108        default=None, metadata=dataclass_config(exclude=lambda f: f is None)
109    )
110    sentiment_score: Optional[float] = field(
111        default=None, metadata=dataclass_config(exclude=lambda f: f is None)
112    )
113    intents: Optional[List[Intent]] = field(
114        default=None, metadata=dataclass_config(exclude=lambda f: f is None)
115    )
116    topics: Optional[List[Topic]] = field(
117        default=None, metadata=dataclass_config(exclude=lambda f: f is None)
118    )
119
120    def __getitem__(self, key):
121        _dict = self.to_dict()
122        if "sentiment" in _dict:
123            _dict["sentiment"] = Sentiment.from_dict(_dict["sentiment"])
124        if "intents" in _dict:
125            _dict["intents"] = Intent.from_dict(_dict["intents"])
126        if "topics" in _dict:
127            _dict["topics"] = Topic.from_dict(_dict["topics"])
128        return _dict[key]

Segment

Segment( text: str = '', start_word: int = 0, end_word: int = 0, sentiment: Optional[deepgram.clients.common.Sentiment] = None, sentiment_score: Optional[float] = None, intents: Optional[List[Intent]] = None, topics: Optional[List[Topic]] = None)
text: str = ''
start_word: int = 0
end_word: int = 0
sentiment: Optional[deepgram.clients.common.Sentiment] = None
sentiment_score: Optional[float] = None
intents: Optional[List[Intent]] = None
topics: Optional[List[Topic]] = None
@dataclass
class Sentiments(deepgram.clients.common.v1.shared_response.BaseResponse):
131@dataclass
132class Sentiments(BaseResponse):
133    """
134    Sentiments
135    """
136
137    average: Average
138    segments: List[Segment] = field(default_factory=list)
139
140    def __getitem__(self, key):
141        _dict = self.to_dict()
142        if "segments" in _dict:
143            _dict["segments"] = [
144                Segment.from_dict(segments) for segments in _dict["segments"]
145            ]
146        if "average" in _dict:
147            _dict["average"] = Average.from_dict(_dict["average"])
148        return _dict[key]

Sentiments

Sentiments( average: Average, segments: List[Segment] = <factory>)
average: Average
segments: List[Segment]
@dataclass
class Topics(deepgram.clients.common.v1.shared_response.BaseResponse):
151@dataclass
152class Topics(BaseResponse):
153    """
154    Topics
155    """
156
157    segments: List[Segment] = field(default_factory=list)
158
159    def __getitem__(self, key):
160        _dict = self.to_dict()
161        if "segments" in _dict:
162            _dict["segments"] = [
163                Segment.from_dict(segments) for segments in _dict["segments"]
164            ]
165        return _dict[key]

Topics

Topics( segments: List[Segment] = <factory>)
segments: List[Segment]
@dataclass
class Intents(deepgram.clients.common.v1.shared_response.BaseResponse):
168@dataclass
169class Intents(BaseResponse):
170    """
171    Intents
172    """
173
174    segments: List[Segment] = field(default_factory=list)
175
176    def __getitem__(self, key):
177        _dict = self.to_dict()
178        if "segments" in _dict:
179            _dict["segments"] = [
180                Segment.from_dict(segments) for segments in _dict["segments"]
181            ]
182        return _dict[key]

Intents

Intents( segments: List[Segment] = <factory>)
segments: List[Segment]