Skip to content

Commit fa256ac

Browse files
committed
RDBC-944 Replace undefined checks with null checks across AI settings validation logic for consistency and improved readability.
1 parent 73a8061 commit fa256ac

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

src/Documents/Operations/AI/ConnectionStrings/Settings/AzureOpenAiSettings.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export class AzureOpenAiSettings extends OpenAiBaseSettings {
2222
public validate(errors: string[]): void {
2323
super.validate(errors);
2424

25-
if (StringUtil.isNullOrEmpty(this.deploymentName.trim())) {
25+
if (StringUtil.isNullOrEmpty(this.deploymentName?.trim())) {
2626
errors.push("Value for 'deploymentName' field cannot be empty.");
2727
}
2828
}

src/Documents/Operations/AI/ConnectionStrings/Settings/GoogleSettings.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export class GoogleSettings extends AbstractAiSettings {
5555
errors.push("Value of 'apiKey' field cannot be empty.");
5656
}
5757

58-
if (this.dimensions !== undefined && this.dimensions <= 0) {
58+
if (this.dimensions != null && this.dimensions <= 0) {
5959
errors.push("Value of 'dimensions' field must be positive.");
6060
}
6161
}

src/Documents/Operations/AI/ConnectionStrings/Settings/OllamaSettings.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export class OllamaSettings extends AbstractAiSettings {
4747
errors.push("Value of 'model' field cannot be empty.");
4848
}
4949

50-
if (this.temperature !== undefined && this.temperature < 0) {
50+
if (this.temperature != null && this.temperature < 0) {
5151
errors.push("Value of 'temperature' field must be non-negative.");
5252
}
5353
}
@@ -71,12 +71,12 @@ export class OllamaSettings extends AbstractAiSettings {
7171
differences |= AiSettingsCompareDifferences.EndpointConfiguration;
7272
}
7373

74-
const hasTemperature = this.temperature !== undefined;
75-
const otherHasTemperature = other.temperature !== undefined;
74+
const hasTemperature = this.temperature != null;
75+
const otherHasTemperature = other.temperature != null;
7676

7777
if (hasTemperature !== otherHasTemperature ||
7878
(hasTemperature && otherHasTemperature &&
79-
Math.abs(this.temperature! - other.temperature!) > 0.0001)) {
79+
Math.abs(this.temperature - other.temperature) > 0.0001)) {
8080
differences |= AiSettingsCompareDifferences.EndpointConfiguration;
8181
}
8282

src/Documents/Operations/AI/ConnectionStrings/Settings/OpenAiBaseSettings.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,11 @@ export abstract class OpenAiBaseSettings extends AbstractAiSettings implements I
7171
errors.push("Value of 'model' field cannot be empty.");
7272
}
7373

74-
if (this.dimensions !== undefined && this.dimensions <= 0) {
74+
if (this.dimensions != null && this.dimensions <= 0) {
7575
errors.push("Value of 'dimensions' field must be positive.");
7676
}
7777

78-
if (this.temperature !== undefined && this.temperature < 0) {
78+
if (this.temperature != null && this.temperature < 0) {
7979
errors.push("Value of 'temperature' field must be non-negative.");
8080
}
8181
}
@@ -103,12 +103,12 @@ export abstract class OpenAiBaseSettings extends AbstractAiSettings implements I
103103
differences |= AiSettingsCompareDifferences.EmbeddingDimensions;
104104
}
105105

106-
const hasTemperature = this.temperature !== undefined;
107-
const otherHasTemperature = other.temperature !== undefined;
106+
const hasTemperature = this.temperature != null;
107+
const otherHasTemperature = other.temperature != null;
108108

109109
if (hasTemperature !== otherHasTemperature ||
110110
(hasTemperature && otherHasTemperature &&
111-
Math.abs(this.temperature! - other.temperature!) > 0.0001)) {
111+
Math.abs(this.temperature - other.temperature) > 0.0001)) {
112112
differences |= AiSettingsCompareDifferences.EndpointConfiguration;
113113
}
114114

0 commit comments

Comments
 (0)