Skip to content

Commit f43e2e5

Browse files
committed
RDBC-926 Refactor AI agent operations: extract hasNoSampleObjectAndSchema for cleaner validation, streamline response parsing logic, and remove unused truncate configuration.
1 parent bd5d8c4 commit f43e2e5

File tree

2 files changed

+3
-15
lines changed

2 files changed

+3
-15
lines changed

src/Documents/Operations/AI/Agents/AddOrUpdateAiAgentOperation.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export class AddOrUpdateAiAgentOperation implements IMaintenanceOperation<AiAgen
2525
throwError("InvalidArgumentException", "configuration cannot be null or undefined.");
2626
}
2727

28-
if (!configuration.outputSchema && !configuration.sampleObject && !sampleObject) {
28+
if (hasNoSampleObjectAndSchema(configuration) && !sampleObject) {
2929
throwError("InvalidArgumentException", "Please provide a non-empty value for either outputSchema or sampleObject.");
3030
}
3131
this._configuration = configuration;
@@ -93,12 +93,7 @@ class AddOrUpdateAiAgentCommand extends RavenCommand<AiAgentConfigurationResult>
9393
if (!bodyStream) {
9494
this._throwInvalidResponse();
9595
}
96-
let body = "";
97-
const data = await this._defaultPipeline<any>(_ => body = _).process(bodyStream);
98-
this.result = {
99-
identifier: data?.Identifier ?? data?.identifier,
100-
raftCommandIndex: data?.RaftCommandIndex ?? data?.raftCommandIndex
101-
} as AiAgentConfigurationResult;
102-
return body;
96+
97+
return this._parseResponseDefaultAsync(bodyStream);
10398
}
10499
}
Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
export interface AiAgentChatTrimmingConfiguration {
22
tokens?: AiAgentSummarizationByTokens;
3-
// Note: truncate is internal in C#, we keep it optional for completeness
4-
truncate?: AiAgentTruncateChat;
53
history?: AiAgentHistoryConfiguration;
64
}
75

@@ -13,11 +11,6 @@ export interface AiAgentSummarizationByTokens {
1311
maxTokensAfterSummarization?: number;
1412
}
1513

16-
export interface AiAgentTruncateChat {
17-
messagesLengthBeforeTruncate?: number; // default 500 in C#
18-
messagesLengthAfterTruncate?: number; // default 250 in C#
19-
}
20-
2114
export interface AiAgentHistoryConfiguration {
2215
historyExpirationInSec?: number;
2316
}

0 commit comments

Comments
 (0)