Merge pull request #684 from Joannall/master
Add attachment example and refine dictionary lookup
This commit is contained in:
commit
927dd471af
|
|
@ -54,6 +54,12 @@ public partial class FileRepository
|
|||
File.WriteAllText(path, JsonSerializer.Serialize(user, _options));
|
||||
}
|
||||
|
||||
public void UpdateExistUser(string userId, User user)
|
||||
{
|
||||
user.Id = userId;
|
||||
CreateUser(user);
|
||||
}
|
||||
|
||||
public void UpdateUserVerified(string userId)
|
||||
{
|
||||
var user = GetUserById(userId);
|
||||
|
|
|
|||
|
|
@ -2,7 +2,9 @@ using System.Data;
|
|||
using BotSharp.Abstraction.Routing;
|
||||
using BotSharp.Plugin.ExcelHandler.Helpers.MySql;
|
||||
using BotSharp.Plugin.ExcelHandler.Models;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Internal;
|
||||
using MySql.Data.MySqlClient;
|
||||
using Newtonsoft.Json;
|
||||
using NPOI.SS.UserModel;
|
||||
|
||||
namespace BotSharp.Plugin.ExcelHandler.Services
|
||||
|
|
@ -108,10 +110,14 @@ namespace BotSharp.Plugin.ExcelHandler.Services
|
|||
continue;
|
||||
}
|
||||
var (isInsertSuccess, insertMessage) = SqlInsertDataFn(sheet);
|
||||
|
||||
string table = $"{_database}.{_tableName}";
|
||||
string exampleData = GetInsertExample(table);
|
||||
|
||||
commandResult = new SqlContextOut
|
||||
{
|
||||
isSuccessful = isInsertSuccess,
|
||||
Message = $"{insertMessage}\r\n{message}",
|
||||
Message = $"{insertMessage}\r\nExample Data: {exampleData}",
|
||||
FileName = _currentFileName
|
||||
};
|
||||
commandList.Add(commandResult);
|
||||
|
|
@ -240,5 +246,18 @@ namespace BotSharp.Plugin.ExcelHandler.Services
|
|||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
private string GetInsertExample(string tableName)
|
||||
{
|
||||
using var connection = _mySqlDbHelpers.GetDbConnection();
|
||||
_database = connection.Database;
|
||||
var sqlQuery = $"SELECT * FROM {tableName} LIMIT 2;";
|
||||
using var cmd = new MySqlCommand(sqlQuery, connection);
|
||||
using var reader = cmd.ExecuteReader();
|
||||
|
||||
var dataExample = new DataTable();
|
||||
dataExample.Load(reader);
|
||||
|
||||
return JsonConvert.SerializeObject(dataExample);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
You are a knowledge generator for knowledge base. Extract the answer in "SQL Answer" to answer the User Questions
|
||||
Replace alias with the actual table name. Output json array only, formatting as [{"question":"string", "answer":"string/sql statement"}].
|
||||
Skip the question/answer for tmp table.
|
||||
Don't include tmp table in the answer.
|
||||
You are a knowledge generator for knowledge base. Extract the answer in "SQL Answer" to answer the User Questions.
|
||||
* Replace alias with the actual table name. Output json array only, formatting as [{"question":"string", "answer":""}].
|
||||
* Skip the question/answer for tmp table.
|
||||
* Don't include tmp table in the answer.
|
||||
* Include all the explanation comments as additional knowledge.
|
||||
|
||||
=====
|
||||
User Questions:
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
},
|
||||
"solution_search_question": {
|
||||
"type": "string",
|
||||
"description": "Provide solution query text"
|
||||
"description": "Generate question to find the knowledge for text. Be short"
|
||||
}
|
||||
},
|
||||
"required": [ "task_description", "solution_search_question" ]
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ Use the TwoStagePlanner approach to plan the overall implementation steps, follo
|
|||
1. Call plan_primary_stage to generate the primary plan.
|
||||
If you've already got the plan to meet the user goal, directly go to step 5.
|
||||
2. If need_lookup_dictionary is True, call verify_dictionary_term to verify or get the enum/term/dictionary value. Pull id and name.
|
||||
If you no items retured, you can pull all the list and find the match.
|
||||
If you no items retured, you can pull 100 records from the table and look for the match.
|
||||
If need_lookup_dictionary is False, skip calling verify_dictionary_term.
|
||||
3. If need_breakdown_task is true, call plan_secondary_stage for the specific primary stage.
|
||||
4. Repeat step 3 until you processed all the primary stages.
|
||||
|
|
@ -12,6 +12,7 @@ Use the TwoStagePlanner approach to plan the overall implementation steps, follo
|
|||
|
||||
*** IMPORTANT ***
|
||||
Don't run the planning process repeatedly if you have already got the result of user's request.
|
||||
Function verify_dictionary_term CAN'T generate INSERT SQL Statement.
|
||||
|
||||
|
||||
{% if global_knowledges != empty -%}
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ public class GetTableDefinitionFn : IFunctionCallback
|
|||
{
|
||||
var settings = _services.GetRequiredService<SqlDriverSetting>();
|
||||
var tableDdls = new List<string>();
|
||||
using var connection = new MySqlConnection(settings.MySqlExecutionConnectionString ?? settings.MySqlConnectionString);
|
||||
using var connection = new MySqlConnection(settings.MySqlMetaConnectionString ?? settings.MySqlConnectionString);
|
||||
connection.Open();
|
||||
|
||||
foreach (var table in tables)
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ public class SqlDriverSetting
|
|||
public string MySqlConnectionString { get; set; } = null!;
|
||||
public string MySqlExecutionConnectionString { get; set; } = null!;
|
||||
public string MySqlTempConnectionString { get; set; } = null!;
|
||||
public string MySqlMetaConnectionString { get; set; } = null!;
|
||||
public string SqlServerConnectionString { get; set; } = null!;
|
||||
public string SqlServerExecutionConnectionString { get; set; } = null!;
|
||||
public string SqlLiteConnectionString { get; set; } = null!;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "verify_dictionary_term",
|
||||
"description": "Get id from dictionary table by keyword if tool or solution mentioned this approach",
|
||||
"description": "Get id from dictionary table by keyword. Call this function only if need_lookup_dictionary is True",
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
|
|
|||
|
|
@ -1,11 +1,13 @@
|
|||
Dictionary Verification Rules:
|
||||
Rules to call verify_dictionary_term:
|
||||
=====
|
||||
1. The table name must come from the planning in conversation.
|
||||
2. You must return the id and name/code.
|
||||
2. You must return the id and name/code for existing dictionary.
|
||||
3. Call the function only if need_lookup_dictionary is true.
|
||||
|
||||
You are connecting to {{ db_type }} database. You can run provided SQL statements by following {{ db_type }} rules.
|
||||
|
||||
The dictionary table is identified by a name that begins with "data_". You are only allowed to query the dictionary table without joining it with other non-dictionary tables.
|
||||
The dictionary table is identified by a name that begins with "data_".
|
||||
You are only allowed to query the dictionary table without joining it with other non-dictionary tables.
|
||||
|
||||
IMPORTANT: Don't generate insert SQL.
|
||||
IMPORTANT: You can NOT insert data into dictionary.
|
||||
=====
|
||||
Loading…
Reference in a new issue