mirror of https://github.com/buster-so/buster.git
Merge branch 'staging' into dal/simplify-deploy-endpoint
This commit is contained in:
commit
08ecb44de1
|
@ -1227,6 +1227,7 @@ async fn search_for_relevant_terms(
|
||||||
terms_search
|
terms_search
|
||||||
where
|
where
|
||||||
fts @@ websearch_to_tsquery('{prompt}')
|
fts @@ websearch_to_tsquery('{prompt}')
|
||||||
|
and organization_id = '{organization_id}'
|
||||||
order by rank_ix
|
order by rank_ix
|
||||||
limit least(10, 30) * 2
|
limit least(10, 30) * 2
|
||||||
),
|
),
|
||||||
|
@ -1236,6 +1237,7 @@ semantic as (
|
||||||
row_number() over (order by embedding <#> '{prompt_embedding}') as rank_ix
|
row_number() over (order by embedding <#> '{prompt_embedding}') as rank_ix
|
||||||
from
|
from
|
||||||
terms_search
|
terms_search
|
||||||
|
where organization_id = '{organization_id}'
|
||||||
order by rank_ix
|
order by rank_ix
|
||||||
limit least(10, 30) * 2
|
limit least(10, 30) * 2
|
||||||
)
|
)
|
||||||
|
|
|
@ -82,6 +82,7 @@ pub async fn failed_to_fix_sql_agent(
|
||||||
stream: Some(options.output_sender),
|
stream: Some(options.output_sender),
|
||||||
stream_name: Some("failed_to_fix_sql".to_string()),
|
stream_name: Some("failed_to_fix_sql".to_string()),
|
||||||
prompt_name: "failed_to_fix_sql".to_string(),
|
prompt_name: "failed_to_fix_sql".to_string(),
|
||||||
|
json_mode: true,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -93,19 +94,24 @@ pub async fn failed_to_fix_sql_agent(
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Combine master response with first part of response
|
let sql = match response.get("sql") {
|
||||||
|
Some(sql) => sql.as_str().unwrap_or_default().to_string(),
|
||||||
|
None => "".to_string(),
|
||||||
|
};
|
||||||
|
|
||||||
|
// Combine SQL with first part of response
|
||||||
let combined_response = match (
|
let combined_response = match (
|
||||||
response.as_str(),
|
sql.as_str(),
|
||||||
options.outputs.get("first_part_of_response"),
|
options.outputs.get("first_part_of_response"),
|
||||||
) {
|
) {
|
||||||
(Some(master_str), Some(first_part)) => {
|
(sql_str, Some(first_part)) if !sql_str.is_empty() => {
|
||||||
if let Some(first_part_str) = first_part.as_str() {
|
if let Some(first_part_str) = first_part.as_str() {
|
||||||
Value::String(format!("{}\n\n{}", first_part_str, master_str))
|
Value::String(format!("{}\n\n{}", first_part_str, sql_str))
|
||||||
} else {
|
} else {
|
||||||
response
|
Value::String(sql)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => response,
|
_ => Value::String(sql),
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(combined_response)
|
Ok(combined_response)
|
||||||
|
|
|
@ -8,11 +8,20 @@ You should talk about how you tried to fix the SQL query three times, and that y
|
||||||
|
|
||||||
At the end make sure to apologize to the user
|
At the end make sure to apologize to the user
|
||||||
|
|
||||||
|
PLEASE OUTPUT THE SQL QUERY IN THE FOLLOWING JSON FORMAT:
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
\"sql\": \"SELECT...\"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
### GENERAL GUIDELINES
|
### GENERAL GUIDELINES
|
||||||
- Keep your response under 50 words
|
- Keep your response under 50 words
|
||||||
- Do not output the failed SQL query in your response
|
- Do not output the failed SQL query in your response
|
||||||
- Keep this response fairly non-technical
|
- Keep this response fairly non-technical
|
||||||
- escape columns, datasets, tables, errors, etc. with backticks.".to_string()
|
- escape columns, datasets, tables, errors, etc. with backticks.
|
||||||
|
- You must output the sql query in the format specified above.
|
||||||
|
".to_string()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn failed_to_fix_sql_user_prompt(
|
pub fn failed_to_fix_sql_user_prompt(
|
||||||
|
@ -44,5 +53,7 @@ pub fn failed_to_fix_sql_user_prompt(
|
||||||
message.push_str(error);
|
message.push_str(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message.push_str("\n\nPlease output the SQL query in the format specified above. (```sql ... ```)");
|
||||||
|
|
||||||
message
|
message
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ Your task is to pick all the datasets required to answer the user question/reque
|
||||||
- Feel free to select multiple datasets that can be joined together to provide more complete answers
|
- Feel free to select multiple datasets that can be joined together to provide more complete answers
|
||||||
- If the user requests advanced analysis like predictions, forecasts, correlation, impact analysis, etc., identify all datasets that could be combined for the analysis
|
- If the user requests advanced analysis like predictions, forecasts, correlation, impact analysis, etc., identify all datasets that could be combined for the analysis
|
||||||
- Consider relationships between datasets and how they can be joined to provide comprehensive answers
|
- Consider relationships between datasets and how they can be joined to provide comprehensive answers
|
||||||
|
- Multiple dataset can be selected even while one completely answers the user request.
|
||||||
"#,
|
"#,
|
||||||
datasets
|
datasets
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue