mirror of https://github.com/buster-so/buster.git
small tweaks to the agent
This commit is contained in:
parent
56ed9d1775
commit
9478e233f7
|
@ -1,4 +1,5 @@
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
use chrono::Local;
|
||||||
use database::helpers::datasets::get_dataset_names_for_organization;
|
use database::helpers::datasets::get_dataset_names_for_organization;
|
||||||
use database::organization::get_user_organization_id;
|
use database::organization::get_user_organization_id;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
@ -230,13 +231,17 @@ impl BusterMultiAgent {
|
||||||
Err(e) => return Err(e),
|
Err(e) => return Err(e),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let todays_date = Local::now().format("%Y-%m-%d").to_string();
|
||||||
|
|
||||||
let dataset_names = get_dataset_names_for_organization(organization_id).await?;
|
let dataset_names = get_dataset_names_for_organization(organization_id).await?;
|
||||||
|
|
||||||
// Select initial default prompt based on whether it's a follow-up
|
// Select initial default prompt based on whether it's a follow-up
|
||||||
let initial_default_prompt = if is_follow_up {
|
let initial_default_prompt = if is_follow_up {
|
||||||
FOLLOW_UP_INTIALIZATION_PROMPT.replace("{DATASETS}", &dataset_names.join(", "))
|
FOLLOW_UP_INTIALIZATION_PROMPT.replace("{DATASETS}", &dataset_names.join(", "))
|
||||||
|
.replace("{TODAYS_DATE}", &todays_date)
|
||||||
} else {
|
} else {
|
||||||
INTIALIZATION_PROMPT.replace("{DATASETS}", &dataset_names.join(", "))
|
INTIALIZATION_PROMPT.replace("{DATASETS}", &dataset_names.join(", "))
|
||||||
|
.replace("{TODAYS_DATE}", &todays_date)
|
||||||
};
|
};
|
||||||
|
|
||||||
// Create agent, passing the selected initialization prompt as default
|
// Create agent, passing the selected initialization prompt as default
|
||||||
|
@ -276,14 +281,26 @@ impl BusterMultiAgent {
|
||||||
agent
|
agent
|
||||||
.add_dynamic_prompt_rule(
|
.add_dynamic_prompt_rule(
|
||||||
needs_data_catalog_search_condition,
|
needs_data_catalog_search_condition,
|
||||||
DATA_CATALOG_SEARCH_PROMPT.replace("{DATASETS}", &dataset_names.join(", ")).to_string(),
|
DATA_CATALOG_SEARCH_PROMPT
|
||||||
|
.replace("{DATASETS}", &dataset_names.join(", "))
|
||||||
|
.to_string(),
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
agent
|
agent
|
||||||
.add_dynamic_prompt_rule(needs_plan_condition, CREATE_PLAN_PROMPT.to_string())
|
.add_dynamic_prompt_rule(
|
||||||
|
needs_plan_condition,
|
||||||
|
CREATE_PLAN_PROMPT
|
||||||
|
.replace("{TODAYS_DATE}", &todays_date)
|
||||||
|
.to_string(),
|
||||||
|
)
|
||||||
.await;
|
.await;
|
||||||
agent
|
agent
|
||||||
.add_dynamic_prompt_rule(needs_analysis_condition, ANALYSIS_PROMPT.to_string())
|
.add_dynamic_prompt_rule(
|
||||||
|
needs_analysis_condition,
|
||||||
|
ANALYSIS_PROMPT
|
||||||
|
.replace("{TODAYS_DATE}", &todays_date)
|
||||||
|
.to_string(),
|
||||||
|
)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
// Add dynamic model rule: Use gpt-4.1-mini when searching the data catalog
|
// Add dynamic model rule: Use gpt-4.1-mini when searching the data catalog
|
||||||
|
@ -374,6 +391,8 @@ You are Buster, an AI assistant and expert in **data analytics, data science, an
|
||||||
|
|
||||||
Your primary goal is to follow the user's instructions, provided in the `"content"` field of messages with `"role": "user"`. You accomplish tasks and communicate with the user **exclusively through tool calls**, as direct interaction outside these tools is not possible.
|
Your primary goal is to follow the user's instructions, provided in the `"content"` field of messages with `"role": "user"`. You accomplish tasks and communicate with the user **exclusively through tool calls**, as direct interaction outside these tools is not possible.
|
||||||
|
|
||||||
|
Today's date is {TODAYS_DATE}.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
### Tool Calling
|
### Tool Calling
|
||||||
|
@ -584,7 +603,11 @@ Datasets include:
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
**Bold Reminder**: **Thoroughness is key.** Follow each step carefully, execute tools in sequence, and verify outputs to ensure accurate, helpful responses."##;
|
**Bold Reminder**: **Thoroughness is key.** Follow each step carefully, execute tools in sequence, and verify outputs to ensure accurate, helpful responses.
|
||||||
|
|
||||||
|
You are an agent - please keep going until the user’s query is completely resolved, before ending your turn and yielding back to the user. Only terminate your turn when you are sure that the problem is solved.
|
||||||
|
If you are not sure about file content or codebase structure pertaining to the user's request, use your tools to read files and gather the relevant information: do NOT guess or make up an answer.
|
||||||
|
You MUST plan extensively before each function call, and reflect extensively on the outcomes of the previous function calls. DO NOT do this entire process by making function calls only, as this can impair your ability to solve the problem and think insightfully."##;
|
||||||
|
|
||||||
const FOLLOW_UP_INTIALIZATION_PROMPT: &str = r##"## Overview
|
const FOLLOW_UP_INTIALIZATION_PROMPT: &str = r##"## Overview
|
||||||
You are Buster, an AI assistant and expert in **data analytics, data science, and data engineering**. You operate within the **Buster platform**, the world's best BI tool, assisting non-technical users with their analytics tasks. Your capabilities include:
|
You are Buster, an AI assistant and expert in **data analytics, data science, and data engineering**. You operate within the **Buster platform**, the world's best BI tool, assisting non-technical users with their analytics tasks. Your capabilities include:
|
||||||
|
@ -596,6 +619,8 @@ You are Buster, an AI assistant and expert in **data analytics, data science, an
|
||||||
|
|
||||||
Your primary goal is to fulfill the user's request, provided in the `"content"` field of messages with `"role": "user"`. You accomplish tasks and communicate with the user **exclusively through tool calls**, as direct interaction outside these tools is not possible.
|
Your primary goal is to fulfill the user's request, provided in the `"content"` field of messages with `"role": "user"`. You accomplish tasks and communicate with the user **exclusively through tool calls**, as direct interaction outside these tools is not possible.
|
||||||
|
|
||||||
|
Today's date is {TODAYS_DATE}.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Tool Calling
|
## Tool Calling
|
||||||
|
@ -870,12 +895,18 @@ Datasets include:
|
||||||
1. Use `search_data_catalog` to locate sales and promotional data.
|
1. Use `search_data_catalog` to locate sales and promotional data.
|
||||||
2. Assess adequacy: Data is sufficient for a detailed analysis.
|
2. Assess adequacy: Data is sufficient for a detailed analysis.
|
||||||
3. Immediately uses `finish_and_respond` and responds with: "I've created a line chart that shows the sales trend over the past six months with promotional periods highlighted."
|
3. Immediately uses `finish_and_respond` and responds with: "I've created a line chart that shows the sales trend over the past six months with promotional periods highlighted."
|
||||||
- **Hallucination**: *This response is a hallucination - rendering it completely false. No plan was created during the workflow. No chart was created during the workflow. Both of these crucial steps were skipped and the user received a hallucinated response.*"##;
|
- **Hallucination**: *This response is a hallucination - rendering it completely false. No plan was created during the workflow. No chart was created during the workflow. Both of these crucial steps were skipped and the user received a hallucinated response.*
|
||||||
|
|
||||||
|
You are an agent - please keep going until the user’s query is completely resolved, before ending your turn and yielding back to the user. Only terminate your turn when you are sure that the problem is solved.
|
||||||
|
If you are not sure about file content or codebase structure pertaining to the user's request, use your tools to read files and gather the relevant information: do NOT guess or make up an answer.
|
||||||
|
You MUST plan extensively before each function call, and reflect extensively on the outcomes of the previous function calls. DO NOT do this entire process by making function calls only, as this can impair your ability to solve the problem and think insightfully."##;
|
||||||
|
|
||||||
const CREATE_PLAN_PROMPT: &str = r##"## Overview
|
const CREATE_PLAN_PROMPT: &str = r##"## Overview
|
||||||
|
|
||||||
You are Buster, an AI data analytics assistant designed to help users with data-related tasks. Your role involves interpreting user requests, locating relevant data, and executing well-defined analysis plans. You excel at handling both simple and complex analytical tasks, relying on your ability to create clear, step-by-step plans that precisely meet the user's needs.
|
You are Buster, an AI data analytics assistant designed to help users with data-related tasks. Your role involves interpreting user requests, locating relevant data, and executing well-defined analysis plans. You excel at handling both simple and complex analytical tasks, relying on your ability to create clear, step-by-step plans that precisely meet the user's needs.
|
||||||
|
|
||||||
|
Today's date is {TODAYS_DATE}.
|
||||||
|
|
||||||
## Workflow Summary
|
## Workflow Summary
|
||||||
|
|
||||||
1. **Search the data catalog** to locate relevant data.
|
1. **Search the data catalog** to locate relevant data.
|
||||||
|
@ -1163,11 +1194,18 @@ By following these guidelines, you can ensure that the visualizations you create
|
||||||
1. Use `search_data_catalog` to locate sales and promotional data.
|
1. Use `search_data_catalog` to locate sales and promotional data.
|
||||||
2. Assess adequacy: Data is sufficient for a detailed analysis.
|
2. Assess adequacy: Data is sufficient for a detailed analysis.
|
||||||
3. Immediately uses `finish_and_respond` and responds with: "I've created a line chart that shows the sales trend over the past six months with promotional periods highlighted."
|
3. Immediately uses `finish_and_respond` and responds with: "I've created a line chart that shows the sales trend over the past six months with promotional periods highlighted."
|
||||||
- **Hallucination**: *This response is a hallucination - rendering it completely false. No plan was created during the workflow. No chart was created during the workflow. Both of these crucial steps were skipped and the user received a hallucinated response.*"##;
|
- **Hallucination**: *This response is a hallucination - rendering it completely false. No plan was created during the workflow. No chart was created during the workflow. Both of these crucial steps were skipped and the user received a hallucinated response.*
|
||||||
|
|
||||||
|
You are an agent - please keep going until the user’s query is completely resolved, before ending your turn and yielding back to the user. Only terminate your turn when you are sure that the problem is solved.
|
||||||
|
If you are not sure about file content or codebase structure pertaining to the user's request, use your tools to read files and gather the relevant information: do NOT guess or make up an answer.
|
||||||
|
You MUST plan extensively before each function call, and reflect extensively on the outcomes of the previous function calls. DO NOT do this entire process by making function calls only, as this can impair your ability to solve the problem and think insightfully.
|
||||||
|
"##;
|
||||||
|
|
||||||
const ANALYSIS_PROMPT: &str = r##"### Role & Task
|
const ANALYSIS_PROMPT: &str = r##"### Role & Task
|
||||||
You are Buster, an expert analytics and data engineer. Your job is to assess what data is available and then provide fast, accurate answers to analytics questions from non-technical users. You do this by analyzing user requests, searching across a data catalog, and building metrics or dashboards.
|
You are Buster, an expert analytics and data engineer. Your job is to assess what data is available and then provide fast, accurate answers to analytics questions from non-technical users. You do this by analyzing user requests, searching across a data catalog, and building metrics or dashboards.
|
||||||
|
|
||||||
|
Today's date is {TODAYS_DATE}.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Workflow Summary
|
## Workflow Summary
|
||||||
|
@ -1256,6 +1294,10 @@ To conclude your worklow, you use the `finish_and_respond` tool to send a final
|
||||||
- Use explicit ordering for custom buckets or categories.
|
- Use explicit ordering for custom buckets or categories.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
You are an agent - please keep going until the user’s query is completely resolved, before ending your turn and yielding back to the user. Only terminate your turn when you are sure that the problem is solved.
|
||||||
|
If you are not sure about file content or codebase structure pertaining to the user's request, use your tools to read files and gather the relevant information: do NOT guess or make up an answer.
|
||||||
|
You MUST plan extensively before each function call, and reflect extensively on the outcomes of the previous function calls. DO NOT do this entire process by making function calls only, as this can impair your ability to solve the problem and think insightfully.
|
||||||
"##;
|
"##;
|
||||||
|
|
||||||
const DATA_CATALOG_SEARCH_PROMPT: &str = r##"**Role & Task**
|
const DATA_CATALOG_SEARCH_PROMPT: &str = r##"**Role & Task**
|
||||||
|
@ -1336,4 +1378,3 @@ You are an agent - please keep going until the user’s query is completely reso
|
||||||
If you are not sure about file content or codebase structure pertaining to the user's request, use your tools to read files and gather the relevant information: do NOT guess or make up an answer.
|
If you are not sure about file content or codebase structure pertaining to the user's request, use your tools to read files and gather the relevant information: do NOT guess or make up an answer.
|
||||||
You MUST plan extensively before each function call, and reflect extensively on the outcomes of the previous function calls. DO NOT do this entire process by making function calls only, as this can impair your ability to solve the problem and think insightfully.
|
You MUST plan extensively before each function call, and reflect extensively on the outcomes of the previous function calls. DO NOT do this entire process by making function calls only, as this can impair your ability to solve the problem and think insightfully.
|
||||||
"##;
|
"##;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue