@@ -114,23 +114,13 @@ def create_workspace(self,
114114 :rtype: dict
115115 """
116116 if intents is not None :
117- intents = [
118- x ._to_dict () if hasattr (x , "_to_dict" ) else x for x in intents
119- ]
117+ intents = [self ._convert_model (x ) for x in intents ]
120118 if entities is not None :
121- entities = [
122- x ._to_dict () if hasattr (x , "_to_dict" ) else x for x in entities
123- ]
119+ entities = [self ._convert_model (x ) for x in entities ]
124120 if dialog_nodes is not None :
125- dialog_nodes = [
126- x ._to_dict () if hasattr (x , "_to_dict" ) else x
127- for x in dialog_nodes
128- ]
121+ dialog_nodes = [self ._convert_model (x ) for x in dialog_nodes ]
129122 if counterexamples is not None :
130- counterexamples = [
131- x ._to_dict () if hasattr (x , "_to_dict" ) else x
132- for x in counterexamples
133- ]
123+ counterexamples = [self ._convert_model (x ) for x in counterexamples ]
134124 params = {'version' : self .version }
135125 data = {
136126 'name' : name ,
@@ -252,23 +242,13 @@ def update_workspace(self,
252242 if workspace_id is None :
253243 raise ValueError ('workspace_id must be provided' )
254244 if intents is not None :
255- intents = [
256- x ._to_dict () if hasattr (x , "_to_dict" ) else x for x in intents
257- ]
245+ intents = [self ._convert_model (x ) for x in intents ]
258246 if entities is not None :
259- entities = [
260- x ._to_dict () if hasattr (x , "_to_dict" ) else x for x in entities
261- ]
247+ entities = [self ._convert_model (x ) for x in entities ]
262248 if dialog_nodes is not None :
263- dialog_nodes = [
264- x ._to_dict () if hasattr (x , "_to_dict" ) else x
265- for x in dialog_nodes
266- ]
249+ dialog_nodes = [self ._convert_model (x ) for x in dialog_nodes ]
267250 if counterexamples is not None :
268- counterexamples = [
269- x ._to_dict () if hasattr (x , "_to_dict" ) else x
270- for x in counterexamples
271- ]
251+ counterexamples = [self ._convert_model (x ) for x in counterexamples ]
272252 params = {'version' : self .version }
273253 data = {
274254 'name' : name ,
@@ -317,21 +297,15 @@ def message(self,
317297 if workspace_id is None :
318298 raise ValueError ('workspace_id must be provided' )
319299 if input is not None :
320- input = input . _to_dict () if hasattr ( input , '_to_dict' ) else input
300+ input = self . _convert_model ( input )
321301 if context is not None :
322- context = context ._to_dict () if hasattr (context ,
323- '_to_dict' ) else context
302+ context = self ._convert_model (context )
324303 if entities is not None :
325- entities = [
326- x ._to_dict () if hasattr (x , "_to_dict" ) else x for x in entities
327- ]
304+ entities = [self ._convert_model (x ) for x in entities ]
328305 if intents is not None :
329- intents = [
330- x ._to_dict () if hasattr (x , "_to_dict" ) else x for x in intents
331- ]
306+ intents = [self ._convert_model (x ) for x in intents ]
332307 if output is not None :
333- output = output ._to_dict () if hasattr (output ,
334- '_to_dict' ) else output
308+ output = self ._convert_model (output )
335309 params = {'version' : self .version }
336310 data = {
337311 'input' : input ,
@@ -375,9 +349,7 @@ def create_intent(self,
375349 if intent is None :
376350 raise ValueError ('intent must be provided' )
377351 if examples is not None :
378- examples = [
379- x ._to_dict () if hasattr (x , "_to_dict" ) else x for x in examples
380- ]
352+ examples = [self ._convert_model (x ) for x in examples ]
381353 params = {'version' : self .version }
382354 data = {
383355 'intent' : intent ,
@@ -501,10 +473,7 @@ def update_intent(self,
501473 if intent is None :
502474 raise ValueError ('intent must be provided' )
503475 if new_examples is not None :
504- new_examples = [
505- x ._to_dict () if hasattr (x , "_to_dict" ) else x
506- for x in new_examples
507- ]
476+ new_examples = [self ._convert_model (x ) for x in new_examples ]
508477 params = {'version' : self .version }
509478 data = {
510479 'intent' : new_intent ,
@@ -705,9 +674,7 @@ def create_entity(self,
705674 if entity is None :
706675 raise ValueError ('entity must be provided' )
707676 if values is not None :
708- values = [
709- x ._to_dict () if hasattr (x , "_to_dict" ) else x for x in values
710- ]
677+ values = [self ._convert_model (x ) for x in values ]
711678 params = {'version' : self .version }
712679 data = {
713680 'entity' : entity ,
@@ -836,10 +803,7 @@ def update_entity(self,
836803 if entity is None :
837804 raise ValueError ('entity must be provided' )
838805 if new_values is not None :
839- new_values = [
840- x ._to_dict () if hasattr (x , "_to_dict" ) else x
841- for x in new_values
842- ]
806+ new_values = [self ._convert_model (x ) for x in new_values ]
843807 params = {'version' : self .version }
844808 data = {
845809 'entity' : new_entity ,
@@ -1276,12 +1240,9 @@ def create_dialog_node(self,
12761240 if dialog_node is None :
12771241 raise ValueError ('dialog_node must be provided' )
12781242 if next_step is not None :
1279- next_step = next_step ._to_dict () if hasattr (
1280- next_step , '_to_dict' ) else next_step
1243+ next_step = self ._convert_model (next_step )
12811244 if actions is not None :
1282- actions = [
1283- x ._to_dict () if hasattr (x , "_to_dict" ) else x for x in actions
1284- ]
1245+ actions = [self ._convert_model (x ) for x in actions ]
12851246 params = {'version' : self .version }
12861247 data = {
12871248 'dialog_node' : dialog_node ,
@@ -1437,13 +1398,9 @@ def update_dialog_node(self,
14371398 if new_dialog_node is None :
14381399 raise ValueError ('new_dialog_node must be provided' )
14391400 if new_next_step is not None :
1440- new_next_step = new_next_step ._to_dict () if hasattr (
1441- new_next_step , '_to_dict' ) else new_next_step
1401+ new_next_step = self ._convert_model (new_next_step )
14421402 if new_actions is not None :
1443- new_actions = [
1444- x ._to_dict () if hasattr (x , "_to_dict" ) else x
1445- for x in new_actions
1446- ]
1403+ new_actions = [self ._convert_model (x ) for x in new_actions ]
14471404 params = {'version' : self .version }
14481405 data = {
14491406 'dialog_node' : new_dialog_node ,
0 commit comments