Skip to content

Commit b4bc506

Browse files
committed
Refined knowledge search, added norm_question, entity type/value parms
1 parent 127e694 commit b4bc506

File tree

6 files changed

+41
-6
lines changed

6 files changed

+41
-6
lines changed

src/Plugins/BotSharp.Plugin.KnowledgeBase/data/agents/01acc3e5-0af7-49e6-ad7a-a760bd12dc40/templates/knowledge.generation.plain.liquid

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ You are a knowledge extractor for knowledge base. Extract the answer in "SQL Ans
33
* Skip the question/answer for tmp table.
44
* Don't include tmp table in the answer.
55
* Include all the explanation comments as additional knowledge.
6+
* Don't replace the parameter in the question.
7+
* Replace the specific id in answer based on the question.
8+
* Don't need multiple set of query solutions for the same question. Only keep one.
69

710
=====
811
User Questions:

src/Plugins/BotSharp.Plugin.Planner/Functions/PrimaryStagePlanFn.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,14 @@ public async Task<bool> Execute(RoleDialogModel message)
2525

2626
state.SetState("max_tokens", "4096");
2727
var task = JsonSerializer.Deserialize<PrimaryRequirementRequest>(message.FunctionArgs);
28+
var searchQuestions = new List<string>(task.Questions);
29+
searchQuestions.AddRange(task.NormQuestions);
30+
searchQuestions = searchQuestions.Distinct().ToList();
2831

2932
// Get knowledge from vectordb
3033
var hooks = _services.GetServices<IKnowledgeHook>();
3134
var knowledges = new List<string>();
32-
foreach (var question in task.Questions)
35+
foreach (var question in searchQuestions)
3336
{
3437
foreach (var hook in hooks)
3538
{

src/Plugins/BotSharp.Plugin.Planner/TwoStaging/Models/PrimaryRequirementRequest.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,7 @@ public class PrimaryRequirementRequest
77

88
[JsonPropertyName("questions")]
99
public string[] Questions { get; set; } = [];
10+
11+
[JsonPropertyName("norm_questions")]
12+
public string[] NormQuestions { get; set; } = [];
1013
}

src/Plugins/BotSharp.Plugin.Planner/data/agents/282a7128-69a1-44b0-878c-a9159b88f3b9/functions/plan_primary_stage.json

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,35 @@
1010
},
1111
"questions": {
1212
"type": "array",
13-
"description": "Rephrase user requirements in details and in multiple ways, don't miss any information especially for those line items, values and numbers.",
13+
"description": "Break down user requirements in details and in multiple ways, don't miss any entity type/value",
1414
"items": {
1515
"type": "string",
16-
"description": "Question converted from requirement in different ways to search in the knowledge base, be short and you can refer to the global knowledge.One question should contain only one main topic."
16+
"description": "Question converted from requirement in different ways to search in the knowledge base, be short and you can refer to the global knowledge.One question should contain only one main topic that with one entity type."
17+
}
18+
},
19+
"norm_questions": {
20+
"type": "array",
21+
"description": "normalize the generated questions, remove specific entity value.",
22+
"items": {
23+
"type": "string",
24+
"description": "Normalized question"
25+
}
26+
},
27+
"entities": {
28+
"type": "array",
29+
"description": "entities with type and value",
30+
"items": {
31+
"type": "object",
32+
"properties": {
33+
"type": {
34+
"type": "string",
35+
"description": "entity type"
36+
},
37+
"value": {
38+
"type": "string",
39+
"description": "entity value"
40+
}
41+
}
1742
}
1843
}
1944
},

src/Plugins/BotSharp.Plugin.Planner/data/agents/282a7128-69a1-44b0-878c-a9159b88f3b9/templates/two_stage.1st.plan.liquid

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ Thinking process:
88
- If there is extra knowledge or relationship needed between steps, set the need_breakdown_task to true for both steps.
99
- If the solution mentioned "related solutions" is needed, set the need_breakdown_task to true.
1010
- You should find the relationships between data structure based on the task knowledge strictly. If lack of information, set the need_breakdown_task to true.
11-
- If you need to lookup the dictionary to verify or get the enum/term/dictionary value, set the need_lookup_dictionary to true.
11+
- If you need to lookup the dictionary to verify or get the enum/term/dictionary value(exclude example data from attachment), set the need_lookup_dictionary to true.
12+
- Don't set need_lookup_dictionary to true for attachment data.
1213
- Seperate the dictionary lookup and need additional information/knowledge into different subtask.
1314
3. Input argument must reference to corresponding variable name that retrieved by previous steps, variable name must start with '@';
1415
4. Output all the subtasks as much detail as possible in JSON: [{{ response_format }}]

src/Plugins/BotSharp.Plugin.SqlDriver/data/agents/6745151e-6d46-4a02-8de4-1c4f21c7da95/functions/verify_dictionary_term.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "verify_dictionary_term",
3-
"description": "Get id from dictionary table by keyword. Call this function only if need_lookup_dictionary is true and is_insert is false",
3+
"description": "Get id from dictionary table by keyword. Call this function only if need_lookup_dictionary is true and is_insert is false. You can only query one table at a time.",
44
"parameters": {
55
"type": "object",
66
"properties": {
@@ -18,7 +18,7 @@
1818
},
1919
"tables": {
2020
"type": "array",
21-
"description": "all related tables",
21+
"description": "all related dictionary tables",
2222
"items": {
2323
"type": "string",
2424
"description": "table name"

0 commit comments

Comments
 (0)