Add attachment example and refine dictionary lookup
This commit is contained in:
parent
e0ceec0f4e
commit
04b3e85a37
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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" ]
|
||||
|
|
|
|||
|
|
@ -2,7 +2,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.
|
||||
|
|
@ -10,6 +10,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 -%}
|
||||
|
|
|
|||
|
|
@ -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