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 {
|
async fn get_schema(&self) -> Value {
|
||||||
serde_json::json!({
|
serde_json::json!({
|
||||||
"name": self.get_name(),
|
"name": self.get_name(),
|
||||||
"strict": false,
|
"strict": true,
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": ["files"],
|
"required": ["files"],
|
||||||
|
@ -377,7 +377,7 @@ impl ToolExecutor for CreateDashboardFilesTool {
|
||||||
"items": {
|
"items": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": ["name", "yml_content"],
|
"required": ["name", "yml_content"],
|
||||||
"strict": false,
|
"strict": true,
|
||||||
"properties": {
|
"properties": {
|
||||||
"name": {
|
"name": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
|
|
@ -308,7 +308,7 @@ impl ToolExecutor for CreateMetricFilesTool {
|
||||||
serde_json::json!({
|
serde_json::json!({
|
||||||
"name": self.get_name(),
|
"name": self.get_name(),
|
||||||
"description": get_create_metrics_description().await,
|
"description": get_create_metrics_description().await,
|
||||||
"strict": false,
|
"strict": true,
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": ["files"],
|
"required": ["files"],
|
||||||
|
@ -318,7 +318,7 @@ impl ToolExecutor for CreateMetricFilesTool {
|
||||||
"items": {
|
"items": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": ["name", "yml_content"],
|
"required": ["name", "yml_content"],
|
||||||
"strict": false,
|
"strict": true,
|
||||||
"properties": {
|
"properties": {
|
||||||
"name": {
|
"name": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
|
|
@ -382,7 +382,7 @@ impl ToolExecutor for ModifyDashboardFilesTool {
|
||||||
serde_json::json!({
|
serde_json::json!({
|
||||||
"name": self.get_name(),
|
"name": self.get_name(),
|
||||||
"description": get_modify_dashboards_description().await,
|
"description": get_modify_dashboards_description().await,
|
||||||
"strict": false,
|
"strict": true,
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": ["files"],
|
"required": ["files"],
|
||||||
|
@ -393,7 +393,7 @@ impl ToolExecutor for ModifyDashboardFilesTool {
|
||||||
"items": {
|
"items": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": ["id", "yml_content"],
|
"required": ["id", "yml_content"],
|
||||||
"strict": false,
|
"strict": true,
|
||||||
"properties": {
|
"properties": {
|
||||||
"id": {
|
"id": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
|
|
@ -486,7 +486,7 @@ impl ToolExecutor for ModifyMetricFilesTool {
|
||||||
serde_json::json!({
|
serde_json::json!({
|
||||||
"name": self.get_name(),
|
"name": self.get_name(),
|
||||||
"description": get_modify_metrics_description().await,
|
"description": get_modify_metrics_description().await,
|
||||||
"strict": false,
|
"strict": true,
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": ["files"],
|
"required": ["files"],
|
||||||
|
|
|
@ -87,7 +87,7 @@ impl ToolExecutor for CreatePlanInvestigative {
|
||||||
serde_json::json!({
|
serde_json::json!({
|
||||||
"name": self.get_name(),
|
"name": self.get_name(),
|
||||||
"description": get_create_plan_investigative_description().await,
|
"description": get_create_plan_investigative_description().await,
|
||||||
"strict": false,
|
"strict": true,
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
|
|
|
@ -84,7 +84,7 @@ impl ToolExecutor for CreatePlanStraightforward {
|
||||||
serde_json::json!({
|
serde_json::json!({
|
||||||
"name": self.get_name(),
|
"name": self.get_name(),
|
||||||
"description": get_create_plan_straightforward_description().await,
|
"description": get_create_plan_straightforward_description().await,
|
||||||
"strict": false,
|
"strict": true,
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
use std::env;
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||||
pub struct ChatCompletionRequest {
|
pub struct ChatCompletionRequest {
|
||||||
|
@ -50,7 +51,7 @@ pub struct ChatCompletionRequest {
|
||||||
pub parallel_tool_calls: Option<bool>,
|
pub parallel_tool_calls: Option<bool>,
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub user: Option<String>,
|
pub user: Option<String>,
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "should_skip_metadata")]
|
||||||
pub metadata: Option<Metadata>,
|
pub metadata: Option<Metadata>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1065,3 +1066,17 @@ mod tests {
|
||||||
assert_eq!(deserialized_resp.usage.total_tokens, 99);
|
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