Merge pull request #625 from iceljc/master

relocate
This commit is contained in:
iceljc 2024-09-05 10:42:09 -05:00 committed by GitHub
commit a5ba69c05c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 14 additions and 42 deletions

View file

@ -6,7 +6,6 @@ using BotSharp.Abstraction.Routing.Planning;
using BotSharp.Abstraction.Settings;
using BotSharp.Abstraction.Templating;
using BotSharp.Core.Instructs;
using BotSharp.Core.Knowledges.Services;
using BotSharp.Core.Messaging;
using BotSharp.Core.Routing.Planning;
using BotSharp.Core.Templating;

View file

@ -1,7 +1,4 @@
using BotSharp.Abstraction.Knowledges.Settings;
using BotSharp.Abstraction.MLTasks;
namespace BotSharp.Core.Knowledges.Helpers;
namespace BotSharp.Plugin.KnowledgeBase.Helpers;
public static class KnowledgeSettingHelper
{

View file

@ -1,7 +1,6 @@
using BotSharp.Abstraction.Knowledges.Models;
using System.Text.RegularExpressions;
namespace BotSharp.Core.Knowledges.Helpers;
namespace BotSharp.Plugin.KnowledgeBase.Helpers;
public static class TextChopper
{

View file

@ -1,8 +1,8 @@
using BotSharp.Abstraction.Plugins.Models;
using BotSharp.Abstraction.Settings;
using BotSharp.Core.Knowledges.Services;
using BotSharp.Plugin.KnowledgeBase.Converters;
using BotSharp.Plugin.KnowledgeBase.Hooks;
using BotSharp.Plugin.KnowledgeBase.Services;
using Microsoft.Extensions.Configuration;
namespace BotSharp.Plugin.KnowledgeBase;

View file

@ -1,8 +1,4 @@
using BotSharp.Abstraction.Knowledges.Models;
using BotSharp.Abstraction.VectorStorage.Models;
using BotSharp.Core.Knowledges.Helpers;
namespace BotSharp.Core.Knowledges.Services;
namespace BotSharp.Plugin.KnowledgeBase.Services;
public partial class KnowledgeService
{

View file

@ -1,4 +1,4 @@
namespace BotSharp.Core.Knowledges.Services;
namespace BotSharp.Plugin.KnowledgeBase.Services;
public partial class KnowledgeService
{

View file

@ -1,8 +1,4 @@
using BotSharp.Abstraction.Graph.Models;
using BotSharp.Abstraction.Knowledges.Models;
using BotSharp.Abstraction.VectorStorage.Models;
namespace BotSharp.Core.Knowledges.Services;
namespace BotSharp.Plugin.KnowledgeBase.Services;
public partial class KnowledgeService
{

View file

@ -1,6 +1,4 @@
using BotSharp.Abstraction.VectorStorage.Models;
namespace BotSharp.Core.Knowledges.Services;
namespace BotSharp.Plugin.KnowledgeBase.Services;
public partial class KnowledgeService
{

View file

@ -1,10 +1,4 @@
using BotSharp.Abstraction.Graph;
using BotSharp.Abstraction.Knowledges.Settings;
using BotSharp.Abstraction.MLTasks;
using BotSharp.Abstraction.VectorStorage;
using BotSharp.Core.Knowledges.Helpers;
namespace BotSharp.Core.Knowledges.Services;
namespace BotSharp.Plugin.KnowledgeBase.Services;
public partial class KnowledgeService : IKnowledgeService
{

View file

@ -20,6 +20,7 @@ global using BotSharp.Abstraction.Knowledges.Settings;
global using BotSharp.Abstraction.Knowledges.Enums;
global using BotSharp.Abstraction.VectorStorage;
global using BotSharp.Abstraction.VectorStorage.Models;
global using BotSharp.Abstraction.Graph.Models;
global using BotSharp.Abstraction.Knowledges.Models;
global using BotSharp.Abstraction.MLTasks;
global using BotSharp.Abstraction.Functions;

View file

@ -36,22 +36,14 @@ public class GetTableDefinitionFn : IFunctionCallback
{
try
{
var sql = $"select * from information_schema.tables where table_name = @tableName";
var escapedTableName = MySqlHelper.EscapeString(table);
var sql = $"SHOW CREATE TABLE `{escapedTableName}`";
var result = connection.QueryFirstOrDefault(sql, new
{
tableName = escapedTableName
});
if (result == null) continue;
sql = $"SHOW CREATE TABLE `{escapedTableName}`";
using var command = new MySqlCommand(sql, connection);
using var reader = command.ExecuteReader();
if (reader.Read())
{
result = reader.GetString(1);
var result = reader.GetString(1);
tableDdls.Add(result);
}

View file

@ -91,13 +91,13 @@ public class DbKnowledgeService
private string GetTableStructure(string table)
{
var settings = _services.GetRequiredService<SqlDriverSetting>();
using var connection = new MySqlConnection(settings.MySqlConnectionString);
connection.Open();
var ddl = string.Empty;
var escapedTableName = MySqlHelper.EscapeString(table);
var sql = $"SHOW CREATE TABLE `{escapedTableName}`";
using var connection = new MySqlConnection(settings.MySqlConnectionString);
connection.Open();
using var command = new MySqlCommand(sql, connection);
using var reader = command.ExecuteReader();
if (reader.Read())