@@ -68,7 +68,7 @@ public static IWantToConfig ConfigModel(this IWantToConfig iWantToConfig, Config
68
68
{
69
69
return deploymentName ;
70
70
}
71
- else if ( ! senparcAiSetting . DeploymentName . IsNullOrEmpty ( ) )
71
+ else if ( ! senparcAiSetting . DeploymentName . IsNullOrEmpty ( ) )
72
72
{
73
73
return senparcAiSetting . DeploymentName ;
74
74
}
@@ -321,7 +321,21 @@ public static bool GetStoredArguments(this SenparcAiRequest request, string key,
321
321
/// <param name="request"></param>
322
322
/// <param name="inStreamItemProceessing">启用流,并指定遍历异步流每一步需要执行的委托。注意:只要此项不为 null,则会触发流式的请求。</param>
323
323
/// <returns></returns>
324
- public static async Task < SenparcKernelAiResult > RunAsync ( this IWantToRun iWanToRun , SenparcAiRequest request , Action < StreamingKernelContent > inStreamItemProceessing = null )
324
+ public static Task < SenparcKernelAiResult > RunAsync ( this IWantToRun iWanToRun , SenparcAiRequest request , Action < StreamingKernelContent > inStreamItemProceessing = null )
325
+ {
326
+ return RunAsync < string > ( iWanToRun , request , inStreamItemProceessing ) ;
327
+ }
328
+
329
+ /// <summary>
330
+ /// 运行
331
+ /// </summary>
332
+ /// <param name="iWanToRun"></param>
333
+ /// <param name="request"></param>
334
+ /// <param name="inStreamItemProceessing">启用流,并指定遍历异步流每一步需要执行的委托。注意:只要此项不为 null,则会触发流式的请求。</param>
335
+ /// <typeparam name="T">指定返回结果类型</typeparam>
336
+ /// <returns></returns>
337
+
338
+ public static async Task < SenparcKernelAiResult > RunAsync < T > ( this IWantToRun iWanToRun , SenparcAiRequest request , Action < StreamingKernelContent > inStreamItemProceessing = null )
325
339
{
326
340
var iWantTo = iWanToRun . IWantToBuild . IWantToConfig . IWantTo ;
327
341
var helper = iWanToRun . SemanticKernelHelper ;
@@ -412,7 +426,23 @@ public static async Task<SenparcKernelAiResult> RunAsync(this IWantToRun iWanToR
412
426
413
427
if ( ! useStream )
414
428
{
415
- result . Output = functionResult . GetValue < string > ( ) ? . TrimStart ( '\n ' ) ?? "" ;
429
+ try
430
+ {
431
+ result . Output = functionResult . GetValue < string > ( ) ? . TrimStart ( '\n ' ) ?? "" ;
432
+
433
+ }
434
+ catch ( Exception )
435
+ {
436
+ //TODO: 提供 Output 的泛型
437
+ try
438
+ {
439
+ result . Output = functionResult . GetValue < T > ( ) ? . ToJson ( ) ? . TrimStart ( '\n ' ) ?? "" ;
440
+ }
441
+ catch ( Exception )
442
+ {
443
+ result . Output = functionResult . GetValue < object > ( ) ? . ToJson ( ) ? . TrimStart ( '\n ' ) ?? "" ;
444
+ }
445
+ }
416
446
result . Result = functionResult ;
417
447
}
418
448
else
0 commit comments