Skip to content

Commit

Permalink
feature: disable analytics flag
Browse files Browse the repository at this point in the history
  • Loading branch information
densumesh authored and skeptrunedev committed Dec 8, 2024
1 parent 14d4a59 commit 325d2ce
Show file tree
Hide file tree
Showing 7 changed files with 334 additions and 283 deletions.
5 changes: 5 additions & 0 deletions clients/ts-sdk/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -9306,6 +9306,11 @@
"description": "The BM25 K parameter",
"nullable": true
},
"DISABLE_ANALYTICS": {
"type": "boolean",
"description": "Whether to disable analytics",
"nullable": true
},
"DISTANCE_METRIC": {
"allOf": [
{
Expand Down
4 changes: 4 additions & 0 deletions clients/ts-sdk/src/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,10 @@ export type DatasetConfigurationDTO = {
* The BM25 K parameter
*/
BM25_K?: (number) | null;
/**
* Whether to disable analytics
*/
DISABLE_ANALYTICS?: (boolean) | null;
DISTANCE_METRIC?: ((DistanceMetric) | null);
/**
* The base URL for the embedding API
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,29 @@ export const GeneralServerSettings = (props: {
</label>
</div>

<div class="col-span-4 flex items-center space-x-2 sm:col-span-2">
<input
type="checkbox"
name="disableAnalytics"
id="disableAnalytics"
checked={!!props.serverConfig().DISABLE_ANALYTICS}
onInput={(e) =>
props.setServerConfig((prev) => {
return {
...prev,
DISABLE_ANALYTICS: e.currentTarget.checked,
};
})
}
/>
<label
for="disableAnalytics"
class="block text-sm font-medium leading-6"
>
Disable Analytics
</label>
</div>

<div class="col-span-4 flex items-center space-x-2 sm:col-span-2">
<input
type="checkbox"
Expand Down
19 changes: 17 additions & 2 deletions server/src/data/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2379,6 +2379,7 @@ pub struct DatasetConfiguration {
pub SYSTEM_PROMPT: String,
pub MAX_LIMIT: u64,
pub PUBLIC_DATASET: PublicDatasetOptions,
pub DISABLE_ANALYTICS: bool,
}

#[derive(Debug, Serialize, Deserialize, Clone, ToSchema)]
Expand Down Expand Up @@ -2488,6 +2489,8 @@ pub struct DatasetConfigurationDTO {
pub MAX_LIMIT: Option<u64>,
/// Config for making the dataset public
pub PUBLIC_DATASET: Option<PublicDatasetOptions>,
/// Whether to disable analytics
pub DISABLE_ANALYTICS: Option<bool>,
}

impl From<DatasetConfigurationDTO> for DatasetConfiguration {
Expand Down Expand Up @@ -2530,6 +2533,7 @@ impl From<DatasetConfigurationDTO> for DatasetConfiguration {
extra_params: dto.PUBLIC_DATASET.map(|public_dataset| public_dataset.extra_params)
.unwrap_or_default()
},
DISABLE_ANALYTICS: dto.DISABLE_ANALYTICS.unwrap_or(false),
}
}
}
Expand Down Expand Up @@ -2578,6 +2582,7 @@ impl From<DatasetConfiguration> for DatasetConfigurationDTO {
}
}),
}),
DISABLE_ANALYTICS: Some(config.DISABLE_ANALYTICS),
}
}
}
Expand Down Expand Up @@ -2621,6 +2626,7 @@ impl Default for DatasetConfiguration {
api_key: Some("".to_string()),
extra_params: None,
},
DISABLE_ANALYTICS: false,
}
}
}
Expand Down Expand Up @@ -2901,7 +2907,12 @@ impl DatasetConfiguration {
enabled: configuration_json.pointer("/PUBLIC_DATASET/enabled").unwrap_or(&json!(false)).as_bool().unwrap_or(false),
api_key: Some(configuration_json.pointer("/PUBLIC_DATASET/api_key").unwrap_or(&json!("")).as_str().unwrap_or("").to_string()),
extra_params
}
},
DISABLE_ANALYTICS: configuration
.get("DISABLE_ANALYTICS")
.unwrap_or(&json!(false))
.as_bool()
.unwrap_or(false),
}
}

Expand Down Expand Up @@ -2943,7 +2954,8 @@ impl DatasetConfiguration {
"enabled": self.PUBLIC_DATASET.enabled,
"api_key": self.PUBLIC_DATASET.api_key,
"extra_params": extra_params_json
}
},
"DISABLE_ANALYTICS": self.DISABLE_ANALYTICS,
})
}
}
Expand Down Expand Up @@ -3154,6 +3166,9 @@ impl DatasetConfigurationDTO {
.or(page_parameters_curr.open_graph_metadata),
}),
},
DISABLE_ANALYTICS: self
.DISABLE_ANALYTICS
.unwrap_or(curr_dataset_config.DISABLE_ANALYTICS),
}
}
}
Expand Down
Loading

0 comments on commit 325d2ce

Please sign in to comment.