@deepagents/text2sql 0.28.0 → 0.29.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +22 -118
- package/dist/index.js.map +2 -2
- package/dist/lib/instructions.d.ts.map +1 -1
- package/dist/lib/sql.d.ts +1 -0
- package/dist/lib/sql.d.ts.map +1 -1
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -4747,128 +4747,11 @@ import {
|
|
|
4747
4747
|
guardrail as guardrail2,
|
|
4748
4748
|
hint as hint2,
|
|
4749
4749
|
policy as policy2,
|
|
4750
|
-
principle,
|
|
4751
4750
|
quirk,
|
|
4752
|
-
|
|
4751
|
+
reasoningFramework,
|
|
4753
4752
|
styleGuide,
|
|
4754
4753
|
workflow as workflow2
|
|
4755
4754
|
} from "@deepagents/context";
|
|
4756
|
-
function reasoningFramework() {
|
|
4757
|
-
return [
|
|
4758
|
-
role(
|
|
4759
|
-
"You are a very strong reasoner and planner. Use these critical instructions to structure your plans, thoughts, and responses."
|
|
4760
|
-
),
|
|
4761
|
-
fragment2(
|
|
4762
|
-
"meta_cognitive_reasoning_framework",
|
|
4763
|
-
hint2(
|
|
4764
|
-
"Before taking any action (either tool calls *or* responses to the user), you must proactively, methodically, and independently plan and reason about:"
|
|
4765
|
-
),
|
|
4766
|
-
// 1) Logical dependencies and constraints
|
|
4767
|
-
principle({
|
|
4768
|
-
title: "Logical dependencies and constraints",
|
|
4769
|
-
description: "Analyze the intended action against the following factors. Resolve conflicts in order of importance:",
|
|
4770
|
-
policies: [
|
|
4771
|
-
policy2({
|
|
4772
|
-
rule: "Policy-based rules, mandatory prerequisites, and constraints."
|
|
4773
|
-
}),
|
|
4774
|
-
policy2({
|
|
4775
|
-
rule: "Order of operations: Ensure taking an action does not prevent a subsequent necessary action.",
|
|
4776
|
-
policies: [
|
|
4777
|
-
"The user may request actions in a random order, but you may need to reorder operations to maximize successful completion of the task."
|
|
4778
|
-
]
|
|
4779
|
-
}),
|
|
4780
|
-
policy2({
|
|
4781
|
-
rule: "Other prerequisites (information and/or actions needed)."
|
|
4782
|
-
}),
|
|
4783
|
-
policy2({ rule: "Explicit user constraints or preferences." })
|
|
4784
|
-
]
|
|
4785
|
-
}),
|
|
4786
|
-
// 2) Risk assessment
|
|
4787
|
-
principle({
|
|
4788
|
-
title: "Risk assessment",
|
|
4789
|
-
description: "What are the consequences of taking the action? Will the new state cause any future issues?",
|
|
4790
|
-
policies: [
|
|
4791
|
-
"For exploratory tasks (like searches), missing *optional* parameters is a LOW risk. **Prefer calling the tool with the available information over asking the user, unless** your Rule 1 (Logical Dependencies) reasoning determines that optional information is required for a later step in your plan."
|
|
4792
|
-
]
|
|
4793
|
-
}),
|
|
4794
|
-
// 3) Abductive reasoning and hypothesis exploration
|
|
4795
|
-
principle({
|
|
4796
|
-
title: "Abductive reasoning and hypothesis exploration",
|
|
4797
|
-
description: "At each step, identify the most logical and likely reason for any problem encountered.",
|
|
4798
|
-
policies: [
|
|
4799
|
-
"Look beyond immediate or obvious causes. The most likely reason may not be the simplest and may require deeper inference.",
|
|
4800
|
-
"Hypotheses may require additional research. Each hypothesis may take multiple steps to test.",
|
|
4801
|
-
"Prioritize hypotheses based on likelihood, but do not discard less likely ones prematurely. A low-probability event may still be the root cause."
|
|
4802
|
-
]
|
|
4803
|
-
}),
|
|
4804
|
-
// 4) Outcome evaluation and adaptability
|
|
4805
|
-
principle({
|
|
4806
|
-
title: "Outcome evaluation and adaptability",
|
|
4807
|
-
description: "Does the previous observation require any changes to your plan?",
|
|
4808
|
-
policies: [
|
|
4809
|
-
"If your initial hypotheses are disproven, actively generate new ones based on the gathered information."
|
|
4810
|
-
]
|
|
4811
|
-
}),
|
|
4812
|
-
// 5) Information availability
|
|
4813
|
-
principle({
|
|
4814
|
-
title: "Information availability",
|
|
4815
|
-
description: "Incorporate all applicable and alternative sources of information, including:",
|
|
4816
|
-
policies: [
|
|
4817
|
-
"Using available tools and their capabilities",
|
|
4818
|
-
"All policies, rules, checklists, and constraints",
|
|
4819
|
-
"Previous observations and conversation history",
|
|
4820
|
-
"Information only available by asking the user"
|
|
4821
|
-
]
|
|
4822
|
-
}),
|
|
4823
|
-
// 6) Precision and Grounding
|
|
4824
|
-
principle({
|
|
4825
|
-
title: "Precision and Grounding",
|
|
4826
|
-
description: "Ensure your reasoning is extremely precise and relevant to each exact ongoing situation.",
|
|
4827
|
-
policies: [
|
|
4828
|
-
"Verify your claims by quoting the exact applicable information (including policies) when referring to them."
|
|
4829
|
-
]
|
|
4830
|
-
}),
|
|
4831
|
-
// 7) Completeness
|
|
4832
|
-
principle({
|
|
4833
|
-
title: "Completeness",
|
|
4834
|
-
description: "Ensure that all requirements, constraints, options, and preferences are exhaustively incorporated into your plan.",
|
|
4835
|
-
policies: [
|
|
4836
|
-
policy2({
|
|
4837
|
-
rule: "Resolve conflicts using the order of importance in #1."
|
|
4838
|
-
}),
|
|
4839
|
-
policy2({
|
|
4840
|
-
rule: "Avoid premature conclusions: There may be multiple relevant options for a given situation.",
|
|
4841
|
-
policies: [
|
|
4842
|
-
"To check for whether an option is relevant, reason about all information sources from #5.",
|
|
4843
|
-
"You may need to consult the user to even know whether something is applicable. Do not assume it is not applicable without checking."
|
|
4844
|
-
]
|
|
4845
|
-
}),
|
|
4846
|
-
policy2({
|
|
4847
|
-
rule: "Review applicable sources of information from #5 to confirm which are relevant to the current state."
|
|
4848
|
-
})
|
|
4849
|
-
]
|
|
4850
|
-
}),
|
|
4851
|
-
// 8) Persistence and patience
|
|
4852
|
-
principle({
|
|
4853
|
-
title: "Persistence and patience",
|
|
4854
|
-
description: "Do not give up unless all the reasoning above is exhausted.",
|
|
4855
|
-
policies: [
|
|
4856
|
-
"Don't be dissuaded by time taken or user frustration.",
|
|
4857
|
-
"This persistence must be intelligent: On *transient* errors (e.g. please try again), you *must* retry **unless an explicit retry limit (e.g., max x tries) has been reached**. If such a limit is hit, you *must* stop. On *other* errors, you must change your strategy or arguments, not repeat the same failed call."
|
|
4858
|
-
]
|
|
4859
|
-
}),
|
|
4860
|
-
// 9) Inhibit your response
|
|
4861
|
-
principle({
|
|
4862
|
-
title: "Inhibit your response",
|
|
4863
|
-
description: "Only take an action after all the above reasoning is completed. Once you've taken an action, you cannot take it back."
|
|
4864
|
-
}),
|
|
4865
|
-
principle({
|
|
4866
|
-
title: "Continuous self-monitoring",
|
|
4867
|
-
description: "Constantly evaluate your own reasoning process for any gaps, biases, or errors. Apply the above principles iteratively as needed."
|
|
4868
|
-
})
|
|
4869
|
-
)
|
|
4870
|
-
];
|
|
4871
|
-
}
|
|
4872
4755
|
function guidelines() {
|
|
4873
4756
|
const baseTeachings = [
|
|
4874
4757
|
// Include the meta-cognitive reasoning framework
|
|
@@ -5156,6 +5039,8 @@ import {
|
|
|
5156
5039
|
assistant,
|
|
5157
5040
|
chatMessageToUIMessage,
|
|
5158
5041
|
errorRecoveryGuardrail,
|
|
5042
|
+
generateChatTitle,
|
|
5043
|
+
staticChatTitle,
|
|
5159
5044
|
toMessageFragment
|
|
5160
5045
|
} from "@deepagents/context";
|
|
5161
5046
|
var Text2Sql = class {
|
|
@@ -5242,6 +5127,22 @@ var Text2Sql = class {
|
|
|
5242
5127
|
assistantMsgId = generateId();
|
|
5243
5128
|
}
|
|
5244
5129
|
const uiMessages = messages.map(chatMessageToUIMessage);
|
|
5130
|
+
let title = null;
|
|
5131
|
+
if (!context.chat?.title) {
|
|
5132
|
+
const firstUserMsg = uiMessages.find((m) => m.role === "user");
|
|
5133
|
+
if (firstUserMsg) {
|
|
5134
|
+
if (options?.generateTitle) {
|
|
5135
|
+
title = await generateChatTitle({
|
|
5136
|
+
message: firstUserMsg,
|
|
5137
|
+
model: this.#config.model,
|
|
5138
|
+
abortSignal: options?.abortSignal
|
|
5139
|
+
});
|
|
5140
|
+
} else {
|
|
5141
|
+
title = staticChatTitle(firstUserMsg);
|
|
5142
|
+
}
|
|
5143
|
+
await context.updateChat({ title });
|
|
5144
|
+
}
|
|
5145
|
+
}
|
|
5245
5146
|
const { mounts: skillMounts } = context.getSkillMounts();
|
|
5246
5147
|
const { tools } = await createResultTools({
|
|
5247
5148
|
adapter: this.#config.adapter,
|
|
@@ -5311,6 +5212,9 @@ var Text2Sql = class {
|
|
|
5311
5212
|
},
|
|
5312
5213
|
execute: async ({ writer }) => {
|
|
5313
5214
|
writer.merge(uiStream);
|
|
5215
|
+
if (title) {
|
|
5216
|
+
writer.write({ type: "data-chat-title", data: title });
|
|
5217
|
+
}
|
|
5314
5218
|
}
|
|
5315
5219
|
});
|
|
5316
5220
|
}
|