refine code

This commit is contained in:
Jicheng Lu 2024-07-24 12:10:24 -05:00
parent da79eec90c
commit d983e2a44c
4 changed files with 16 additions and 19 deletions

View file

@ -1,5 +1,3 @@
using BotSharp.Abstraction.Messaging.Enums;
using BotSharp.Abstraction.Options;
using Microsoft.AspNetCore.SignalR;
namespace BotSharp.Plugin.ChatHub.Hooks;

View file

@ -1,11 +1,3 @@
using BotSharp.Abstraction.Agents.Models;
using BotSharp.Abstraction.Functions.Models;
using BotSharp.Abstraction.Loggers;
using BotSharp.Abstraction.Loggers.Enums;
using BotSharp.Abstraction.Loggers.Models;
using BotSharp.Abstraction.Options;
using BotSharp.Abstraction.Repositories;
using BotSharp.Abstraction.Routing;
using Microsoft.AspNetCore.SignalR;
using System.Text.Encodings.Web;
using System.Text.Unicode;
@ -570,10 +562,9 @@ public class StreamingLogHook : ConversationHookBase, IContentGeneratingHook, IR
private string FormatJson(string? json)
{
var defaultJson = "{}";
if (string.IsNullOrWhiteSpace(json))
{
return defaultJson;
return "{}";
}
try
@ -595,11 +586,11 @@ public class StreamingLogHook : ConversationHookBase, IContentGeneratingHook, IR
{
Formatting = Newtonsoft.Json.Formatting.Indented
};
return JsonConvert.SerializeObject(parsedJson, jsonSettings) ?? defaultJson;
return JsonConvert.SerializeObject(parsedJson, jsonSettings);
}
catch
{
return defaultJson;
return json;
}
}
#endregion

View file

@ -1,8 +1,4 @@
using BotSharp.Abstraction.Messaging.Models.RichContent;
using BotSharp.Abstraction.Messaging;
using BotSharp.Abstraction.Templating;
using Microsoft.AspNetCore.SignalR;
using BotSharp.Abstraction.Options;
namespace BotSharp.Plugin.ChatHub.Hooks;

View file

@ -19,4 +19,16 @@ global using BotSharp.Abstraction.Conversations.Settings;
global using BotSharp.Abstraction.Agents.Enums;
global using BotSharp.Abstraction.Conversations.Models;
global using BotSharp.OpenAPI.ViewModels.Conversations;
global using BotSharp.OpenAPI.ViewModels.Users;
global using BotSharp.OpenAPI.ViewModels.Users;
global using BotSharp.Abstraction.Agents.Models;
global using BotSharp.Abstraction.Functions.Models;
global using BotSharp.Abstraction.Loggers;
global using BotSharp.Abstraction.Loggers.Enums;
global using BotSharp.Abstraction.Loggers.Models;
global using BotSharp.Abstraction.Options;
global using BotSharp.Abstraction.Repositories;
global using BotSharp.Abstraction.Routing;
global using BotSharp.Abstraction.Messaging;
global using BotSharp.Abstraction.Messaging.Enums;
global using BotSharp.Abstraction.Messaging.Models.RichContent;
global using BotSharp.Abstraction.Templating;