11using System ;
22using System . Collections . Generic ;
3+ using System . IO ;
34using System . Linq ;
5+ using System . Reflection ;
46using System . Threading . Tasks ;
57using System . Web ;
68using Newtonsoft . Json ;
@@ -27,14 +29,14 @@ public IntentoAiText Parent
2729
2830 public dynamic Fulfill ( object text , string to , string from = null , string provider = null ,
2931 bool async = false , bool wait_async = false , string format = null , object auth = null ,
30- string custom_model = null , string glossary = null ,
32+ string custom_model = null , string glossary = null , int [ ] intentoGlossary = null ,
3133 object pre_processing = null , object post_processing = null ,
3234 bool failover = false , object failover_list = null , string routing = null , bool trace = false ,
3335 Dictionary < string , string > special_headers = null , bool useSyncwrapper = false )
3436 {
3537 Task < dynamic > taskReadResult = Task . Run < dynamic > ( async ( ) => await this . FulfillAsync ( text , to , from : from , provider : provider ,
3638 async : async , wait_async : wait_async , format : format , auth : auth ,
37- custom_model : custom_model , glossary : glossary ,
39+ custom_model : custom_model , glossary : glossary , intentoGlossary : intentoGlossary ,
3840 pre_processing : pre_processing , post_processing : post_processing ,
3941 failover : failover , failover_list : failover_list , routing : routing , trace : trace ,
4042 special_headers : special_headers , useSyncwrapper : useSyncwrapper ) ) ;
@@ -43,7 +45,7 @@ public dynamic Fulfill(object text, string to, string from = null, string provid
4345
4446 async public Task < dynamic > FulfillAsync ( object text , string to , string from = null , string provider = null ,
4547 bool async = false , bool wait_async = false , string format = null , object auth = null ,
46- string custom_model = null , string glossary = null ,
48+ string custom_model = null , string glossary = null , int [ ] intentoGlossary = null ,
4749 object pre_processing = null , object post_processing = null ,
4850 bool failover = false , object failover_list = null , string routing = null , bool trace = false ,
4951 Dictionary < string , string > special_headers = null , bool useSyncwrapper = false )
@@ -100,6 +102,13 @@ async public Task<dynamic> FulfillAsync(object text, string to, string from = nu
100102 if ( ! string . IsNullOrWhiteSpace ( glossary ) )
101103 context . glossary = glossary ;
102104
105+ // intento glossary
106+ if ( intentoGlossary != null && intentoGlossary . Length > 0 )
107+ {
108+ dynamic intentoG = JArray . FromObject ( intentoGlossary . Select ( g => JObject . FromObject ( new { id = g } ) ) ) ;
109+ context . glossary = intentoG ;
110+ }
111+
103112 json . context = context ;
104113
105114 // ----- service section
@@ -403,6 +412,54 @@ async public Task<IList<dynamic>> GlossariesAsync(string providerId, Dictionary<
403412 return glossaries;
404413 }
405414
415+ public IList< dynamic > AgnosticGlossaries ( )
416+ {
417+ Task < dynamic > taskReadResult = Task . Run < dynamic > ( async ( ) =>
418+ await AgnosticGlossariesAsync ( ) ) ;
419+ return taskReadResult. Result ;
420+ }
421+
422+ public async Task < IList < dynamic > > AgnosticGlossariesAsync ( )
423+ {
424+ var path = $"ai/text/glossaries/v2/typed" ;
425+ dynamic jsonResult ;
426+ // Call to Intento API and get json result
427+ using ( HttpConnector conn = new HttpConnector ( Intento ) )
428+ {
429+ jsonResult = await conn . GetAsync ( path ) ;
430+ }
431+ var glossaries = new List < dynamic > ( ) ;
432+ foreach ( dynamic glossary in jsonResult . glossaries )
433+ {
434+ glossaries. Add ( glossary ) ;
435+ }
436+ return glossaries;
437+ }
438+
439+ public IList< dynamic > AgnosticGlossariesTypes ( )
440+ {
441+ Task < dynamic > taskReadResult = Task . Run < dynamic > ( async ( ) =>
442+ await AgnosticGlossariesTypesAsync ( ) ) ;
443+ return taskReadResult. Result ;
444+ }
445+
446+ public async Task < IList < dynamic > > AgnosticGlossariesTypesAsync ( )
447+ {
448+ var path = $"ai/text/glossaries/v2/cs_types" ;
449+ dynamic jsonResult ;
450+ // Call to Intento API and get json result
451+ using ( HttpConnector conn = new HttpConnector ( Intento ) )
452+ {
453+ jsonResult = await conn . GetAsync ( path ) ;
454+ }
455+ var types = new List < dynamic > ( ) ;
456+ foreach ( dynamic type in jsonResult . types )
457+ {
458+ types. Add ( type ) ;
459+ }
460+ return types;
461+ }
462+
406463 /// <summary>
407464 /// Get a list of available delegated credentials
408465 /// </summary>
0 commit comments