2024-01-13 21:17:40 +00:00
|
|
|
using BotSharp.Abstraction.Conversations.Models;
|
|
|
|
|
using BotSharp.Abstraction.Functions;
|
2024-01-18 11:30:28 +00:00
|
|
|
using BotSharp.Plugin.SqlDriver.Models;
|
2024-01-13 21:17:40 +00:00
|
|
|
using BotSharp.Plugin.SqlHero.Settings;
|
|
|
|
|
using Dapper;
|
|
|
|
|
using MySqlConnector;
|
|
|
|
|
using System.Text.Json;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
2024-01-18 11:30:28 +00:00
|
|
|
namespace BotSharp.Plugin.SqlDriver.Actions;
|
2024-01-13 21:17:40 +00:00
|
|
|
|
|
|
|
|
public class ExecuteQueryAction : IFunctionCallback
|
|
|
|
|
{
|
|
|
|
|
public string Name => "execute_sql";
|
|
|
|
|
|
2024-01-18 11:30:28 +00:00
|
|
|
private readonly SqlDriverSetting _setting;
|
2024-01-13 21:17:40 +00:00
|
|
|
|
2024-01-18 11:30:28 +00:00
|
|
|
public ExecuteQueryAction(SqlDriverSetting setting)
|
2024-01-13 21:17:40 +00:00
|
|
|
{
|
|
|
|
|
_setting = setting;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<bool> Execute(RoleDialogModel message)
|
|
|
|
|
{
|
|
|
|
|
var args = JsonSerializer.Deserialize<LlmInputArgs>(message.FunctionArgs);
|
|
|
|
|
message.Content = "executed successully";
|
|
|
|
|
/*using var connection = new MySqlConnection(_setting.MySqlConnectionString);
|
|
|
|
|
message.Content = JsonSerializer.Serialize(connection.Query(args.SqlStatement), new JsonSerializerOptions
|
|
|
|
|
{
|
|
|
|
|
WriteIndented = true,
|
|
|
|
|
});*/
|
|
|
|
|
// message.StopCompletion = true;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|