mirror of https://github.com/buster-so/buster.git
strict mode and ignore metadata func
This commit is contained in:
parent
f358c451bb
commit
9cc01639c5
|
@ -367,7 +367,7 @@ impl ToolExecutor for CreateDashboardFilesTool {
|
|||
async fn get_schema(&self) -> Value {
|
||||
serde_json::json!({
|
||||
"name": self.get_name(),
|
||||
"strict": false,
|
||||
"strict": true,
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"required": ["files"],
|
||||
|
@ -377,7 +377,7 @@ impl ToolExecutor for CreateDashboardFilesTool {
|
|||
"items": {
|
||||
"type": "object",
|
||||
"required": ["name", "yml_content"],
|
||||
"strict": false,
|
||||
"strict": true,
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string",
|
||||
|
|
|
@ -308,7 +308,7 @@ impl ToolExecutor for CreateMetricFilesTool {
|
|||
serde_json::json!({
|
||||
"name": self.get_name(),
|
||||
"description": get_create_metrics_description().await,
|
||||
"strict": false,
|
||||
"strict": true,
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"required": ["files"],
|
||||
|
@ -318,7 +318,7 @@ impl ToolExecutor for CreateMetricFilesTool {
|
|||
"items": {
|
||||
"type": "object",
|
||||
"required": ["name", "yml_content"],
|
||||
"strict": false,
|
||||
"strict": true,
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string",
|
||||
|
|
|
@ -382,7 +382,7 @@ impl ToolExecutor for ModifyDashboardFilesTool {
|
|||
serde_json::json!({
|
||||
"name": self.get_name(),
|
||||
"description": get_modify_dashboards_description().await,
|
||||
"strict": false,
|
||||
"strict": true,
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"required": ["files"],
|
||||
|
@ -393,7 +393,7 @@ impl ToolExecutor for ModifyDashboardFilesTool {
|
|||
"items": {
|
||||
"type": "object",
|
||||
"required": ["id", "yml_content"],
|
||||
"strict": false,
|
||||
"strict": true,
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string",
|
||||
|
|
|
@ -486,7 +486,7 @@ impl ToolExecutor for ModifyMetricFilesTool {
|
|||
serde_json::json!({
|
||||
"name": self.get_name(),
|
||||
"description": get_modify_metrics_description().await,
|
||||
"strict": false,
|
||||
"strict": true,
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"required": ["files"],
|
||||
|
|
|
@ -87,7 +87,7 @@ impl ToolExecutor for CreatePlanInvestigative {
|
|||
serde_json::json!({
|
||||
"name": self.get_name(),
|
||||
"description": get_create_plan_investigative_description().await,
|
||||
"strict": false,
|
||||
"strict": true,
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
|
|
|
@ -84,7 +84,7 @@ impl ToolExecutor for CreatePlanStraightforward {
|
|||
serde_json::json!({
|
||||
"name": self.get_name(),
|
||||
"description": get_create_plan_straightforward_description().await,
|
||||
"strict": false,
|
||||
"strict": true,
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::Value;
|
||||
use std::collections::HashMap;
|
||||
use std::env;
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct ChatCompletionRequest {
|
||||
|
@ -50,7 +51,7 @@ pub struct ChatCompletionRequest {
|
|||
pub parallel_tool_calls: Option<bool>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub user: Option<String>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
#[serde(skip_serializing_if = "should_skip_metadata")]
|
||||
pub metadata: Option<Metadata>,
|
||||
}
|
||||
|
||||
|
@ -1065,3 +1066,17 @@ mod tests {
|
|||
assert_eq!(deserialized_resp.usage.total_tokens, 99);
|
||||
}
|
||||
}
|
||||
|
||||
fn should_skip_metadata(metadata: &Option<Metadata>) -> bool {
|
||||
let env_var_condition_met = match env::var("LLM_BASE_URL") {
|
||||
Ok(val) => val == "https://api.openai.com/v1",
|
||||
Err(_) => false, // If env var is not set or any error, condition is not met
|
||||
};
|
||||
|
||||
if env_var_condition_met {
|
||||
return true; // If env var condition is met, always skip
|
||||
}
|
||||
|
||||
// If env var condition is not met, then skip only if metadata is None
|
||||
metadata.is_none()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue