Skip to content

Commit cec45ce

Browse files
Merge pull request #259 from UniversalDevGenius/issue-170
modified ` response.py ` to add support for tokens issue #170
2 parents 0b263a8 + c152b93 commit cec45ce

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

deepgram/clients/manage/v1/response.py

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,13 @@ class Config:
181181
punctuate: Optional[bool] = False
182182
utterances: Optional[bool] = False
183183
diarize: Optional[bool] = False
184+
smart_format: Optional[bool] = False
185+
interim_results: Optional[bool] = False
184186

185187
def __getitem__(self, key):
186188
_dict = self.to_dict()
187189
return _dict[key]
188190

189-
190191
@dataclass_json
191192
@dataclass
192193
class Details:
@@ -200,6 +201,8 @@ class Details:
200201
tags: Optional[List[str]] = None
201202
features: Optional[List[str]] = None
202203
config: Optional[Config] = None
204+
tier: Optional[str] = ""
205+
203206

204207
def __getitem__(self, key):
205208
_dict = self.to_dict()
@@ -225,24 +228,41 @@ def __getitem__(self, key):
225228
_dict = self.to_dict()
226229
return _dict[key]
227230

231+
@dataclass_json
232+
@dataclass
233+
class TokenDetail:
234+
feature: Optional[str] = ""
235+
input: Optional[int] = 0
236+
model: Optional[str] = ""
237+
output: Optional[int] = 0
228238

239+
def __getitem__(self, key):
240+
_dict = self.to_dict()
241+
return _dict[key]
242+
229243
@dataclass_json
230244
@dataclass
231245
class Response:
232246
code: Optional[int] = 0
233247
completed: Optional[str] = ""
234248
details: Optional[Details] = None
249+
token_details: Optional[List[TokenDetail]] = None
235250

236251
def __getitem__(self, key):
237252
_dict = self.to_dict()
238253
if _dict["details"] is not None:
239254
_dict["details"] = Details.from_dict(_dict["details"])
255+
if _dict["token_details"] is not None:
256+
_dict["token_details"] = [
257+
TokenDetail.from_dict(token_details) for _, token_details in _dict["token_details"].items()
258+
]
240259
return _dict[key]
241260

242261

243262
@dataclass_json
244263
@dataclass
245264
class UsageRequest:
265+
project_uuid: Optional[str] = ""
246266
request_id: Optional[str] = ""
247267
created: Optional[str] = ""
248268
path: Optional[str] = ""
@@ -276,6 +296,13 @@ def __getitem__(self, key):
276296
]
277297
return _dict[key]
278298

299+
class Tokens:
300+
tokens_in: Optional[int] = 0
301+
out: Optional[int] = 0
302+
303+
def __getitem__(self, key):
304+
_dict = self.to_dict()
305+
return _dict[key]
279306

280307
@dataclass_json
281308
@dataclass
@@ -285,9 +312,14 @@ class Results:
285312
hours: Optional[int] = 0
286313
total_hours: Optional[int] = 0
287314
requests: Optional[int] = 0
315+
tokens: Optional[Tokens] = None
288316

289317
def __getitem__(self, key):
290318
_dict = self.to_dict()
319+
if _dict["tokens"] is not None:
320+
_dict["tokens"] = [
321+
Tokens.from_dict(tokens) for _, tokens in _dict["tokens"].items()
322+
]
291323
return _dict[key]
292324

293325

0 commit comments

Comments
 (0)