weave-typescript 0.27.0 → 0.29.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2613 @@
1
+ "use strict";
2
+ // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
3
+ // versions:
4
+ // protoc-gen-ts_proto v2.11.6
5
+ // protoc unknown
6
+ // source: weaveapi/retrieval/v1/retrieval.proto
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.ExplainRetrievalResponse = exports.SubQueryResult = exports.ExplainRetrievalRequest = exports.SearchDocumentsResponse = exports.SearchDocumentsRequest = exports.RetrieveResponse = exports.RetrieveRequest = exports.RetrievedDocument = exports.DocumentSearchSnippet = exports.DocumentSearchFilters = exports.RetrievedThread = exports.Citation = exports.RetrievalPlan = exports.RerankerConfig = exports.SubQuery = exports.RetrievalConstraints = exports.IntentSignal = exports.KnowledgeTypeBias = exports.SubQueryStrategy = exports.RetrievalTimeScope = exports.IntentType = exports.protobufPackage = void 0;
9
+ exports.intentTypeFromJSON = intentTypeFromJSON;
10
+ exports.intentTypeToJSON = intentTypeToJSON;
11
+ exports.retrievalTimeScopeFromJSON = retrievalTimeScopeFromJSON;
12
+ exports.retrievalTimeScopeToJSON = retrievalTimeScopeToJSON;
13
+ exports.subQueryStrategyFromJSON = subQueryStrategyFromJSON;
14
+ exports.subQueryStrategyToJSON = subQueryStrategyToJSON;
15
+ /* eslint-disable */
16
+ const wire_1 = require("@bufbuild/protobuf/wire");
17
+ const struct_pb_1 = require("../../../google/protobuf/struct.pb");
18
+ const timestamp_pb_1 = require("../../../google/protobuf/timestamp.pb");
19
+ const ingestion_pb_1 = require("../../ingestion/v1/ingestion.pb");
20
+ exports.protobufPackage = "weaveapi.retrieval.v1";
21
+ var IntentType;
22
+ (function (IntentType) {
23
+ IntentType[IntentType["INTENT_TYPE_UNSPECIFIED"] = 0] = "INTENT_TYPE_UNSPECIFIED";
24
+ IntentType[IntentType["INTENT_TYPE_FACTUAL_LOOKUP"] = 1] = "INTENT_TYPE_FACTUAL_LOOKUP";
25
+ IntentType[IntentType["INTENT_TYPE_COMPARISON"] = 2] = "INTENT_TYPE_COMPARISON";
26
+ IntentType[IntentType["INTENT_TYPE_TEMPORAL_QUERY"] = 3] = "INTENT_TYPE_TEMPORAL_QUERY";
27
+ IntentType[IntentType["INTENT_TYPE_PROCEDURAL"] = 4] = "INTENT_TYPE_PROCEDURAL";
28
+ IntentType[IntentType["INTENT_TYPE_ENTITY_EXPLORATION"] = 5] = "INTENT_TYPE_ENTITY_EXPLORATION";
29
+ IntentType[IntentType["INTENT_TYPE_CONSTRAINT_CHECK"] = 6] = "INTENT_TYPE_CONSTRAINT_CHECK";
30
+ IntentType[IntentType["INTENT_TYPE_MULTI_SOURCE_SYNTHESIS"] = 7] = "INTENT_TYPE_MULTI_SOURCE_SYNTHESIS";
31
+ IntentType[IntentType["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
32
+ })(IntentType || (exports.IntentType = IntentType = {}));
33
+ function intentTypeFromJSON(object) {
34
+ switch (object) {
35
+ case 0:
36
+ case "INTENT_TYPE_UNSPECIFIED":
37
+ return IntentType.INTENT_TYPE_UNSPECIFIED;
38
+ case 1:
39
+ case "INTENT_TYPE_FACTUAL_LOOKUP":
40
+ return IntentType.INTENT_TYPE_FACTUAL_LOOKUP;
41
+ case 2:
42
+ case "INTENT_TYPE_COMPARISON":
43
+ return IntentType.INTENT_TYPE_COMPARISON;
44
+ case 3:
45
+ case "INTENT_TYPE_TEMPORAL_QUERY":
46
+ return IntentType.INTENT_TYPE_TEMPORAL_QUERY;
47
+ case 4:
48
+ case "INTENT_TYPE_PROCEDURAL":
49
+ return IntentType.INTENT_TYPE_PROCEDURAL;
50
+ case 5:
51
+ case "INTENT_TYPE_ENTITY_EXPLORATION":
52
+ return IntentType.INTENT_TYPE_ENTITY_EXPLORATION;
53
+ case 6:
54
+ case "INTENT_TYPE_CONSTRAINT_CHECK":
55
+ return IntentType.INTENT_TYPE_CONSTRAINT_CHECK;
56
+ case 7:
57
+ case "INTENT_TYPE_MULTI_SOURCE_SYNTHESIS":
58
+ return IntentType.INTENT_TYPE_MULTI_SOURCE_SYNTHESIS;
59
+ case -1:
60
+ case "UNRECOGNIZED":
61
+ default:
62
+ return IntentType.UNRECOGNIZED;
63
+ }
64
+ }
65
+ function intentTypeToJSON(object) {
66
+ switch (object) {
67
+ case IntentType.INTENT_TYPE_UNSPECIFIED:
68
+ return "INTENT_TYPE_UNSPECIFIED";
69
+ case IntentType.INTENT_TYPE_FACTUAL_LOOKUP:
70
+ return "INTENT_TYPE_FACTUAL_LOOKUP";
71
+ case IntentType.INTENT_TYPE_COMPARISON:
72
+ return "INTENT_TYPE_COMPARISON";
73
+ case IntentType.INTENT_TYPE_TEMPORAL_QUERY:
74
+ return "INTENT_TYPE_TEMPORAL_QUERY";
75
+ case IntentType.INTENT_TYPE_PROCEDURAL:
76
+ return "INTENT_TYPE_PROCEDURAL";
77
+ case IntentType.INTENT_TYPE_ENTITY_EXPLORATION:
78
+ return "INTENT_TYPE_ENTITY_EXPLORATION";
79
+ case IntentType.INTENT_TYPE_CONSTRAINT_CHECK:
80
+ return "INTENT_TYPE_CONSTRAINT_CHECK";
81
+ case IntentType.INTENT_TYPE_MULTI_SOURCE_SYNTHESIS:
82
+ return "INTENT_TYPE_MULTI_SOURCE_SYNTHESIS";
83
+ case IntentType.UNRECOGNIZED:
84
+ default:
85
+ return "UNRECOGNIZED";
86
+ }
87
+ }
88
+ var RetrievalTimeScope;
89
+ (function (RetrievalTimeScope) {
90
+ RetrievalTimeScope[RetrievalTimeScope["RETRIEVAL_TIME_SCOPE_UNSPECIFIED"] = 0] = "RETRIEVAL_TIME_SCOPE_UNSPECIFIED";
91
+ RetrievalTimeScope[RetrievalTimeScope["RETRIEVAL_TIME_SCOPE_CURRENT"] = 1] = "RETRIEVAL_TIME_SCOPE_CURRENT";
92
+ RetrievalTimeScope[RetrievalTimeScope["RETRIEVAL_TIME_SCOPE_HISTORICAL"] = 2] = "RETRIEVAL_TIME_SCOPE_HISTORICAL";
93
+ RetrievalTimeScope[RetrievalTimeScope["RETRIEVAL_TIME_SCOPE_ALL"] = 3] = "RETRIEVAL_TIME_SCOPE_ALL";
94
+ RetrievalTimeScope[RetrievalTimeScope["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
95
+ })(RetrievalTimeScope || (exports.RetrievalTimeScope = RetrievalTimeScope = {}));
96
+ function retrievalTimeScopeFromJSON(object) {
97
+ switch (object) {
98
+ case 0:
99
+ case "RETRIEVAL_TIME_SCOPE_UNSPECIFIED":
100
+ return RetrievalTimeScope.RETRIEVAL_TIME_SCOPE_UNSPECIFIED;
101
+ case 1:
102
+ case "RETRIEVAL_TIME_SCOPE_CURRENT":
103
+ return RetrievalTimeScope.RETRIEVAL_TIME_SCOPE_CURRENT;
104
+ case 2:
105
+ case "RETRIEVAL_TIME_SCOPE_HISTORICAL":
106
+ return RetrievalTimeScope.RETRIEVAL_TIME_SCOPE_HISTORICAL;
107
+ case 3:
108
+ case "RETRIEVAL_TIME_SCOPE_ALL":
109
+ return RetrievalTimeScope.RETRIEVAL_TIME_SCOPE_ALL;
110
+ case -1:
111
+ case "UNRECOGNIZED":
112
+ default:
113
+ return RetrievalTimeScope.UNRECOGNIZED;
114
+ }
115
+ }
116
+ function retrievalTimeScopeToJSON(object) {
117
+ switch (object) {
118
+ case RetrievalTimeScope.RETRIEVAL_TIME_SCOPE_UNSPECIFIED:
119
+ return "RETRIEVAL_TIME_SCOPE_UNSPECIFIED";
120
+ case RetrievalTimeScope.RETRIEVAL_TIME_SCOPE_CURRENT:
121
+ return "RETRIEVAL_TIME_SCOPE_CURRENT";
122
+ case RetrievalTimeScope.RETRIEVAL_TIME_SCOPE_HISTORICAL:
123
+ return "RETRIEVAL_TIME_SCOPE_HISTORICAL";
124
+ case RetrievalTimeScope.RETRIEVAL_TIME_SCOPE_ALL:
125
+ return "RETRIEVAL_TIME_SCOPE_ALL";
126
+ case RetrievalTimeScope.UNRECOGNIZED:
127
+ default:
128
+ return "UNRECOGNIZED";
129
+ }
130
+ }
131
+ var SubQueryStrategy;
132
+ (function (SubQueryStrategy) {
133
+ SubQueryStrategy[SubQueryStrategy["SUB_QUERY_STRATEGY_UNSPECIFIED"] = 0] = "SUB_QUERY_STRATEGY_UNSPECIFIED";
134
+ SubQueryStrategy[SubQueryStrategy["SUB_QUERY_STRATEGY_CONCEPT_HIERARCHY"] = 1] = "SUB_QUERY_STRATEGY_CONCEPT_HIERARCHY";
135
+ SubQueryStrategy[SubQueryStrategy["SUB_QUERY_STRATEGY_SEMANTIC"] = 2] = "SUB_QUERY_STRATEGY_SEMANTIC";
136
+ SubQueryStrategy[SubQueryStrategy["SUB_QUERY_STRATEGY_ENTITY_GRAPH"] = 3] = "SUB_QUERY_STRATEGY_ENTITY_GRAPH";
137
+ SubQueryStrategy[SubQueryStrategy["SUB_QUERY_STRATEGY_FACET_FILTERED"] = 4] = "SUB_QUERY_STRATEGY_FACET_FILTERED";
138
+ SubQueryStrategy[SubQueryStrategy["SUB_QUERY_STRATEGY_TEMPORAL"] = 5] = "SUB_QUERY_STRATEGY_TEMPORAL";
139
+ SubQueryStrategy[SubQueryStrategy["SUB_QUERY_STRATEGY_HYBRID"] = 6] = "SUB_QUERY_STRATEGY_HYBRID";
140
+ SubQueryStrategy[SubQueryStrategy["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
141
+ })(SubQueryStrategy || (exports.SubQueryStrategy = SubQueryStrategy = {}));
142
+ function subQueryStrategyFromJSON(object) {
143
+ switch (object) {
144
+ case 0:
145
+ case "SUB_QUERY_STRATEGY_UNSPECIFIED":
146
+ return SubQueryStrategy.SUB_QUERY_STRATEGY_UNSPECIFIED;
147
+ case 1:
148
+ case "SUB_QUERY_STRATEGY_CONCEPT_HIERARCHY":
149
+ return SubQueryStrategy.SUB_QUERY_STRATEGY_CONCEPT_HIERARCHY;
150
+ case 2:
151
+ case "SUB_QUERY_STRATEGY_SEMANTIC":
152
+ return SubQueryStrategy.SUB_QUERY_STRATEGY_SEMANTIC;
153
+ case 3:
154
+ case "SUB_QUERY_STRATEGY_ENTITY_GRAPH":
155
+ return SubQueryStrategy.SUB_QUERY_STRATEGY_ENTITY_GRAPH;
156
+ case 4:
157
+ case "SUB_QUERY_STRATEGY_FACET_FILTERED":
158
+ return SubQueryStrategy.SUB_QUERY_STRATEGY_FACET_FILTERED;
159
+ case 5:
160
+ case "SUB_QUERY_STRATEGY_TEMPORAL":
161
+ return SubQueryStrategy.SUB_QUERY_STRATEGY_TEMPORAL;
162
+ case 6:
163
+ case "SUB_QUERY_STRATEGY_HYBRID":
164
+ return SubQueryStrategy.SUB_QUERY_STRATEGY_HYBRID;
165
+ case -1:
166
+ case "UNRECOGNIZED":
167
+ default:
168
+ return SubQueryStrategy.UNRECOGNIZED;
169
+ }
170
+ }
171
+ function subQueryStrategyToJSON(object) {
172
+ switch (object) {
173
+ case SubQueryStrategy.SUB_QUERY_STRATEGY_UNSPECIFIED:
174
+ return "SUB_QUERY_STRATEGY_UNSPECIFIED";
175
+ case SubQueryStrategy.SUB_QUERY_STRATEGY_CONCEPT_HIERARCHY:
176
+ return "SUB_QUERY_STRATEGY_CONCEPT_HIERARCHY";
177
+ case SubQueryStrategy.SUB_QUERY_STRATEGY_SEMANTIC:
178
+ return "SUB_QUERY_STRATEGY_SEMANTIC";
179
+ case SubQueryStrategy.SUB_QUERY_STRATEGY_ENTITY_GRAPH:
180
+ return "SUB_QUERY_STRATEGY_ENTITY_GRAPH";
181
+ case SubQueryStrategy.SUB_QUERY_STRATEGY_FACET_FILTERED:
182
+ return "SUB_QUERY_STRATEGY_FACET_FILTERED";
183
+ case SubQueryStrategy.SUB_QUERY_STRATEGY_TEMPORAL:
184
+ return "SUB_QUERY_STRATEGY_TEMPORAL";
185
+ case SubQueryStrategy.SUB_QUERY_STRATEGY_HYBRID:
186
+ return "SUB_QUERY_STRATEGY_HYBRID";
187
+ case SubQueryStrategy.UNRECOGNIZED:
188
+ default:
189
+ return "UNRECOGNIZED";
190
+ }
191
+ }
192
+ function createBaseKnowledgeTypeBias() {
193
+ return { knowledgeType: "", weight: 0 };
194
+ }
195
+ exports.KnowledgeTypeBias = {
196
+ encode(message, writer = new wire_1.BinaryWriter()) {
197
+ if (message.knowledgeType !== "") {
198
+ writer.uint32(10).string(message.knowledgeType);
199
+ }
200
+ if (message.weight !== 0) {
201
+ writer.uint32(21).float(message.weight);
202
+ }
203
+ return writer;
204
+ },
205
+ decode(input, length) {
206
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
207
+ const end = length === undefined ? reader.len : reader.pos + length;
208
+ const message = createBaseKnowledgeTypeBias();
209
+ while (reader.pos < end) {
210
+ const tag = reader.uint32();
211
+ switch (tag >>> 3) {
212
+ case 1: {
213
+ if (tag !== 10) {
214
+ break;
215
+ }
216
+ message.knowledgeType = reader.string();
217
+ continue;
218
+ }
219
+ case 2: {
220
+ if (tag !== 21) {
221
+ break;
222
+ }
223
+ message.weight = reader.float();
224
+ continue;
225
+ }
226
+ }
227
+ if ((tag & 7) === 4 || tag === 0) {
228
+ break;
229
+ }
230
+ reader.skip(tag & 7);
231
+ }
232
+ return message;
233
+ },
234
+ fromJSON(object) {
235
+ return {
236
+ knowledgeType: isSet(object.knowledgeType)
237
+ ? globalThis.String(object.knowledgeType)
238
+ : isSet(object.knowledge_type)
239
+ ? globalThis.String(object.knowledge_type)
240
+ : "",
241
+ weight: isSet(object.weight) ? globalThis.Number(object.weight) : 0,
242
+ };
243
+ },
244
+ toJSON(message) {
245
+ const obj = {};
246
+ if (message.knowledgeType !== "") {
247
+ obj.knowledgeType = message.knowledgeType;
248
+ }
249
+ if (message.weight !== 0) {
250
+ obj.weight = message.weight;
251
+ }
252
+ return obj;
253
+ },
254
+ create(base) {
255
+ return exports.KnowledgeTypeBias.fromPartial(base !== null && base !== void 0 ? base : {});
256
+ },
257
+ fromPartial(object) {
258
+ var _a, _b;
259
+ const message = createBaseKnowledgeTypeBias();
260
+ message.knowledgeType = (_a = object.knowledgeType) !== null && _a !== void 0 ? _a : "";
261
+ message.weight = (_b = object.weight) !== null && _b !== void 0 ? _b : 0;
262
+ return message;
263
+ },
264
+ };
265
+ function createBaseIntentSignal() {
266
+ return { type: 0, entities: [], timeScope: 0, confidence: 0, knowledgeTypeBias: [] };
267
+ }
268
+ exports.IntentSignal = {
269
+ encode(message, writer = new wire_1.BinaryWriter()) {
270
+ if (message.type !== 0) {
271
+ writer.uint32(8).int32(message.type);
272
+ }
273
+ for (const v of message.entities) {
274
+ writer.uint32(18).string(v);
275
+ }
276
+ if (message.timeScope !== 0) {
277
+ writer.uint32(24).int32(message.timeScope);
278
+ }
279
+ if (message.confidence !== 0) {
280
+ writer.uint32(37).float(message.confidence);
281
+ }
282
+ for (const v of message.knowledgeTypeBias) {
283
+ exports.KnowledgeTypeBias.encode(v, writer.uint32(42).fork()).join();
284
+ }
285
+ return writer;
286
+ },
287
+ decode(input, length) {
288
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
289
+ const end = length === undefined ? reader.len : reader.pos + length;
290
+ const message = createBaseIntentSignal();
291
+ while (reader.pos < end) {
292
+ const tag = reader.uint32();
293
+ switch (tag >>> 3) {
294
+ case 1: {
295
+ if (tag !== 8) {
296
+ break;
297
+ }
298
+ message.type = reader.int32();
299
+ continue;
300
+ }
301
+ case 2: {
302
+ if (tag !== 18) {
303
+ break;
304
+ }
305
+ message.entities.push(reader.string());
306
+ continue;
307
+ }
308
+ case 3: {
309
+ if (tag !== 24) {
310
+ break;
311
+ }
312
+ message.timeScope = reader.int32();
313
+ continue;
314
+ }
315
+ case 4: {
316
+ if (tag !== 37) {
317
+ break;
318
+ }
319
+ message.confidence = reader.float();
320
+ continue;
321
+ }
322
+ case 5: {
323
+ if (tag !== 42) {
324
+ break;
325
+ }
326
+ message.knowledgeTypeBias.push(exports.KnowledgeTypeBias.decode(reader, reader.uint32()));
327
+ continue;
328
+ }
329
+ }
330
+ if ((tag & 7) === 4 || tag === 0) {
331
+ break;
332
+ }
333
+ reader.skip(tag & 7);
334
+ }
335
+ return message;
336
+ },
337
+ fromJSON(object) {
338
+ return {
339
+ type: isSet(object.type) ? intentTypeFromJSON(object.type) : 0,
340
+ entities: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.entities) ? object.entities.map((e) => globalThis.String(e)) : [],
341
+ timeScope: isSet(object.timeScope)
342
+ ? retrievalTimeScopeFromJSON(object.timeScope)
343
+ : isSet(object.time_scope)
344
+ ? retrievalTimeScopeFromJSON(object.time_scope)
345
+ : 0,
346
+ confidence: isSet(object.confidence) ? globalThis.Number(object.confidence) : 0,
347
+ knowledgeTypeBias: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.knowledgeTypeBias)
348
+ ? object.knowledgeTypeBias.map((e) => exports.KnowledgeTypeBias.fromJSON(e))
349
+ : globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.knowledge_type_bias)
350
+ ? object.knowledge_type_bias.map((e) => exports.KnowledgeTypeBias.fromJSON(e))
351
+ : [],
352
+ };
353
+ },
354
+ toJSON(message) {
355
+ var _a, _b;
356
+ const obj = {};
357
+ if (message.type !== 0) {
358
+ obj.type = intentTypeToJSON(message.type);
359
+ }
360
+ if ((_a = message.entities) === null || _a === void 0 ? void 0 : _a.length) {
361
+ obj.entities = message.entities;
362
+ }
363
+ if (message.timeScope !== 0) {
364
+ obj.timeScope = retrievalTimeScopeToJSON(message.timeScope);
365
+ }
366
+ if (message.confidence !== 0) {
367
+ obj.confidence = message.confidence;
368
+ }
369
+ if ((_b = message.knowledgeTypeBias) === null || _b === void 0 ? void 0 : _b.length) {
370
+ obj.knowledgeTypeBias = message.knowledgeTypeBias.map((e) => exports.KnowledgeTypeBias.toJSON(e));
371
+ }
372
+ return obj;
373
+ },
374
+ create(base) {
375
+ return exports.IntentSignal.fromPartial(base !== null && base !== void 0 ? base : {});
376
+ },
377
+ fromPartial(object) {
378
+ var _a, _b;
379
+ var _c, _d, _e;
380
+ const message = createBaseIntentSignal();
381
+ message.type = (_c = object.type) !== null && _c !== void 0 ? _c : 0;
382
+ message.entities = ((_a = object.entities) === null || _a === void 0 ? void 0 : _a.map((e) => e)) || [];
383
+ message.timeScope = (_d = object.timeScope) !== null && _d !== void 0 ? _d : 0;
384
+ message.confidence = (_e = object.confidence) !== null && _e !== void 0 ? _e : 0;
385
+ message.knowledgeTypeBias = ((_b = object.knowledgeTypeBias) === null || _b === void 0 ? void 0 : _b.map((e) => exports.KnowledgeTypeBias.fromPartial(e))) || [];
386
+ return message;
387
+ },
388
+ };
389
+ function createBaseRetrievalConstraints() {
390
+ return { actingUserId: "", maxResults: 0, minSimilarity: 0, recencyBias: 0, sessionContextThreadIds: [] };
391
+ }
392
+ exports.RetrievalConstraints = {
393
+ encode(message, writer = new wire_1.BinaryWriter()) {
394
+ if (message.actingUserId !== "") {
395
+ writer.uint32(10).string(message.actingUserId);
396
+ }
397
+ if (message.maxResults !== 0) {
398
+ writer.uint32(24).int32(message.maxResults);
399
+ }
400
+ if (message.minSimilarity !== 0) {
401
+ writer.uint32(37).float(message.minSimilarity);
402
+ }
403
+ if (message.recencyBias !== 0) {
404
+ writer.uint32(45).float(message.recencyBias);
405
+ }
406
+ for (const v of message.sessionContextThreadIds) {
407
+ writer.uint32(50).string(v);
408
+ }
409
+ return writer;
410
+ },
411
+ decode(input, length) {
412
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
413
+ const end = length === undefined ? reader.len : reader.pos + length;
414
+ const message = createBaseRetrievalConstraints();
415
+ while (reader.pos < end) {
416
+ const tag = reader.uint32();
417
+ switch (tag >>> 3) {
418
+ case 1: {
419
+ if (tag !== 10) {
420
+ break;
421
+ }
422
+ message.actingUserId = reader.string();
423
+ continue;
424
+ }
425
+ case 3: {
426
+ if (tag !== 24) {
427
+ break;
428
+ }
429
+ message.maxResults = reader.int32();
430
+ continue;
431
+ }
432
+ case 4: {
433
+ if (tag !== 37) {
434
+ break;
435
+ }
436
+ message.minSimilarity = reader.float();
437
+ continue;
438
+ }
439
+ case 5: {
440
+ if (tag !== 45) {
441
+ break;
442
+ }
443
+ message.recencyBias = reader.float();
444
+ continue;
445
+ }
446
+ case 6: {
447
+ if (tag !== 50) {
448
+ break;
449
+ }
450
+ message.sessionContextThreadIds.push(reader.string());
451
+ continue;
452
+ }
453
+ }
454
+ if ((tag & 7) === 4 || tag === 0) {
455
+ break;
456
+ }
457
+ reader.skip(tag & 7);
458
+ }
459
+ return message;
460
+ },
461
+ fromJSON(object) {
462
+ return {
463
+ actingUserId: isSet(object.actingUserId)
464
+ ? globalThis.String(object.actingUserId)
465
+ : isSet(object.acting_user_id)
466
+ ? globalThis.String(object.acting_user_id)
467
+ : "",
468
+ maxResults: isSet(object.maxResults)
469
+ ? globalThis.Number(object.maxResults)
470
+ : isSet(object.max_results)
471
+ ? globalThis.Number(object.max_results)
472
+ : 0,
473
+ minSimilarity: isSet(object.minSimilarity)
474
+ ? globalThis.Number(object.minSimilarity)
475
+ : isSet(object.min_similarity)
476
+ ? globalThis.Number(object.min_similarity)
477
+ : 0,
478
+ recencyBias: isSet(object.recencyBias)
479
+ ? globalThis.Number(object.recencyBias)
480
+ : isSet(object.recency_bias)
481
+ ? globalThis.Number(object.recency_bias)
482
+ : 0,
483
+ sessionContextThreadIds: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.sessionContextThreadIds)
484
+ ? object.sessionContextThreadIds.map((e) => globalThis.String(e))
485
+ : globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.session_context_thread_ids)
486
+ ? object.session_context_thread_ids.map((e) => globalThis.String(e))
487
+ : [],
488
+ };
489
+ },
490
+ toJSON(message) {
491
+ var _a;
492
+ const obj = {};
493
+ if (message.actingUserId !== "") {
494
+ obj.actingUserId = message.actingUserId;
495
+ }
496
+ if (message.maxResults !== 0) {
497
+ obj.maxResults = Math.round(message.maxResults);
498
+ }
499
+ if (message.minSimilarity !== 0) {
500
+ obj.minSimilarity = message.minSimilarity;
501
+ }
502
+ if (message.recencyBias !== 0) {
503
+ obj.recencyBias = message.recencyBias;
504
+ }
505
+ if ((_a = message.sessionContextThreadIds) === null || _a === void 0 ? void 0 : _a.length) {
506
+ obj.sessionContextThreadIds = message.sessionContextThreadIds;
507
+ }
508
+ return obj;
509
+ },
510
+ create(base) {
511
+ return exports.RetrievalConstraints.fromPartial(base !== null && base !== void 0 ? base : {});
512
+ },
513
+ fromPartial(object) {
514
+ var _a;
515
+ var _b, _c, _d, _e;
516
+ const message = createBaseRetrievalConstraints();
517
+ message.actingUserId = (_b = object.actingUserId) !== null && _b !== void 0 ? _b : "";
518
+ message.maxResults = (_c = object.maxResults) !== null && _c !== void 0 ? _c : 0;
519
+ message.minSimilarity = (_d = object.minSimilarity) !== null && _d !== void 0 ? _d : 0;
520
+ message.recencyBias = (_e = object.recencyBias) !== null && _e !== void 0 ? _e : 0;
521
+ message.sessionContextThreadIds = ((_a = object.sessionContextThreadIds) === null || _a === void 0 ? void 0 : _a.map((e) => e)) || [];
522
+ return message;
523
+ },
524
+ };
525
+ function createBaseSubQuery() {
526
+ return { strategy: 0, queryText: "", embedding: [], filters: undefined, limit: 0, weight: 0, conceptIds: [] };
527
+ }
528
+ exports.SubQuery = {
529
+ encode(message, writer = new wire_1.BinaryWriter()) {
530
+ if (message.strategy !== 0) {
531
+ writer.uint32(8).int32(message.strategy);
532
+ }
533
+ if (message.queryText !== "") {
534
+ writer.uint32(18).string(message.queryText);
535
+ }
536
+ writer.uint32(26).fork();
537
+ for (const v of message.embedding) {
538
+ writer.float(v);
539
+ }
540
+ writer.join();
541
+ if (message.filters !== undefined) {
542
+ struct_pb_1.Struct.encode(struct_pb_1.Struct.wrap(message.filters), writer.uint32(34).fork()).join();
543
+ }
544
+ if (message.limit !== 0) {
545
+ writer.uint32(40).int32(message.limit);
546
+ }
547
+ if (message.weight !== 0) {
548
+ writer.uint32(53).float(message.weight);
549
+ }
550
+ for (const v of message.conceptIds) {
551
+ writer.uint32(58).string(v);
552
+ }
553
+ return writer;
554
+ },
555
+ decode(input, length) {
556
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
557
+ const end = length === undefined ? reader.len : reader.pos + length;
558
+ const message = createBaseSubQuery();
559
+ while (reader.pos < end) {
560
+ const tag = reader.uint32();
561
+ switch (tag >>> 3) {
562
+ case 1: {
563
+ if (tag !== 8) {
564
+ break;
565
+ }
566
+ message.strategy = reader.int32();
567
+ continue;
568
+ }
569
+ case 2: {
570
+ if (tag !== 18) {
571
+ break;
572
+ }
573
+ message.queryText = reader.string();
574
+ continue;
575
+ }
576
+ case 3: {
577
+ if (tag === 29) {
578
+ message.embedding.push(reader.float());
579
+ continue;
580
+ }
581
+ if (tag === 26) {
582
+ const end2 = reader.uint32() + reader.pos;
583
+ while (reader.pos < end2) {
584
+ message.embedding.push(reader.float());
585
+ }
586
+ continue;
587
+ }
588
+ break;
589
+ }
590
+ case 4: {
591
+ if (tag !== 34) {
592
+ break;
593
+ }
594
+ message.filters = struct_pb_1.Struct.unwrap(struct_pb_1.Struct.decode(reader, reader.uint32()));
595
+ continue;
596
+ }
597
+ case 5: {
598
+ if (tag !== 40) {
599
+ break;
600
+ }
601
+ message.limit = reader.int32();
602
+ continue;
603
+ }
604
+ case 6: {
605
+ if (tag !== 53) {
606
+ break;
607
+ }
608
+ message.weight = reader.float();
609
+ continue;
610
+ }
611
+ case 7: {
612
+ if (tag !== 58) {
613
+ break;
614
+ }
615
+ message.conceptIds.push(reader.string());
616
+ continue;
617
+ }
618
+ }
619
+ if ((tag & 7) === 4 || tag === 0) {
620
+ break;
621
+ }
622
+ reader.skip(tag & 7);
623
+ }
624
+ return message;
625
+ },
626
+ fromJSON(object) {
627
+ return {
628
+ strategy: isSet(object.strategy) ? subQueryStrategyFromJSON(object.strategy) : 0,
629
+ queryText: isSet(object.queryText)
630
+ ? globalThis.String(object.queryText)
631
+ : isSet(object.query_text)
632
+ ? globalThis.String(object.query_text)
633
+ : "",
634
+ embedding: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.embedding)
635
+ ? object.embedding.map((e) => globalThis.Number(e))
636
+ : [],
637
+ filters: isObject(object.filters) ? object.filters : undefined,
638
+ limit: isSet(object.limit) ? globalThis.Number(object.limit) : 0,
639
+ weight: isSet(object.weight) ? globalThis.Number(object.weight) : 0,
640
+ conceptIds: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.conceptIds)
641
+ ? object.conceptIds.map((e) => globalThis.String(e))
642
+ : globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.concept_ids)
643
+ ? object.concept_ids.map((e) => globalThis.String(e))
644
+ : [],
645
+ };
646
+ },
647
+ toJSON(message) {
648
+ var _a, _b;
649
+ const obj = {};
650
+ if (message.strategy !== 0) {
651
+ obj.strategy = subQueryStrategyToJSON(message.strategy);
652
+ }
653
+ if (message.queryText !== "") {
654
+ obj.queryText = message.queryText;
655
+ }
656
+ if ((_a = message.embedding) === null || _a === void 0 ? void 0 : _a.length) {
657
+ obj.embedding = message.embedding;
658
+ }
659
+ if (message.filters !== undefined) {
660
+ obj.filters = message.filters;
661
+ }
662
+ if (message.limit !== 0) {
663
+ obj.limit = Math.round(message.limit);
664
+ }
665
+ if (message.weight !== 0) {
666
+ obj.weight = message.weight;
667
+ }
668
+ if ((_b = message.conceptIds) === null || _b === void 0 ? void 0 : _b.length) {
669
+ obj.conceptIds = message.conceptIds;
670
+ }
671
+ return obj;
672
+ },
673
+ create(base) {
674
+ return exports.SubQuery.fromPartial(base !== null && base !== void 0 ? base : {});
675
+ },
676
+ fromPartial(object) {
677
+ var _a, _b;
678
+ var _c, _d, _e, _f, _g;
679
+ const message = createBaseSubQuery();
680
+ message.strategy = (_c = object.strategy) !== null && _c !== void 0 ? _c : 0;
681
+ message.queryText = (_d = object.queryText) !== null && _d !== void 0 ? _d : "";
682
+ message.embedding = ((_a = object.embedding) === null || _a === void 0 ? void 0 : _a.map((e) => e)) || [];
683
+ message.filters = (_e = object.filters) !== null && _e !== void 0 ? _e : undefined;
684
+ message.limit = (_f = object.limit) !== null && _f !== void 0 ? _f : 0;
685
+ message.weight = (_g = object.weight) !== null && _g !== void 0 ? _g : 0;
686
+ message.conceptIds = ((_b = object.conceptIds) === null || _b === void 0 ? void 0 : _b.map((e) => e)) || [];
687
+ return message;
688
+ },
689
+ };
690
+ function createBaseRerankerConfig() {
691
+ return {
692
+ recencyBias: 0,
693
+ reinforcementBoost: 0,
694
+ entityOverlapBoost: 0,
695
+ diversityTarget: 0,
696
+ sessionDeduplication: false,
697
+ };
698
+ }
699
+ exports.RerankerConfig = {
700
+ encode(message, writer = new wire_1.BinaryWriter()) {
701
+ if (message.recencyBias !== 0) {
702
+ writer.uint32(13).float(message.recencyBias);
703
+ }
704
+ if (message.reinforcementBoost !== 0) {
705
+ writer.uint32(21).float(message.reinforcementBoost);
706
+ }
707
+ if (message.entityOverlapBoost !== 0) {
708
+ writer.uint32(29).float(message.entityOverlapBoost);
709
+ }
710
+ if (message.diversityTarget !== 0) {
711
+ writer.uint32(37).float(message.diversityTarget);
712
+ }
713
+ if (message.sessionDeduplication !== false) {
714
+ writer.uint32(40).bool(message.sessionDeduplication);
715
+ }
716
+ return writer;
717
+ },
718
+ decode(input, length) {
719
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
720
+ const end = length === undefined ? reader.len : reader.pos + length;
721
+ const message = createBaseRerankerConfig();
722
+ while (reader.pos < end) {
723
+ const tag = reader.uint32();
724
+ switch (tag >>> 3) {
725
+ case 1: {
726
+ if (tag !== 13) {
727
+ break;
728
+ }
729
+ message.recencyBias = reader.float();
730
+ continue;
731
+ }
732
+ case 2: {
733
+ if (tag !== 21) {
734
+ break;
735
+ }
736
+ message.reinforcementBoost = reader.float();
737
+ continue;
738
+ }
739
+ case 3: {
740
+ if (tag !== 29) {
741
+ break;
742
+ }
743
+ message.entityOverlapBoost = reader.float();
744
+ continue;
745
+ }
746
+ case 4: {
747
+ if (tag !== 37) {
748
+ break;
749
+ }
750
+ message.diversityTarget = reader.float();
751
+ continue;
752
+ }
753
+ case 5: {
754
+ if (tag !== 40) {
755
+ break;
756
+ }
757
+ message.sessionDeduplication = reader.bool();
758
+ continue;
759
+ }
760
+ }
761
+ if ((tag & 7) === 4 || tag === 0) {
762
+ break;
763
+ }
764
+ reader.skip(tag & 7);
765
+ }
766
+ return message;
767
+ },
768
+ fromJSON(object) {
769
+ return {
770
+ recencyBias: isSet(object.recencyBias)
771
+ ? globalThis.Number(object.recencyBias)
772
+ : isSet(object.recency_bias)
773
+ ? globalThis.Number(object.recency_bias)
774
+ : 0,
775
+ reinforcementBoost: isSet(object.reinforcementBoost)
776
+ ? globalThis.Number(object.reinforcementBoost)
777
+ : isSet(object.reinforcement_boost)
778
+ ? globalThis.Number(object.reinforcement_boost)
779
+ : 0,
780
+ entityOverlapBoost: isSet(object.entityOverlapBoost)
781
+ ? globalThis.Number(object.entityOverlapBoost)
782
+ : isSet(object.entity_overlap_boost)
783
+ ? globalThis.Number(object.entity_overlap_boost)
784
+ : 0,
785
+ diversityTarget: isSet(object.diversityTarget)
786
+ ? globalThis.Number(object.diversityTarget)
787
+ : isSet(object.diversity_target)
788
+ ? globalThis.Number(object.diversity_target)
789
+ : 0,
790
+ sessionDeduplication: isSet(object.sessionDeduplication)
791
+ ? globalThis.Boolean(object.sessionDeduplication)
792
+ : isSet(object.session_deduplication)
793
+ ? globalThis.Boolean(object.session_deduplication)
794
+ : false,
795
+ };
796
+ },
797
+ toJSON(message) {
798
+ const obj = {};
799
+ if (message.recencyBias !== 0) {
800
+ obj.recencyBias = message.recencyBias;
801
+ }
802
+ if (message.reinforcementBoost !== 0) {
803
+ obj.reinforcementBoost = message.reinforcementBoost;
804
+ }
805
+ if (message.entityOverlapBoost !== 0) {
806
+ obj.entityOverlapBoost = message.entityOverlapBoost;
807
+ }
808
+ if (message.diversityTarget !== 0) {
809
+ obj.diversityTarget = message.diversityTarget;
810
+ }
811
+ if (message.sessionDeduplication !== false) {
812
+ obj.sessionDeduplication = message.sessionDeduplication;
813
+ }
814
+ return obj;
815
+ },
816
+ create(base) {
817
+ return exports.RerankerConfig.fromPartial(base !== null && base !== void 0 ? base : {});
818
+ },
819
+ fromPartial(object) {
820
+ var _a, _b, _c, _d, _e;
821
+ const message = createBaseRerankerConfig();
822
+ message.recencyBias = (_a = object.recencyBias) !== null && _a !== void 0 ? _a : 0;
823
+ message.reinforcementBoost = (_b = object.reinforcementBoost) !== null && _b !== void 0 ? _b : 0;
824
+ message.entityOverlapBoost = (_c = object.entityOverlapBoost) !== null && _c !== void 0 ? _c : 0;
825
+ message.diversityTarget = (_d = object.diversityTarget) !== null && _d !== void 0 ? _d : 0;
826
+ message.sessionDeduplication = (_e = object.sessionDeduplication) !== null && _e !== void 0 ? _e : false;
827
+ return message;
828
+ },
829
+ };
830
+ function createBaseRetrievalPlan() {
831
+ return {
832
+ queryId: "",
833
+ originalQuery: "",
834
+ intent: undefined,
835
+ constraints: undefined,
836
+ subQueries: [],
837
+ rerankerConfig: undefined,
838
+ createdAt: undefined,
839
+ };
840
+ }
841
+ exports.RetrievalPlan = {
842
+ encode(message, writer = new wire_1.BinaryWriter()) {
843
+ if (message.queryId !== "") {
844
+ writer.uint32(10).string(message.queryId);
845
+ }
846
+ if (message.originalQuery !== "") {
847
+ writer.uint32(18).string(message.originalQuery);
848
+ }
849
+ if (message.intent !== undefined) {
850
+ exports.IntentSignal.encode(message.intent, writer.uint32(26).fork()).join();
851
+ }
852
+ if (message.constraints !== undefined) {
853
+ exports.RetrievalConstraints.encode(message.constraints, writer.uint32(34).fork()).join();
854
+ }
855
+ for (const v of message.subQueries) {
856
+ exports.SubQuery.encode(v, writer.uint32(42).fork()).join();
857
+ }
858
+ if (message.rerankerConfig !== undefined) {
859
+ exports.RerankerConfig.encode(message.rerankerConfig, writer.uint32(50).fork()).join();
860
+ }
861
+ if (message.createdAt !== undefined) {
862
+ timestamp_pb_1.Timestamp.encode(toTimestamp(message.createdAt), writer.uint32(58).fork()).join();
863
+ }
864
+ return writer;
865
+ },
866
+ decode(input, length) {
867
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
868
+ const end = length === undefined ? reader.len : reader.pos + length;
869
+ const message = createBaseRetrievalPlan();
870
+ while (reader.pos < end) {
871
+ const tag = reader.uint32();
872
+ switch (tag >>> 3) {
873
+ case 1: {
874
+ if (tag !== 10) {
875
+ break;
876
+ }
877
+ message.queryId = reader.string();
878
+ continue;
879
+ }
880
+ case 2: {
881
+ if (tag !== 18) {
882
+ break;
883
+ }
884
+ message.originalQuery = reader.string();
885
+ continue;
886
+ }
887
+ case 3: {
888
+ if (tag !== 26) {
889
+ break;
890
+ }
891
+ message.intent = exports.IntentSignal.decode(reader, reader.uint32());
892
+ continue;
893
+ }
894
+ case 4: {
895
+ if (tag !== 34) {
896
+ break;
897
+ }
898
+ message.constraints = exports.RetrievalConstraints.decode(reader, reader.uint32());
899
+ continue;
900
+ }
901
+ case 5: {
902
+ if (tag !== 42) {
903
+ break;
904
+ }
905
+ message.subQueries.push(exports.SubQuery.decode(reader, reader.uint32()));
906
+ continue;
907
+ }
908
+ case 6: {
909
+ if (tag !== 50) {
910
+ break;
911
+ }
912
+ message.rerankerConfig = exports.RerankerConfig.decode(reader, reader.uint32());
913
+ continue;
914
+ }
915
+ case 7: {
916
+ if (tag !== 58) {
917
+ break;
918
+ }
919
+ message.createdAt = fromTimestamp(timestamp_pb_1.Timestamp.decode(reader, reader.uint32()));
920
+ continue;
921
+ }
922
+ }
923
+ if ((tag & 7) === 4 || tag === 0) {
924
+ break;
925
+ }
926
+ reader.skip(tag & 7);
927
+ }
928
+ return message;
929
+ },
930
+ fromJSON(object) {
931
+ return {
932
+ queryId: isSet(object.queryId)
933
+ ? globalThis.String(object.queryId)
934
+ : isSet(object.query_id)
935
+ ? globalThis.String(object.query_id)
936
+ : "",
937
+ originalQuery: isSet(object.originalQuery)
938
+ ? globalThis.String(object.originalQuery)
939
+ : isSet(object.original_query)
940
+ ? globalThis.String(object.original_query)
941
+ : "",
942
+ intent: isSet(object.intent) ? exports.IntentSignal.fromJSON(object.intent) : undefined,
943
+ constraints: isSet(object.constraints) ? exports.RetrievalConstraints.fromJSON(object.constraints) : undefined,
944
+ subQueries: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.subQueries)
945
+ ? object.subQueries.map((e) => exports.SubQuery.fromJSON(e))
946
+ : globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.sub_queries)
947
+ ? object.sub_queries.map((e) => exports.SubQuery.fromJSON(e))
948
+ : [],
949
+ rerankerConfig: isSet(object.rerankerConfig)
950
+ ? exports.RerankerConfig.fromJSON(object.rerankerConfig)
951
+ : isSet(object.reranker_config)
952
+ ? exports.RerankerConfig.fromJSON(object.reranker_config)
953
+ : undefined,
954
+ createdAt: isSet(object.createdAt)
955
+ ? fromJsonTimestamp(object.createdAt)
956
+ : isSet(object.created_at)
957
+ ? fromJsonTimestamp(object.created_at)
958
+ : undefined,
959
+ };
960
+ },
961
+ toJSON(message) {
962
+ var _a;
963
+ const obj = {};
964
+ if (message.queryId !== "") {
965
+ obj.queryId = message.queryId;
966
+ }
967
+ if (message.originalQuery !== "") {
968
+ obj.originalQuery = message.originalQuery;
969
+ }
970
+ if (message.intent !== undefined) {
971
+ obj.intent = exports.IntentSignal.toJSON(message.intent);
972
+ }
973
+ if (message.constraints !== undefined) {
974
+ obj.constraints = exports.RetrievalConstraints.toJSON(message.constraints);
975
+ }
976
+ if ((_a = message.subQueries) === null || _a === void 0 ? void 0 : _a.length) {
977
+ obj.subQueries = message.subQueries.map((e) => exports.SubQuery.toJSON(e));
978
+ }
979
+ if (message.rerankerConfig !== undefined) {
980
+ obj.rerankerConfig = exports.RerankerConfig.toJSON(message.rerankerConfig);
981
+ }
982
+ if (message.createdAt !== undefined) {
983
+ obj.createdAt = message.createdAt.toISOString();
984
+ }
985
+ return obj;
986
+ },
987
+ create(base) {
988
+ return exports.RetrievalPlan.fromPartial(base !== null && base !== void 0 ? base : {});
989
+ },
990
+ fromPartial(object) {
991
+ var _a;
992
+ var _b, _c, _d;
993
+ const message = createBaseRetrievalPlan();
994
+ message.queryId = (_b = object.queryId) !== null && _b !== void 0 ? _b : "";
995
+ message.originalQuery = (_c = object.originalQuery) !== null && _c !== void 0 ? _c : "";
996
+ message.intent = (object.intent !== undefined && object.intent !== null)
997
+ ? exports.IntentSignal.fromPartial(object.intent)
998
+ : undefined;
999
+ message.constraints = (object.constraints !== undefined && object.constraints !== null)
1000
+ ? exports.RetrievalConstraints.fromPartial(object.constraints)
1001
+ : undefined;
1002
+ message.subQueries = ((_a = object.subQueries) === null || _a === void 0 ? void 0 : _a.map((e) => exports.SubQuery.fromPartial(e))) || [];
1003
+ message.rerankerConfig = (object.rerankerConfig !== undefined && object.rerankerConfig !== null)
1004
+ ? exports.RerankerConfig.fromPartial(object.rerankerConfig)
1005
+ : undefined;
1006
+ message.createdAt = (_d = object.createdAt) !== null && _d !== void 0 ? _d : undefined;
1007
+ return message;
1008
+ },
1009
+ };
1010
+ function createBaseCitation() {
1011
+ return { documentId: "", documentName: "", sourceLocation: undefined, approvedAt: undefined, conceptCluster: "" };
1012
+ }
1013
+ exports.Citation = {
1014
+ encode(message, writer = new wire_1.BinaryWriter()) {
1015
+ if (message.documentId !== "") {
1016
+ writer.uint32(10).string(message.documentId);
1017
+ }
1018
+ if (message.documentName !== "") {
1019
+ writer.uint32(18).string(message.documentName);
1020
+ }
1021
+ if (message.sourceLocation !== undefined) {
1022
+ ingestion_pb_1.SourceLocation.encode(message.sourceLocation, writer.uint32(26).fork()).join();
1023
+ }
1024
+ if (message.approvedAt !== undefined) {
1025
+ timestamp_pb_1.Timestamp.encode(toTimestamp(message.approvedAt), writer.uint32(34).fork()).join();
1026
+ }
1027
+ if (message.conceptCluster !== "") {
1028
+ writer.uint32(42).string(message.conceptCluster);
1029
+ }
1030
+ return writer;
1031
+ },
1032
+ decode(input, length) {
1033
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
1034
+ const end = length === undefined ? reader.len : reader.pos + length;
1035
+ const message = createBaseCitation();
1036
+ while (reader.pos < end) {
1037
+ const tag = reader.uint32();
1038
+ switch (tag >>> 3) {
1039
+ case 1: {
1040
+ if (tag !== 10) {
1041
+ break;
1042
+ }
1043
+ message.documentId = reader.string();
1044
+ continue;
1045
+ }
1046
+ case 2: {
1047
+ if (tag !== 18) {
1048
+ break;
1049
+ }
1050
+ message.documentName = reader.string();
1051
+ continue;
1052
+ }
1053
+ case 3: {
1054
+ if (tag !== 26) {
1055
+ break;
1056
+ }
1057
+ message.sourceLocation = ingestion_pb_1.SourceLocation.decode(reader, reader.uint32());
1058
+ continue;
1059
+ }
1060
+ case 4: {
1061
+ if (tag !== 34) {
1062
+ break;
1063
+ }
1064
+ message.approvedAt = fromTimestamp(timestamp_pb_1.Timestamp.decode(reader, reader.uint32()));
1065
+ continue;
1066
+ }
1067
+ case 5: {
1068
+ if (tag !== 42) {
1069
+ break;
1070
+ }
1071
+ message.conceptCluster = reader.string();
1072
+ continue;
1073
+ }
1074
+ }
1075
+ if ((tag & 7) === 4 || tag === 0) {
1076
+ break;
1077
+ }
1078
+ reader.skip(tag & 7);
1079
+ }
1080
+ return message;
1081
+ },
1082
+ fromJSON(object) {
1083
+ return {
1084
+ documentId: isSet(object.documentId)
1085
+ ? globalThis.String(object.documentId)
1086
+ : isSet(object.document_id)
1087
+ ? globalThis.String(object.document_id)
1088
+ : "",
1089
+ documentName: isSet(object.documentName)
1090
+ ? globalThis.String(object.documentName)
1091
+ : isSet(object.document_name)
1092
+ ? globalThis.String(object.document_name)
1093
+ : "",
1094
+ sourceLocation: isSet(object.sourceLocation)
1095
+ ? ingestion_pb_1.SourceLocation.fromJSON(object.sourceLocation)
1096
+ : isSet(object.source_location)
1097
+ ? ingestion_pb_1.SourceLocation.fromJSON(object.source_location)
1098
+ : undefined,
1099
+ approvedAt: isSet(object.approvedAt)
1100
+ ? fromJsonTimestamp(object.approvedAt)
1101
+ : isSet(object.approved_at)
1102
+ ? fromJsonTimestamp(object.approved_at)
1103
+ : undefined,
1104
+ conceptCluster: isSet(object.conceptCluster)
1105
+ ? globalThis.String(object.conceptCluster)
1106
+ : isSet(object.concept_cluster)
1107
+ ? globalThis.String(object.concept_cluster)
1108
+ : "",
1109
+ };
1110
+ },
1111
+ toJSON(message) {
1112
+ const obj = {};
1113
+ if (message.documentId !== "") {
1114
+ obj.documentId = message.documentId;
1115
+ }
1116
+ if (message.documentName !== "") {
1117
+ obj.documentName = message.documentName;
1118
+ }
1119
+ if (message.sourceLocation !== undefined) {
1120
+ obj.sourceLocation = ingestion_pb_1.SourceLocation.toJSON(message.sourceLocation);
1121
+ }
1122
+ if (message.approvedAt !== undefined) {
1123
+ obj.approvedAt = message.approvedAt.toISOString();
1124
+ }
1125
+ if (message.conceptCluster !== "") {
1126
+ obj.conceptCluster = message.conceptCluster;
1127
+ }
1128
+ return obj;
1129
+ },
1130
+ create(base) {
1131
+ return exports.Citation.fromPartial(base !== null && base !== void 0 ? base : {});
1132
+ },
1133
+ fromPartial(object) {
1134
+ var _a, _b, _c, _d;
1135
+ const message = createBaseCitation();
1136
+ message.documentId = (_a = object.documentId) !== null && _a !== void 0 ? _a : "";
1137
+ message.documentName = (_b = object.documentName) !== null && _b !== void 0 ? _b : "";
1138
+ message.sourceLocation = (object.sourceLocation !== undefined && object.sourceLocation !== null)
1139
+ ? ingestion_pb_1.SourceLocation.fromPartial(object.sourceLocation)
1140
+ : undefined;
1141
+ message.approvedAt = (_c = object.approvedAt) !== null && _c !== void 0 ? _c : undefined;
1142
+ message.conceptCluster = (_d = object.conceptCluster) !== null && _d !== void 0 ? _d : "";
1143
+ return message;
1144
+ },
1145
+ };
1146
+ function createBaseRetrievedThread() {
1147
+ return {
1148
+ threadId: "",
1149
+ text: "",
1150
+ knowledgeType: "",
1151
+ facetFields: undefined,
1152
+ score: 0,
1153
+ classification: 0,
1154
+ citation: undefined,
1155
+ temporalValidity: undefined,
1156
+ entities: [],
1157
+ reinforcementCount: 0,
1158
+ sessionTurn: 0,
1159
+ };
1160
+ }
1161
+ exports.RetrievedThread = {
1162
+ encode(message, writer = new wire_1.BinaryWriter()) {
1163
+ if (message.threadId !== "") {
1164
+ writer.uint32(10).string(message.threadId);
1165
+ }
1166
+ if (message.text !== "") {
1167
+ writer.uint32(18).string(message.text);
1168
+ }
1169
+ if (message.knowledgeType !== "") {
1170
+ writer.uint32(26).string(message.knowledgeType);
1171
+ }
1172
+ if (message.facetFields !== undefined) {
1173
+ struct_pb_1.Struct.encode(struct_pb_1.Struct.wrap(message.facetFields), writer.uint32(34).fork()).join();
1174
+ }
1175
+ if (message.score !== 0) {
1176
+ writer.uint32(45).float(message.score);
1177
+ }
1178
+ if (message.classification !== 0) {
1179
+ writer.uint32(48).int32(message.classification);
1180
+ }
1181
+ if (message.citation !== undefined) {
1182
+ exports.Citation.encode(message.citation, writer.uint32(58).fork()).join();
1183
+ }
1184
+ if (message.temporalValidity !== undefined) {
1185
+ ingestion_pb_1.TemporalValidity.encode(message.temporalValidity, writer.uint32(66).fork()).join();
1186
+ }
1187
+ for (const v of message.entities) {
1188
+ writer.uint32(74).string(v);
1189
+ }
1190
+ if (message.reinforcementCount !== 0) {
1191
+ writer.uint32(80).int32(message.reinforcementCount);
1192
+ }
1193
+ if (message.sessionTurn !== 0) {
1194
+ writer.uint32(88).int32(message.sessionTurn);
1195
+ }
1196
+ return writer;
1197
+ },
1198
+ decode(input, length) {
1199
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
1200
+ const end = length === undefined ? reader.len : reader.pos + length;
1201
+ const message = createBaseRetrievedThread();
1202
+ while (reader.pos < end) {
1203
+ const tag = reader.uint32();
1204
+ switch (tag >>> 3) {
1205
+ case 1: {
1206
+ if (tag !== 10) {
1207
+ break;
1208
+ }
1209
+ message.threadId = reader.string();
1210
+ continue;
1211
+ }
1212
+ case 2: {
1213
+ if (tag !== 18) {
1214
+ break;
1215
+ }
1216
+ message.text = reader.string();
1217
+ continue;
1218
+ }
1219
+ case 3: {
1220
+ if (tag !== 26) {
1221
+ break;
1222
+ }
1223
+ message.knowledgeType = reader.string();
1224
+ continue;
1225
+ }
1226
+ case 4: {
1227
+ if (tag !== 34) {
1228
+ break;
1229
+ }
1230
+ message.facetFields = struct_pb_1.Struct.unwrap(struct_pb_1.Struct.decode(reader, reader.uint32()));
1231
+ continue;
1232
+ }
1233
+ case 5: {
1234
+ if (tag !== 45) {
1235
+ break;
1236
+ }
1237
+ message.score = reader.float();
1238
+ continue;
1239
+ }
1240
+ case 6: {
1241
+ if (tag !== 48) {
1242
+ break;
1243
+ }
1244
+ message.classification = reader.int32();
1245
+ continue;
1246
+ }
1247
+ case 7: {
1248
+ if (tag !== 58) {
1249
+ break;
1250
+ }
1251
+ message.citation = exports.Citation.decode(reader, reader.uint32());
1252
+ continue;
1253
+ }
1254
+ case 8: {
1255
+ if (tag !== 66) {
1256
+ break;
1257
+ }
1258
+ message.temporalValidity = ingestion_pb_1.TemporalValidity.decode(reader, reader.uint32());
1259
+ continue;
1260
+ }
1261
+ case 9: {
1262
+ if (tag !== 74) {
1263
+ break;
1264
+ }
1265
+ message.entities.push(reader.string());
1266
+ continue;
1267
+ }
1268
+ case 10: {
1269
+ if (tag !== 80) {
1270
+ break;
1271
+ }
1272
+ message.reinforcementCount = reader.int32();
1273
+ continue;
1274
+ }
1275
+ case 11: {
1276
+ if (tag !== 88) {
1277
+ break;
1278
+ }
1279
+ message.sessionTurn = reader.int32();
1280
+ continue;
1281
+ }
1282
+ }
1283
+ if ((tag & 7) === 4 || tag === 0) {
1284
+ break;
1285
+ }
1286
+ reader.skip(tag & 7);
1287
+ }
1288
+ return message;
1289
+ },
1290
+ fromJSON(object) {
1291
+ return {
1292
+ threadId: isSet(object.threadId)
1293
+ ? globalThis.String(object.threadId)
1294
+ : isSet(object.thread_id)
1295
+ ? globalThis.String(object.thread_id)
1296
+ : "",
1297
+ text: isSet(object.text) ? globalThis.String(object.text) : "",
1298
+ knowledgeType: isSet(object.knowledgeType)
1299
+ ? globalThis.String(object.knowledgeType)
1300
+ : isSet(object.knowledge_type)
1301
+ ? globalThis.String(object.knowledge_type)
1302
+ : "",
1303
+ facetFields: isObject(object.facetFields)
1304
+ ? object.facetFields
1305
+ : isObject(object.facet_fields)
1306
+ ? object.facet_fields
1307
+ : undefined,
1308
+ score: isSet(object.score) ? globalThis.Number(object.score) : 0,
1309
+ classification: isSet(object.classification) ? (0, ingestion_pb_1.threadClassificationFromJSON)(object.classification) : 0,
1310
+ citation: isSet(object.citation) ? exports.Citation.fromJSON(object.citation) : undefined,
1311
+ temporalValidity: isSet(object.temporalValidity)
1312
+ ? ingestion_pb_1.TemporalValidity.fromJSON(object.temporalValidity)
1313
+ : isSet(object.temporal_validity)
1314
+ ? ingestion_pb_1.TemporalValidity.fromJSON(object.temporal_validity)
1315
+ : undefined,
1316
+ entities: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.entities)
1317
+ ? object.entities.map((e) => globalThis.String(e))
1318
+ : [],
1319
+ reinforcementCount: isSet(object.reinforcementCount)
1320
+ ? globalThis.Number(object.reinforcementCount)
1321
+ : isSet(object.reinforcement_count)
1322
+ ? globalThis.Number(object.reinforcement_count)
1323
+ : 0,
1324
+ sessionTurn: isSet(object.sessionTurn)
1325
+ ? globalThis.Number(object.sessionTurn)
1326
+ : isSet(object.session_turn)
1327
+ ? globalThis.Number(object.session_turn)
1328
+ : 0,
1329
+ };
1330
+ },
1331
+ toJSON(message) {
1332
+ var _a;
1333
+ const obj = {};
1334
+ if (message.threadId !== "") {
1335
+ obj.threadId = message.threadId;
1336
+ }
1337
+ if (message.text !== "") {
1338
+ obj.text = message.text;
1339
+ }
1340
+ if (message.knowledgeType !== "") {
1341
+ obj.knowledgeType = message.knowledgeType;
1342
+ }
1343
+ if (message.facetFields !== undefined) {
1344
+ obj.facetFields = message.facetFields;
1345
+ }
1346
+ if (message.score !== 0) {
1347
+ obj.score = message.score;
1348
+ }
1349
+ if (message.classification !== 0) {
1350
+ obj.classification = (0, ingestion_pb_1.threadClassificationToJSON)(message.classification);
1351
+ }
1352
+ if (message.citation !== undefined) {
1353
+ obj.citation = exports.Citation.toJSON(message.citation);
1354
+ }
1355
+ if (message.temporalValidity !== undefined) {
1356
+ obj.temporalValidity = ingestion_pb_1.TemporalValidity.toJSON(message.temporalValidity);
1357
+ }
1358
+ if ((_a = message.entities) === null || _a === void 0 ? void 0 : _a.length) {
1359
+ obj.entities = message.entities;
1360
+ }
1361
+ if (message.reinforcementCount !== 0) {
1362
+ obj.reinforcementCount = Math.round(message.reinforcementCount);
1363
+ }
1364
+ if (message.sessionTurn !== 0) {
1365
+ obj.sessionTurn = Math.round(message.sessionTurn);
1366
+ }
1367
+ return obj;
1368
+ },
1369
+ create(base) {
1370
+ return exports.RetrievedThread.fromPartial(base !== null && base !== void 0 ? base : {});
1371
+ },
1372
+ fromPartial(object) {
1373
+ var _a;
1374
+ var _b, _c, _d, _e, _f, _g, _h, _j;
1375
+ const message = createBaseRetrievedThread();
1376
+ message.threadId = (_b = object.threadId) !== null && _b !== void 0 ? _b : "";
1377
+ message.text = (_c = object.text) !== null && _c !== void 0 ? _c : "";
1378
+ message.knowledgeType = (_d = object.knowledgeType) !== null && _d !== void 0 ? _d : "";
1379
+ message.facetFields = (_e = object.facetFields) !== null && _e !== void 0 ? _e : undefined;
1380
+ message.score = (_f = object.score) !== null && _f !== void 0 ? _f : 0;
1381
+ message.classification = (_g = object.classification) !== null && _g !== void 0 ? _g : 0;
1382
+ message.citation = (object.citation !== undefined && object.citation !== null)
1383
+ ? exports.Citation.fromPartial(object.citation)
1384
+ : undefined;
1385
+ message.temporalValidity = (object.temporalValidity !== undefined && object.temporalValidity !== null)
1386
+ ? ingestion_pb_1.TemporalValidity.fromPartial(object.temporalValidity)
1387
+ : undefined;
1388
+ message.entities = ((_a = object.entities) === null || _a === void 0 ? void 0 : _a.map((e) => e)) || [];
1389
+ message.reinforcementCount = (_h = object.reinforcementCount) !== null && _h !== void 0 ? _h : 0;
1390
+ message.sessionTurn = (_j = object.sessionTurn) !== null && _j !== void 0 ? _j : 0;
1391
+ return message;
1392
+ },
1393
+ };
1394
+ function createBaseDocumentSearchFilters() {
1395
+ return { tags: [], restrictedTags: [], scopes: [], uploadedAfter: undefined, uploadedBefore: undefined };
1396
+ }
1397
+ exports.DocumentSearchFilters = {
1398
+ encode(message, writer = new wire_1.BinaryWriter()) {
1399
+ for (const v of message.tags) {
1400
+ writer.uint32(10).string(v);
1401
+ }
1402
+ for (const v of message.restrictedTags) {
1403
+ writer.uint32(18).string(v);
1404
+ }
1405
+ writer.uint32(26).fork();
1406
+ for (const v of message.scopes) {
1407
+ writer.int32(v);
1408
+ }
1409
+ writer.join();
1410
+ if (message.uploadedAfter !== undefined) {
1411
+ timestamp_pb_1.Timestamp.encode(toTimestamp(message.uploadedAfter), writer.uint32(34).fork()).join();
1412
+ }
1413
+ if (message.uploadedBefore !== undefined) {
1414
+ timestamp_pb_1.Timestamp.encode(toTimestamp(message.uploadedBefore), writer.uint32(42).fork()).join();
1415
+ }
1416
+ return writer;
1417
+ },
1418
+ decode(input, length) {
1419
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
1420
+ const end = length === undefined ? reader.len : reader.pos + length;
1421
+ const message = createBaseDocumentSearchFilters();
1422
+ while (reader.pos < end) {
1423
+ const tag = reader.uint32();
1424
+ switch (tag >>> 3) {
1425
+ case 1: {
1426
+ if (tag !== 10) {
1427
+ break;
1428
+ }
1429
+ message.tags.push(reader.string());
1430
+ continue;
1431
+ }
1432
+ case 2: {
1433
+ if (tag !== 18) {
1434
+ break;
1435
+ }
1436
+ message.restrictedTags.push(reader.string());
1437
+ continue;
1438
+ }
1439
+ case 3: {
1440
+ if (tag === 24) {
1441
+ message.scopes.push(reader.int32());
1442
+ continue;
1443
+ }
1444
+ if (tag === 26) {
1445
+ const end2 = reader.uint32() + reader.pos;
1446
+ while (reader.pos < end2) {
1447
+ message.scopes.push(reader.int32());
1448
+ }
1449
+ continue;
1450
+ }
1451
+ break;
1452
+ }
1453
+ case 4: {
1454
+ if (tag !== 34) {
1455
+ break;
1456
+ }
1457
+ message.uploadedAfter = fromTimestamp(timestamp_pb_1.Timestamp.decode(reader, reader.uint32()));
1458
+ continue;
1459
+ }
1460
+ case 5: {
1461
+ if (tag !== 42) {
1462
+ break;
1463
+ }
1464
+ message.uploadedBefore = fromTimestamp(timestamp_pb_1.Timestamp.decode(reader, reader.uint32()));
1465
+ continue;
1466
+ }
1467
+ }
1468
+ if ((tag & 7) === 4 || tag === 0) {
1469
+ break;
1470
+ }
1471
+ reader.skip(tag & 7);
1472
+ }
1473
+ return message;
1474
+ },
1475
+ fromJSON(object) {
1476
+ return {
1477
+ tags: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.tags) ? object.tags.map((e) => globalThis.String(e)) : [],
1478
+ restrictedTags: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.restrictedTags)
1479
+ ? object.restrictedTags.map((e) => globalThis.String(e))
1480
+ : globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.restricted_tags)
1481
+ ? object.restricted_tags.map((e) => globalThis.String(e))
1482
+ : [],
1483
+ scopes: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.scopes) ? object.scopes.map((e) => (0, ingestion_pb_1.documentScopeFromJSON)(e)) : [],
1484
+ uploadedAfter: isSet(object.uploadedAfter)
1485
+ ? fromJsonTimestamp(object.uploadedAfter)
1486
+ : isSet(object.uploaded_after)
1487
+ ? fromJsonTimestamp(object.uploaded_after)
1488
+ : undefined,
1489
+ uploadedBefore: isSet(object.uploadedBefore)
1490
+ ? fromJsonTimestamp(object.uploadedBefore)
1491
+ : isSet(object.uploaded_before)
1492
+ ? fromJsonTimestamp(object.uploaded_before)
1493
+ : undefined,
1494
+ };
1495
+ },
1496
+ toJSON(message) {
1497
+ var _a, _b, _c;
1498
+ const obj = {};
1499
+ if ((_a = message.tags) === null || _a === void 0 ? void 0 : _a.length) {
1500
+ obj.tags = message.tags;
1501
+ }
1502
+ if ((_b = message.restrictedTags) === null || _b === void 0 ? void 0 : _b.length) {
1503
+ obj.restrictedTags = message.restrictedTags;
1504
+ }
1505
+ if ((_c = message.scopes) === null || _c === void 0 ? void 0 : _c.length) {
1506
+ obj.scopes = message.scopes.map((e) => (0, ingestion_pb_1.documentScopeToJSON)(e));
1507
+ }
1508
+ if (message.uploadedAfter !== undefined) {
1509
+ obj.uploadedAfter = message.uploadedAfter.toISOString();
1510
+ }
1511
+ if (message.uploadedBefore !== undefined) {
1512
+ obj.uploadedBefore = message.uploadedBefore.toISOString();
1513
+ }
1514
+ return obj;
1515
+ },
1516
+ create(base) {
1517
+ return exports.DocumentSearchFilters.fromPartial(base !== null && base !== void 0 ? base : {});
1518
+ },
1519
+ fromPartial(object) {
1520
+ var _a, _b, _c;
1521
+ var _d, _e;
1522
+ const message = createBaseDocumentSearchFilters();
1523
+ message.tags = ((_a = object.tags) === null || _a === void 0 ? void 0 : _a.map((e) => e)) || [];
1524
+ message.restrictedTags = ((_b = object.restrictedTags) === null || _b === void 0 ? void 0 : _b.map((e) => e)) || [];
1525
+ message.scopes = ((_c = object.scopes) === null || _c === void 0 ? void 0 : _c.map((e) => e)) || [];
1526
+ message.uploadedAfter = (_d = object.uploadedAfter) !== null && _d !== void 0 ? _d : undefined;
1527
+ message.uploadedBefore = (_e = object.uploadedBefore) !== null && _e !== void 0 ? _e : undefined;
1528
+ return message;
1529
+ },
1530
+ };
1531
+ function createBaseDocumentSearchSnippet() {
1532
+ return { threadId: "", text: "", score: 0, classification: 0, sourceLocation: undefined };
1533
+ }
1534
+ exports.DocumentSearchSnippet = {
1535
+ encode(message, writer = new wire_1.BinaryWriter()) {
1536
+ if (message.threadId !== "") {
1537
+ writer.uint32(10).string(message.threadId);
1538
+ }
1539
+ if (message.text !== "") {
1540
+ writer.uint32(18).string(message.text);
1541
+ }
1542
+ if (message.score !== 0) {
1543
+ writer.uint32(29).float(message.score);
1544
+ }
1545
+ if (message.classification !== 0) {
1546
+ writer.uint32(32).int32(message.classification);
1547
+ }
1548
+ if (message.sourceLocation !== undefined) {
1549
+ ingestion_pb_1.SourceLocation.encode(message.sourceLocation, writer.uint32(42).fork()).join();
1550
+ }
1551
+ return writer;
1552
+ },
1553
+ decode(input, length) {
1554
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
1555
+ const end = length === undefined ? reader.len : reader.pos + length;
1556
+ const message = createBaseDocumentSearchSnippet();
1557
+ while (reader.pos < end) {
1558
+ const tag = reader.uint32();
1559
+ switch (tag >>> 3) {
1560
+ case 1: {
1561
+ if (tag !== 10) {
1562
+ break;
1563
+ }
1564
+ message.threadId = reader.string();
1565
+ continue;
1566
+ }
1567
+ case 2: {
1568
+ if (tag !== 18) {
1569
+ break;
1570
+ }
1571
+ message.text = reader.string();
1572
+ continue;
1573
+ }
1574
+ case 3: {
1575
+ if (tag !== 29) {
1576
+ break;
1577
+ }
1578
+ message.score = reader.float();
1579
+ continue;
1580
+ }
1581
+ case 4: {
1582
+ if (tag !== 32) {
1583
+ break;
1584
+ }
1585
+ message.classification = reader.int32();
1586
+ continue;
1587
+ }
1588
+ case 5: {
1589
+ if (tag !== 42) {
1590
+ break;
1591
+ }
1592
+ message.sourceLocation = ingestion_pb_1.SourceLocation.decode(reader, reader.uint32());
1593
+ continue;
1594
+ }
1595
+ }
1596
+ if ((tag & 7) === 4 || tag === 0) {
1597
+ break;
1598
+ }
1599
+ reader.skip(tag & 7);
1600
+ }
1601
+ return message;
1602
+ },
1603
+ fromJSON(object) {
1604
+ return {
1605
+ threadId: isSet(object.threadId)
1606
+ ? globalThis.String(object.threadId)
1607
+ : isSet(object.thread_id)
1608
+ ? globalThis.String(object.thread_id)
1609
+ : "",
1610
+ text: isSet(object.text) ? globalThis.String(object.text) : "",
1611
+ score: isSet(object.score) ? globalThis.Number(object.score) : 0,
1612
+ classification: isSet(object.classification) ? (0, ingestion_pb_1.threadClassificationFromJSON)(object.classification) : 0,
1613
+ sourceLocation: isSet(object.sourceLocation)
1614
+ ? ingestion_pb_1.SourceLocation.fromJSON(object.sourceLocation)
1615
+ : isSet(object.source_location)
1616
+ ? ingestion_pb_1.SourceLocation.fromJSON(object.source_location)
1617
+ : undefined,
1618
+ };
1619
+ },
1620
+ toJSON(message) {
1621
+ const obj = {};
1622
+ if (message.threadId !== "") {
1623
+ obj.threadId = message.threadId;
1624
+ }
1625
+ if (message.text !== "") {
1626
+ obj.text = message.text;
1627
+ }
1628
+ if (message.score !== 0) {
1629
+ obj.score = message.score;
1630
+ }
1631
+ if (message.classification !== 0) {
1632
+ obj.classification = (0, ingestion_pb_1.threadClassificationToJSON)(message.classification);
1633
+ }
1634
+ if (message.sourceLocation !== undefined) {
1635
+ obj.sourceLocation = ingestion_pb_1.SourceLocation.toJSON(message.sourceLocation);
1636
+ }
1637
+ return obj;
1638
+ },
1639
+ create(base) {
1640
+ return exports.DocumentSearchSnippet.fromPartial(base !== null && base !== void 0 ? base : {});
1641
+ },
1642
+ fromPartial(object) {
1643
+ var _a, _b, _c, _d;
1644
+ const message = createBaseDocumentSearchSnippet();
1645
+ message.threadId = (_a = object.threadId) !== null && _a !== void 0 ? _a : "";
1646
+ message.text = (_b = object.text) !== null && _b !== void 0 ? _b : "";
1647
+ message.score = (_c = object.score) !== null && _c !== void 0 ? _c : 0;
1648
+ message.classification = (_d = object.classification) !== null && _d !== void 0 ? _d : 0;
1649
+ message.sourceLocation = (object.sourceLocation !== undefined && object.sourceLocation !== null)
1650
+ ? ingestion_pb_1.SourceLocation.fromPartial(object.sourceLocation)
1651
+ : undefined;
1652
+ return message;
1653
+ },
1654
+ };
1655
+ function createBaseRetrievedDocument() {
1656
+ return {
1657
+ documentId: "",
1658
+ documentName: "",
1659
+ mimeType: "",
1660
+ scope: 0,
1661
+ tags: [],
1662
+ sensitivityTags: [],
1663
+ score: 0,
1664
+ matchedThreadCount: 0,
1665
+ snippets: [],
1666
+ uploadedAt: undefined,
1667
+ };
1668
+ }
1669
+ exports.RetrievedDocument = {
1670
+ encode(message, writer = new wire_1.BinaryWriter()) {
1671
+ if (message.documentId !== "") {
1672
+ writer.uint32(10).string(message.documentId);
1673
+ }
1674
+ if (message.documentName !== "") {
1675
+ writer.uint32(18).string(message.documentName);
1676
+ }
1677
+ if (message.mimeType !== "") {
1678
+ writer.uint32(26).string(message.mimeType);
1679
+ }
1680
+ if (message.scope !== 0) {
1681
+ writer.uint32(32).int32(message.scope);
1682
+ }
1683
+ for (const v of message.tags) {
1684
+ ingestion_pb_1.DocumentTag.encode(v, writer.uint32(42).fork()).join();
1685
+ }
1686
+ for (const v of message.sensitivityTags) {
1687
+ writer.uint32(50).string(v);
1688
+ }
1689
+ if (message.score !== 0) {
1690
+ writer.uint32(61).float(message.score);
1691
+ }
1692
+ if (message.matchedThreadCount !== 0) {
1693
+ writer.uint32(64).int32(message.matchedThreadCount);
1694
+ }
1695
+ for (const v of message.snippets) {
1696
+ exports.DocumentSearchSnippet.encode(v, writer.uint32(74).fork()).join();
1697
+ }
1698
+ if (message.uploadedAt !== undefined) {
1699
+ timestamp_pb_1.Timestamp.encode(toTimestamp(message.uploadedAt), writer.uint32(82).fork()).join();
1700
+ }
1701
+ return writer;
1702
+ },
1703
+ decode(input, length) {
1704
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
1705
+ const end = length === undefined ? reader.len : reader.pos + length;
1706
+ const message = createBaseRetrievedDocument();
1707
+ while (reader.pos < end) {
1708
+ const tag = reader.uint32();
1709
+ switch (tag >>> 3) {
1710
+ case 1: {
1711
+ if (tag !== 10) {
1712
+ break;
1713
+ }
1714
+ message.documentId = reader.string();
1715
+ continue;
1716
+ }
1717
+ case 2: {
1718
+ if (tag !== 18) {
1719
+ break;
1720
+ }
1721
+ message.documentName = reader.string();
1722
+ continue;
1723
+ }
1724
+ case 3: {
1725
+ if (tag !== 26) {
1726
+ break;
1727
+ }
1728
+ message.mimeType = reader.string();
1729
+ continue;
1730
+ }
1731
+ case 4: {
1732
+ if (tag !== 32) {
1733
+ break;
1734
+ }
1735
+ message.scope = reader.int32();
1736
+ continue;
1737
+ }
1738
+ case 5: {
1739
+ if (tag !== 42) {
1740
+ break;
1741
+ }
1742
+ message.tags.push(ingestion_pb_1.DocumentTag.decode(reader, reader.uint32()));
1743
+ continue;
1744
+ }
1745
+ case 6: {
1746
+ if (tag !== 50) {
1747
+ break;
1748
+ }
1749
+ message.sensitivityTags.push(reader.string());
1750
+ continue;
1751
+ }
1752
+ case 7: {
1753
+ if (tag !== 61) {
1754
+ break;
1755
+ }
1756
+ message.score = reader.float();
1757
+ continue;
1758
+ }
1759
+ case 8: {
1760
+ if (tag !== 64) {
1761
+ break;
1762
+ }
1763
+ message.matchedThreadCount = reader.int32();
1764
+ continue;
1765
+ }
1766
+ case 9: {
1767
+ if (tag !== 74) {
1768
+ break;
1769
+ }
1770
+ message.snippets.push(exports.DocumentSearchSnippet.decode(reader, reader.uint32()));
1771
+ continue;
1772
+ }
1773
+ case 10: {
1774
+ if (tag !== 82) {
1775
+ break;
1776
+ }
1777
+ message.uploadedAt = fromTimestamp(timestamp_pb_1.Timestamp.decode(reader, reader.uint32()));
1778
+ continue;
1779
+ }
1780
+ }
1781
+ if ((tag & 7) === 4 || tag === 0) {
1782
+ break;
1783
+ }
1784
+ reader.skip(tag & 7);
1785
+ }
1786
+ return message;
1787
+ },
1788
+ fromJSON(object) {
1789
+ return {
1790
+ documentId: isSet(object.documentId)
1791
+ ? globalThis.String(object.documentId)
1792
+ : isSet(object.document_id)
1793
+ ? globalThis.String(object.document_id)
1794
+ : "",
1795
+ documentName: isSet(object.documentName)
1796
+ ? globalThis.String(object.documentName)
1797
+ : isSet(object.document_name)
1798
+ ? globalThis.String(object.document_name)
1799
+ : "",
1800
+ mimeType: isSet(object.mimeType)
1801
+ ? globalThis.String(object.mimeType)
1802
+ : isSet(object.mime_type)
1803
+ ? globalThis.String(object.mime_type)
1804
+ : "",
1805
+ scope: isSet(object.scope) ? (0, ingestion_pb_1.documentScopeFromJSON)(object.scope) : 0,
1806
+ tags: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.tags) ? object.tags.map((e) => ingestion_pb_1.DocumentTag.fromJSON(e)) : [],
1807
+ sensitivityTags: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.sensitivityTags)
1808
+ ? object.sensitivityTags.map((e) => globalThis.String(e))
1809
+ : globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.sensitivity_tags)
1810
+ ? object.sensitivity_tags.map((e) => globalThis.String(e))
1811
+ : [],
1812
+ score: isSet(object.score) ? globalThis.Number(object.score) : 0,
1813
+ matchedThreadCount: isSet(object.matchedThreadCount)
1814
+ ? globalThis.Number(object.matchedThreadCount)
1815
+ : isSet(object.matched_thread_count)
1816
+ ? globalThis.Number(object.matched_thread_count)
1817
+ : 0,
1818
+ snippets: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.snippets)
1819
+ ? object.snippets.map((e) => exports.DocumentSearchSnippet.fromJSON(e))
1820
+ : [],
1821
+ uploadedAt: isSet(object.uploadedAt)
1822
+ ? fromJsonTimestamp(object.uploadedAt)
1823
+ : isSet(object.uploaded_at)
1824
+ ? fromJsonTimestamp(object.uploaded_at)
1825
+ : undefined,
1826
+ };
1827
+ },
1828
+ toJSON(message) {
1829
+ var _a, _b, _c;
1830
+ const obj = {};
1831
+ if (message.documentId !== "") {
1832
+ obj.documentId = message.documentId;
1833
+ }
1834
+ if (message.documentName !== "") {
1835
+ obj.documentName = message.documentName;
1836
+ }
1837
+ if (message.mimeType !== "") {
1838
+ obj.mimeType = message.mimeType;
1839
+ }
1840
+ if (message.scope !== 0) {
1841
+ obj.scope = (0, ingestion_pb_1.documentScopeToJSON)(message.scope);
1842
+ }
1843
+ if ((_a = message.tags) === null || _a === void 0 ? void 0 : _a.length) {
1844
+ obj.tags = message.tags.map((e) => ingestion_pb_1.DocumentTag.toJSON(e));
1845
+ }
1846
+ if ((_b = message.sensitivityTags) === null || _b === void 0 ? void 0 : _b.length) {
1847
+ obj.sensitivityTags = message.sensitivityTags;
1848
+ }
1849
+ if (message.score !== 0) {
1850
+ obj.score = message.score;
1851
+ }
1852
+ if (message.matchedThreadCount !== 0) {
1853
+ obj.matchedThreadCount = Math.round(message.matchedThreadCount);
1854
+ }
1855
+ if ((_c = message.snippets) === null || _c === void 0 ? void 0 : _c.length) {
1856
+ obj.snippets = message.snippets.map((e) => exports.DocumentSearchSnippet.toJSON(e));
1857
+ }
1858
+ if (message.uploadedAt !== undefined) {
1859
+ obj.uploadedAt = message.uploadedAt.toISOString();
1860
+ }
1861
+ return obj;
1862
+ },
1863
+ create(base) {
1864
+ return exports.RetrievedDocument.fromPartial(base !== null && base !== void 0 ? base : {});
1865
+ },
1866
+ fromPartial(object) {
1867
+ var _a, _b, _c;
1868
+ var _d, _e, _f, _g, _h, _j, _k;
1869
+ const message = createBaseRetrievedDocument();
1870
+ message.documentId = (_d = object.documentId) !== null && _d !== void 0 ? _d : "";
1871
+ message.documentName = (_e = object.documentName) !== null && _e !== void 0 ? _e : "";
1872
+ message.mimeType = (_f = object.mimeType) !== null && _f !== void 0 ? _f : "";
1873
+ message.scope = (_g = object.scope) !== null && _g !== void 0 ? _g : 0;
1874
+ message.tags = ((_a = object.tags) === null || _a === void 0 ? void 0 : _a.map((e) => ingestion_pb_1.DocumentTag.fromPartial(e))) || [];
1875
+ message.sensitivityTags = ((_b = object.sensitivityTags) === null || _b === void 0 ? void 0 : _b.map((e) => e)) || [];
1876
+ message.score = (_h = object.score) !== null && _h !== void 0 ? _h : 0;
1877
+ message.matchedThreadCount = (_j = object.matchedThreadCount) !== null && _j !== void 0 ? _j : 0;
1878
+ message.snippets = ((_c = object.snippets) === null || _c === void 0 ? void 0 : _c.map((e) => exports.DocumentSearchSnippet.fromPartial(e))) || [];
1879
+ message.uploadedAt = (_k = object.uploadedAt) !== null && _k !== void 0 ? _k : undefined;
1880
+ return message;
1881
+ },
1882
+ };
1883
+ function createBaseRetrieveRequest() {
1884
+ return { organizationId: "", query: "", constraints: undefined, sessionId: "" };
1885
+ }
1886
+ exports.RetrieveRequest = {
1887
+ encode(message, writer = new wire_1.BinaryWriter()) {
1888
+ if (message.organizationId !== "") {
1889
+ writer.uint32(10).string(message.organizationId);
1890
+ }
1891
+ if (message.query !== "") {
1892
+ writer.uint32(18).string(message.query);
1893
+ }
1894
+ if (message.constraints !== undefined) {
1895
+ exports.RetrievalConstraints.encode(message.constraints, writer.uint32(26).fork()).join();
1896
+ }
1897
+ if (message.sessionId !== "") {
1898
+ writer.uint32(34).string(message.sessionId);
1899
+ }
1900
+ return writer;
1901
+ },
1902
+ decode(input, length) {
1903
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
1904
+ const end = length === undefined ? reader.len : reader.pos + length;
1905
+ const message = createBaseRetrieveRequest();
1906
+ while (reader.pos < end) {
1907
+ const tag = reader.uint32();
1908
+ switch (tag >>> 3) {
1909
+ case 1: {
1910
+ if (tag !== 10) {
1911
+ break;
1912
+ }
1913
+ message.organizationId = reader.string();
1914
+ continue;
1915
+ }
1916
+ case 2: {
1917
+ if (tag !== 18) {
1918
+ break;
1919
+ }
1920
+ message.query = reader.string();
1921
+ continue;
1922
+ }
1923
+ case 3: {
1924
+ if (tag !== 26) {
1925
+ break;
1926
+ }
1927
+ message.constraints = exports.RetrievalConstraints.decode(reader, reader.uint32());
1928
+ continue;
1929
+ }
1930
+ case 4: {
1931
+ if (tag !== 34) {
1932
+ break;
1933
+ }
1934
+ message.sessionId = reader.string();
1935
+ continue;
1936
+ }
1937
+ }
1938
+ if ((tag & 7) === 4 || tag === 0) {
1939
+ break;
1940
+ }
1941
+ reader.skip(tag & 7);
1942
+ }
1943
+ return message;
1944
+ },
1945
+ fromJSON(object) {
1946
+ return {
1947
+ organizationId: isSet(object.organizationId)
1948
+ ? globalThis.String(object.organizationId)
1949
+ : isSet(object.organization_id)
1950
+ ? globalThis.String(object.organization_id)
1951
+ : "",
1952
+ query: isSet(object.query) ? globalThis.String(object.query) : "",
1953
+ constraints: isSet(object.constraints) ? exports.RetrievalConstraints.fromJSON(object.constraints) : undefined,
1954
+ sessionId: isSet(object.sessionId)
1955
+ ? globalThis.String(object.sessionId)
1956
+ : isSet(object.session_id)
1957
+ ? globalThis.String(object.session_id)
1958
+ : "",
1959
+ };
1960
+ },
1961
+ toJSON(message) {
1962
+ const obj = {};
1963
+ if (message.organizationId !== "") {
1964
+ obj.organizationId = message.organizationId;
1965
+ }
1966
+ if (message.query !== "") {
1967
+ obj.query = message.query;
1968
+ }
1969
+ if (message.constraints !== undefined) {
1970
+ obj.constraints = exports.RetrievalConstraints.toJSON(message.constraints);
1971
+ }
1972
+ if (message.sessionId !== "") {
1973
+ obj.sessionId = message.sessionId;
1974
+ }
1975
+ return obj;
1976
+ },
1977
+ create(base) {
1978
+ return exports.RetrieveRequest.fromPartial(base !== null && base !== void 0 ? base : {});
1979
+ },
1980
+ fromPartial(object) {
1981
+ var _a, _b, _c;
1982
+ const message = createBaseRetrieveRequest();
1983
+ message.organizationId = (_a = object.organizationId) !== null && _a !== void 0 ? _a : "";
1984
+ message.query = (_b = object.query) !== null && _b !== void 0 ? _b : "";
1985
+ message.constraints = (object.constraints !== undefined && object.constraints !== null)
1986
+ ? exports.RetrievalConstraints.fromPartial(object.constraints)
1987
+ : undefined;
1988
+ message.sessionId = (_c = object.sessionId) !== null && _c !== void 0 ? _c : "";
1989
+ return message;
1990
+ },
1991
+ };
1992
+ function createBaseRetrieveResponse() {
1993
+ return { threads: [], plan: undefined };
1994
+ }
1995
+ exports.RetrieveResponse = {
1996
+ encode(message, writer = new wire_1.BinaryWriter()) {
1997
+ for (const v of message.threads) {
1998
+ exports.RetrievedThread.encode(v, writer.uint32(10).fork()).join();
1999
+ }
2000
+ if (message.plan !== undefined) {
2001
+ exports.RetrievalPlan.encode(message.plan, writer.uint32(18).fork()).join();
2002
+ }
2003
+ return writer;
2004
+ },
2005
+ decode(input, length) {
2006
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
2007
+ const end = length === undefined ? reader.len : reader.pos + length;
2008
+ const message = createBaseRetrieveResponse();
2009
+ while (reader.pos < end) {
2010
+ const tag = reader.uint32();
2011
+ switch (tag >>> 3) {
2012
+ case 1: {
2013
+ if (tag !== 10) {
2014
+ break;
2015
+ }
2016
+ message.threads.push(exports.RetrievedThread.decode(reader, reader.uint32()));
2017
+ continue;
2018
+ }
2019
+ case 2: {
2020
+ if (tag !== 18) {
2021
+ break;
2022
+ }
2023
+ message.plan = exports.RetrievalPlan.decode(reader, reader.uint32());
2024
+ continue;
2025
+ }
2026
+ }
2027
+ if ((tag & 7) === 4 || tag === 0) {
2028
+ break;
2029
+ }
2030
+ reader.skip(tag & 7);
2031
+ }
2032
+ return message;
2033
+ },
2034
+ fromJSON(object) {
2035
+ return {
2036
+ threads: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.threads)
2037
+ ? object.threads.map((e) => exports.RetrievedThread.fromJSON(e))
2038
+ : [],
2039
+ plan: isSet(object.plan) ? exports.RetrievalPlan.fromJSON(object.plan) : undefined,
2040
+ };
2041
+ },
2042
+ toJSON(message) {
2043
+ var _a;
2044
+ const obj = {};
2045
+ if ((_a = message.threads) === null || _a === void 0 ? void 0 : _a.length) {
2046
+ obj.threads = message.threads.map((e) => exports.RetrievedThread.toJSON(e));
2047
+ }
2048
+ if (message.plan !== undefined) {
2049
+ obj.plan = exports.RetrievalPlan.toJSON(message.plan);
2050
+ }
2051
+ return obj;
2052
+ },
2053
+ create(base) {
2054
+ return exports.RetrieveResponse.fromPartial(base !== null && base !== void 0 ? base : {});
2055
+ },
2056
+ fromPartial(object) {
2057
+ var _a;
2058
+ const message = createBaseRetrieveResponse();
2059
+ message.threads = ((_a = object.threads) === null || _a === void 0 ? void 0 : _a.map((e) => exports.RetrievedThread.fromPartial(e))) || [];
2060
+ message.plan = (object.plan !== undefined && object.plan !== null)
2061
+ ? exports.RetrievalPlan.fromPartial(object.plan)
2062
+ : undefined;
2063
+ return message;
2064
+ },
2065
+ };
2066
+ function createBaseSearchDocumentsRequest() {
2067
+ return { organizationId: "", query: "", constraints: undefined, filters: undefined, pageSize: 0, pageToken: "" };
2068
+ }
2069
+ exports.SearchDocumentsRequest = {
2070
+ encode(message, writer = new wire_1.BinaryWriter()) {
2071
+ if (message.organizationId !== "") {
2072
+ writer.uint32(10).string(message.organizationId);
2073
+ }
2074
+ if (message.query !== "") {
2075
+ writer.uint32(18).string(message.query);
2076
+ }
2077
+ if (message.constraints !== undefined) {
2078
+ exports.RetrievalConstraints.encode(message.constraints, writer.uint32(26).fork()).join();
2079
+ }
2080
+ if (message.filters !== undefined) {
2081
+ exports.DocumentSearchFilters.encode(message.filters, writer.uint32(34).fork()).join();
2082
+ }
2083
+ if (message.pageSize !== 0) {
2084
+ writer.uint32(40).int32(message.pageSize);
2085
+ }
2086
+ if (message.pageToken !== "") {
2087
+ writer.uint32(50).string(message.pageToken);
2088
+ }
2089
+ return writer;
2090
+ },
2091
+ decode(input, length) {
2092
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
2093
+ const end = length === undefined ? reader.len : reader.pos + length;
2094
+ const message = createBaseSearchDocumentsRequest();
2095
+ while (reader.pos < end) {
2096
+ const tag = reader.uint32();
2097
+ switch (tag >>> 3) {
2098
+ case 1: {
2099
+ if (tag !== 10) {
2100
+ break;
2101
+ }
2102
+ message.organizationId = reader.string();
2103
+ continue;
2104
+ }
2105
+ case 2: {
2106
+ if (tag !== 18) {
2107
+ break;
2108
+ }
2109
+ message.query = reader.string();
2110
+ continue;
2111
+ }
2112
+ case 3: {
2113
+ if (tag !== 26) {
2114
+ break;
2115
+ }
2116
+ message.constraints = exports.RetrievalConstraints.decode(reader, reader.uint32());
2117
+ continue;
2118
+ }
2119
+ case 4: {
2120
+ if (tag !== 34) {
2121
+ break;
2122
+ }
2123
+ message.filters = exports.DocumentSearchFilters.decode(reader, reader.uint32());
2124
+ continue;
2125
+ }
2126
+ case 5: {
2127
+ if (tag !== 40) {
2128
+ break;
2129
+ }
2130
+ message.pageSize = reader.int32();
2131
+ continue;
2132
+ }
2133
+ case 6: {
2134
+ if (tag !== 50) {
2135
+ break;
2136
+ }
2137
+ message.pageToken = reader.string();
2138
+ continue;
2139
+ }
2140
+ }
2141
+ if ((tag & 7) === 4 || tag === 0) {
2142
+ break;
2143
+ }
2144
+ reader.skip(tag & 7);
2145
+ }
2146
+ return message;
2147
+ },
2148
+ fromJSON(object) {
2149
+ return {
2150
+ organizationId: isSet(object.organizationId)
2151
+ ? globalThis.String(object.organizationId)
2152
+ : isSet(object.organization_id)
2153
+ ? globalThis.String(object.organization_id)
2154
+ : "",
2155
+ query: isSet(object.query) ? globalThis.String(object.query) : "",
2156
+ constraints: isSet(object.constraints) ? exports.RetrievalConstraints.fromJSON(object.constraints) : undefined,
2157
+ filters: isSet(object.filters) ? exports.DocumentSearchFilters.fromJSON(object.filters) : undefined,
2158
+ pageSize: isSet(object.pageSize)
2159
+ ? globalThis.Number(object.pageSize)
2160
+ : isSet(object.page_size)
2161
+ ? globalThis.Number(object.page_size)
2162
+ : 0,
2163
+ pageToken: isSet(object.pageToken)
2164
+ ? globalThis.String(object.pageToken)
2165
+ : isSet(object.page_token)
2166
+ ? globalThis.String(object.page_token)
2167
+ : "",
2168
+ };
2169
+ },
2170
+ toJSON(message) {
2171
+ const obj = {};
2172
+ if (message.organizationId !== "") {
2173
+ obj.organizationId = message.organizationId;
2174
+ }
2175
+ if (message.query !== "") {
2176
+ obj.query = message.query;
2177
+ }
2178
+ if (message.constraints !== undefined) {
2179
+ obj.constraints = exports.RetrievalConstraints.toJSON(message.constraints);
2180
+ }
2181
+ if (message.filters !== undefined) {
2182
+ obj.filters = exports.DocumentSearchFilters.toJSON(message.filters);
2183
+ }
2184
+ if (message.pageSize !== 0) {
2185
+ obj.pageSize = Math.round(message.pageSize);
2186
+ }
2187
+ if (message.pageToken !== "") {
2188
+ obj.pageToken = message.pageToken;
2189
+ }
2190
+ return obj;
2191
+ },
2192
+ create(base) {
2193
+ return exports.SearchDocumentsRequest.fromPartial(base !== null && base !== void 0 ? base : {});
2194
+ },
2195
+ fromPartial(object) {
2196
+ var _a, _b, _c, _d;
2197
+ const message = createBaseSearchDocumentsRequest();
2198
+ message.organizationId = (_a = object.organizationId) !== null && _a !== void 0 ? _a : "";
2199
+ message.query = (_b = object.query) !== null && _b !== void 0 ? _b : "";
2200
+ message.constraints = (object.constraints !== undefined && object.constraints !== null)
2201
+ ? exports.RetrievalConstraints.fromPartial(object.constraints)
2202
+ : undefined;
2203
+ message.filters = (object.filters !== undefined && object.filters !== null)
2204
+ ? exports.DocumentSearchFilters.fromPartial(object.filters)
2205
+ : undefined;
2206
+ message.pageSize = (_c = object.pageSize) !== null && _c !== void 0 ? _c : 0;
2207
+ message.pageToken = (_d = object.pageToken) !== null && _d !== void 0 ? _d : "";
2208
+ return message;
2209
+ },
2210
+ };
2211
+ function createBaseSearchDocumentsResponse() {
2212
+ return { documents: [], plan: undefined, nextPageToken: "" };
2213
+ }
2214
+ exports.SearchDocumentsResponse = {
2215
+ encode(message, writer = new wire_1.BinaryWriter()) {
2216
+ for (const v of message.documents) {
2217
+ exports.RetrievedDocument.encode(v, writer.uint32(10).fork()).join();
2218
+ }
2219
+ if (message.plan !== undefined) {
2220
+ exports.RetrievalPlan.encode(message.plan, writer.uint32(18).fork()).join();
2221
+ }
2222
+ if (message.nextPageToken !== "") {
2223
+ writer.uint32(26).string(message.nextPageToken);
2224
+ }
2225
+ return writer;
2226
+ },
2227
+ decode(input, length) {
2228
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
2229
+ const end = length === undefined ? reader.len : reader.pos + length;
2230
+ const message = createBaseSearchDocumentsResponse();
2231
+ while (reader.pos < end) {
2232
+ const tag = reader.uint32();
2233
+ switch (tag >>> 3) {
2234
+ case 1: {
2235
+ if (tag !== 10) {
2236
+ break;
2237
+ }
2238
+ message.documents.push(exports.RetrievedDocument.decode(reader, reader.uint32()));
2239
+ continue;
2240
+ }
2241
+ case 2: {
2242
+ if (tag !== 18) {
2243
+ break;
2244
+ }
2245
+ message.plan = exports.RetrievalPlan.decode(reader, reader.uint32());
2246
+ continue;
2247
+ }
2248
+ case 3: {
2249
+ if (tag !== 26) {
2250
+ break;
2251
+ }
2252
+ message.nextPageToken = reader.string();
2253
+ continue;
2254
+ }
2255
+ }
2256
+ if ((tag & 7) === 4 || tag === 0) {
2257
+ break;
2258
+ }
2259
+ reader.skip(tag & 7);
2260
+ }
2261
+ return message;
2262
+ },
2263
+ fromJSON(object) {
2264
+ return {
2265
+ documents: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.documents)
2266
+ ? object.documents.map((e) => exports.RetrievedDocument.fromJSON(e))
2267
+ : [],
2268
+ plan: isSet(object.plan) ? exports.RetrievalPlan.fromJSON(object.plan) : undefined,
2269
+ nextPageToken: isSet(object.nextPageToken)
2270
+ ? globalThis.String(object.nextPageToken)
2271
+ : isSet(object.next_page_token)
2272
+ ? globalThis.String(object.next_page_token)
2273
+ : "",
2274
+ };
2275
+ },
2276
+ toJSON(message) {
2277
+ var _a;
2278
+ const obj = {};
2279
+ if ((_a = message.documents) === null || _a === void 0 ? void 0 : _a.length) {
2280
+ obj.documents = message.documents.map((e) => exports.RetrievedDocument.toJSON(e));
2281
+ }
2282
+ if (message.plan !== undefined) {
2283
+ obj.plan = exports.RetrievalPlan.toJSON(message.plan);
2284
+ }
2285
+ if (message.nextPageToken !== "") {
2286
+ obj.nextPageToken = message.nextPageToken;
2287
+ }
2288
+ return obj;
2289
+ },
2290
+ create(base) {
2291
+ return exports.SearchDocumentsResponse.fromPartial(base !== null && base !== void 0 ? base : {});
2292
+ },
2293
+ fromPartial(object) {
2294
+ var _a;
2295
+ var _b;
2296
+ const message = createBaseSearchDocumentsResponse();
2297
+ message.documents = ((_a = object.documents) === null || _a === void 0 ? void 0 : _a.map((e) => exports.RetrievedDocument.fromPartial(e))) || [];
2298
+ message.plan = (object.plan !== undefined && object.plan !== null)
2299
+ ? exports.RetrievalPlan.fromPartial(object.plan)
2300
+ : undefined;
2301
+ message.nextPageToken = (_b = object.nextPageToken) !== null && _b !== void 0 ? _b : "";
2302
+ return message;
2303
+ },
2304
+ };
2305
+ function createBaseExplainRetrievalRequest() {
2306
+ return { organizationId: "", query: "", constraints: undefined, sessionId: "" };
2307
+ }
2308
+ exports.ExplainRetrievalRequest = {
2309
+ encode(message, writer = new wire_1.BinaryWriter()) {
2310
+ if (message.organizationId !== "") {
2311
+ writer.uint32(10).string(message.organizationId);
2312
+ }
2313
+ if (message.query !== "") {
2314
+ writer.uint32(18).string(message.query);
2315
+ }
2316
+ if (message.constraints !== undefined) {
2317
+ exports.RetrievalConstraints.encode(message.constraints, writer.uint32(26).fork()).join();
2318
+ }
2319
+ if (message.sessionId !== "") {
2320
+ writer.uint32(34).string(message.sessionId);
2321
+ }
2322
+ return writer;
2323
+ },
2324
+ decode(input, length) {
2325
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
2326
+ const end = length === undefined ? reader.len : reader.pos + length;
2327
+ const message = createBaseExplainRetrievalRequest();
2328
+ while (reader.pos < end) {
2329
+ const tag = reader.uint32();
2330
+ switch (tag >>> 3) {
2331
+ case 1: {
2332
+ if (tag !== 10) {
2333
+ break;
2334
+ }
2335
+ message.organizationId = reader.string();
2336
+ continue;
2337
+ }
2338
+ case 2: {
2339
+ if (tag !== 18) {
2340
+ break;
2341
+ }
2342
+ message.query = reader.string();
2343
+ continue;
2344
+ }
2345
+ case 3: {
2346
+ if (tag !== 26) {
2347
+ break;
2348
+ }
2349
+ message.constraints = exports.RetrievalConstraints.decode(reader, reader.uint32());
2350
+ continue;
2351
+ }
2352
+ case 4: {
2353
+ if (tag !== 34) {
2354
+ break;
2355
+ }
2356
+ message.sessionId = reader.string();
2357
+ continue;
2358
+ }
2359
+ }
2360
+ if ((tag & 7) === 4 || tag === 0) {
2361
+ break;
2362
+ }
2363
+ reader.skip(tag & 7);
2364
+ }
2365
+ return message;
2366
+ },
2367
+ fromJSON(object) {
2368
+ return {
2369
+ organizationId: isSet(object.organizationId)
2370
+ ? globalThis.String(object.organizationId)
2371
+ : isSet(object.organization_id)
2372
+ ? globalThis.String(object.organization_id)
2373
+ : "",
2374
+ query: isSet(object.query) ? globalThis.String(object.query) : "",
2375
+ constraints: isSet(object.constraints) ? exports.RetrievalConstraints.fromJSON(object.constraints) : undefined,
2376
+ sessionId: isSet(object.sessionId)
2377
+ ? globalThis.String(object.sessionId)
2378
+ : isSet(object.session_id)
2379
+ ? globalThis.String(object.session_id)
2380
+ : "",
2381
+ };
2382
+ },
2383
+ toJSON(message) {
2384
+ const obj = {};
2385
+ if (message.organizationId !== "") {
2386
+ obj.organizationId = message.organizationId;
2387
+ }
2388
+ if (message.query !== "") {
2389
+ obj.query = message.query;
2390
+ }
2391
+ if (message.constraints !== undefined) {
2392
+ obj.constraints = exports.RetrievalConstraints.toJSON(message.constraints);
2393
+ }
2394
+ if (message.sessionId !== "") {
2395
+ obj.sessionId = message.sessionId;
2396
+ }
2397
+ return obj;
2398
+ },
2399
+ create(base) {
2400
+ return exports.ExplainRetrievalRequest.fromPartial(base !== null && base !== void 0 ? base : {});
2401
+ },
2402
+ fromPartial(object) {
2403
+ var _a, _b, _c;
2404
+ const message = createBaseExplainRetrievalRequest();
2405
+ message.organizationId = (_a = object.organizationId) !== null && _a !== void 0 ? _a : "";
2406
+ message.query = (_b = object.query) !== null && _b !== void 0 ? _b : "";
2407
+ message.constraints = (object.constraints !== undefined && object.constraints !== null)
2408
+ ? exports.RetrievalConstraints.fromPartial(object.constraints)
2409
+ : undefined;
2410
+ message.sessionId = (_c = object.sessionId) !== null && _c !== void 0 ? _c : "";
2411
+ return message;
2412
+ },
2413
+ };
2414
+ function createBaseSubQueryResult() {
2415
+ return { subQuery: undefined, threads: [] };
2416
+ }
2417
+ exports.SubQueryResult = {
2418
+ encode(message, writer = new wire_1.BinaryWriter()) {
2419
+ if (message.subQuery !== undefined) {
2420
+ exports.SubQuery.encode(message.subQuery, writer.uint32(10).fork()).join();
2421
+ }
2422
+ for (const v of message.threads) {
2423
+ exports.RetrievedThread.encode(v, writer.uint32(18).fork()).join();
2424
+ }
2425
+ return writer;
2426
+ },
2427
+ decode(input, length) {
2428
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
2429
+ const end = length === undefined ? reader.len : reader.pos + length;
2430
+ const message = createBaseSubQueryResult();
2431
+ while (reader.pos < end) {
2432
+ const tag = reader.uint32();
2433
+ switch (tag >>> 3) {
2434
+ case 1: {
2435
+ if (tag !== 10) {
2436
+ break;
2437
+ }
2438
+ message.subQuery = exports.SubQuery.decode(reader, reader.uint32());
2439
+ continue;
2440
+ }
2441
+ case 2: {
2442
+ if (tag !== 18) {
2443
+ break;
2444
+ }
2445
+ message.threads.push(exports.RetrievedThread.decode(reader, reader.uint32()));
2446
+ continue;
2447
+ }
2448
+ }
2449
+ if ((tag & 7) === 4 || tag === 0) {
2450
+ break;
2451
+ }
2452
+ reader.skip(tag & 7);
2453
+ }
2454
+ return message;
2455
+ },
2456
+ fromJSON(object) {
2457
+ return {
2458
+ subQuery: isSet(object.subQuery)
2459
+ ? exports.SubQuery.fromJSON(object.subQuery)
2460
+ : isSet(object.sub_query)
2461
+ ? exports.SubQuery.fromJSON(object.sub_query)
2462
+ : undefined,
2463
+ threads: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.threads)
2464
+ ? object.threads.map((e) => exports.RetrievedThread.fromJSON(e))
2465
+ : [],
2466
+ };
2467
+ },
2468
+ toJSON(message) {
2469
+ var _a;
2470
+ const obj = {};
2471
+ if (message.subQuery !== undefined) {
2472
+ obj.subQuery = exports.SubQuery.toJSON(message.subQuery);
2473
+ }
2474
+ if ((_a = message.threads) === null || _a === void 0 ? void 0 : _a.length) {
2475
+ obj.threads = message.threads.map((e) => exports.RetrievedThread.toJSON(e));
2476
+ }
2477
+ return obj;
2478
+ },
2479
+ create(base) {
2480
+ return exports.SubQueryResult.fromPartial(base !== null && base !== void 0 ? base : {});
2481
+ },
2482
+ fromPartial(object) {
2483
+ var _a;
2484
+ const message = createBaseSubQueryResult();
2485
+ message.subQuery = (object.subQuery !== undefined && object.subQuery !== null)
2486
+ ? exports.SubQuery.fromPartial(object.subQuery)
2487
+ : undefined;
2488
+ message.threads = ((_a = object.threads) === null || _a === void 0 ? void 0 : _a.map((e) => exports.RetrievedThread.fromPartial(e))) || [];
2489
+ return message;
2490
+ },
2491
+ };
2492
+ function createBaseExplainRetrievalResponse() {
2493
+ return { plan: undefined, subQueryResults: [], finalThreads: [] };
2494
+ }
2495
+ exports.ExplainRetrievalResponse = {
2496
+ encode(message, writer = new wire_1.BinaryWriter()) {
2497
+ if (message.plan !== undefined) {
2498
+ exports.RetrievalPlan.encode(message.plan, writer.uint32(10).fork()).join();
2499
+ }
2500
+ for (const v of message.subQueryResults) {
2501
+ exports.SubQueryResult.encode(v, writer.uint32(18).fork()).join();
2502
+ }
2503
+ for (const v of message.finalThreads) {
2504
+ exports.RetrievedThread.encode(v, writer.uint32(26).fork()).join();
2505
+ }
2506
+ return writer;
2507
+ },
2508
+ decode(input, length) {
2509
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
2510
+ const end = length === undefined ? reader.len : reader.pos + length;
2511
+ const message = createBaseExplainRetrievalResponse();
2512
+ while (reader.pos < end) {
2513
+ const tag = reader.uint32();
2514
+ switch (tag >>> 3) {
2515
+ case 1: {
2516
+ if (tag !== 10) {
2517
+ break;
2518
+ }
2519
+ message.plan = exports.RetrievalPlan.decode(reader, reader.uint32());
2520
+ continue;
2521
+ }
2522
+ case 2: {
2523
+ if (tag !== 18) {
2524
+ break;
2525
+ }
2526
+ message.subQueryResults.push(exports.SubQueryResult.decode(reader, reader.uint32()));
2527
+ continue;
2528
+ }
2529
+ case 3: {
2530
+ if (tag !== 26) {
2531
+ break;
2532
+ }
2533
+ message.finalThreads.push(exports.RetrievedThread.decode(reader, reader.uint32()));
2534
+ continue;
2535
+ }
2536
+ }
2537
+ if ((tag & 7) === 4 || tag === 0) {
2538
+ break;
2539
+ }
2540
+ reader.skip(tag & 7);
2541
+ }
2542
+ return message;
2543
+ },
2544
+ fromJSON(object) {
2545
+ return {
2546
+ plan: isSet(object.plan) ? exports.RetrievalPlan.fromJSON(object.plan) : undefined,
2547
+ subQueryResults: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.subQueryResults)
2548
+ ? object.subQueryResults.map((e) => exports.SubQueryResult.fromJSON(e))
2549
+ : globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.sub_query_results)
2550
+ ? object.sub_query_results.map((e) => exports.SubQueryResult.fromJSON(e))
2551
+ : [],
2552
+ finalThreads: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.finalThreads)
2553
+ ? object.finalThreads.map((e) => exports.RetrievedThread.fromJSON(e))
2554
+ : globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.final_threads)
2555
+ ? object.final_threads.map((e) => exports.RetrievedThread.fromJSON(e))
2556
+ : [],
2557
+ };
2558
+ },
2559
+ toJSON(message) {
2560
+ var _a, _b;
2561
+ const obj = {};
2562
+ if (message.plan !== undefined) {
2563
+ obj.plan = exports.RetrievalPlan.toJSON(message.plan);
2564
+ }
2565
+ if ((_a = message.subQueryResults) === null || _a === void 0 ? void 0 : _a.length) {
2566
+ obj.subQueryResults = message.subQueryResults.map((e) => exports.SubQueryResult.toJSON(e));
2567
+ }
2568
+ if ((_b = message.finalThreads) === null || _b === void 0 ? void 0 : _b.length) {
2569
+ obj.finalThreads = message.finalThreads.map((e) => exports.RetrievedThread.toJSON(e));
2570
+ }
2571
+ return obj;
2572
+ },
2573
+ create(base) {
2574
+ return exports.ExplainRetrievalResponse.fromPartial(base !== null && base !== void 0 ? base : {});
2575
+ },
2576
+ fromPartial(object) {
2577
+ var _a, _b;
2578
+ const message = createBaseExplainRetrievalResponse();
2579
+ message.plan = (object.plan !== undefined && object.plan !== null)
2580
+ ? exports.RetrievalPlan.fromPartial(object.plan)
2581
+ : undefined;
2582
+ message.subQueryResults = ((_a = object.subQueryResults) === null || _a === void 0 ? void 0 : _a.map((e) => exports.SubQueryResult.fromPartial(e))) || [];
2583
+ message.finalThreads = ((_b = object.finalThreads) === null || _b === void 0 ? void 0 : _b.map((e) => exports.RetrievedThread.fromPartial(e))) || [];
2584
+ return message;
2585
+ },
2586
+ };
2587
+ function toTimestamp(date) {
2588
+ const seconds = Math.trunc(date.getTime() / 1000);
2589
+ const nanos = (date.getTime() % 1000) * 1000000;
2590
+ return { seconds, nanos };
2591
+ }
2592
+ function fromTimestamp(t) {
2593
+ let millis = (t.seconds || 0) * 1000;
2594
+ millis += (t.nanos || 0) / 1000000;
2595
+ return new globalThis.Date(millis);
2596
+ }
2597
+ function fromJsonTimestamp(o) {
2598
+ if (o instanceof globalThis.Date) {
2599
+ return o;
2600
+ }
2601
+ else if (typeof o === "string") {
2602
+ return new globalThis.Date(o);
2603
+ }
2604
+ else {
2605
+ return fromTimestamp(timestamp_pb_1.Timestamp.fromJSON(o));
2606
+ }
2607
+ }
2608
+ function isObject(value) {
2609
+ return typeof value === "object" && value !== null;
2610
+ }
2611
+ function isSet(value) {
2612
+ return value !== null && value !== undefined;
2613
+ }