weave-typescript 0.27.0 → 0.28.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,1885 @@
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.RetrieveResponse = exports.RetrieveRequest = 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 createBaseRetrieveRequest() {
1395
+ return { organizationId: "", query: "", constraints: undefined, sessionId: "" };
1396
+ }
1397
+ exports.RetrieveRequest = {
1398
+ encode(message, writer = new wire_1.BinaryWriter()) {
1399
+ if (message.organizationId !== "") {
1400
+ writer.uint32(10).string(message.organizationId);
1401
+ }
1402
+ if (message.query !== "") {
1403
+ writer.uint32(18).string(message.query);
1404
+ }
1405
+ if (message.constraints !== undefined) {
1406
+ exports.RetrievalConstraints.encode(message.constraints, writer.uint32(26).fork()).join();
1407
+ }
1408
+ if (message.sessionId !== "") {
1409
+ writer.uint32(34).string(message.sessionId);
1410
+ }
1411
+ return writer;
1412
+ },
1413
+ decode(input, length) {
1414
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
1415
+ const end = length === undefined ? reader.len : reader.pos + length;
1416
+ const message = createBaseRetrieveRequest();
1417
+ while (reader.pos < end) {
1418
+ const tag = reader.uint32();
1419
+ switch (tag >>> 3) {
1420
+ case 1: {
1421
+ if (tag !== 10) {
1422
+ break;
1423
+ }
1424
+ message.organizationId = reader.string();
1425
+ continue;
1426
+ }
1427
+ case 2: {
1428
+ if (tag !== 18) {
1429
+ break;
1430
+ }
1431
+ message.query = reader.string();
1432
+ continue;
1433
+ }
1434
+ case 3: {
1435
+ if (tag !== 26) {
1436
+ break;
1437
+ }
1438
+ message.constraints = exports.RetrievalConstraints.decode(reader, reader.uint32());
1439
+ continue;
1440
+ }
1441
+ case 4: {
1442
+ if (tag !== 34) {
1443
+ break;
1444
+ }
1445
+ message.sessionId = reader.string();
1446
+ continue;
1447
+ }
1448
+ }
1449
+ if ((tag & 7) === 4 || tag === 0) {
1450
+ break;
1451
+ }
1452
+ reader.skip(tag & 7);
1453
+ }
1454
+ return message;
1455
+ },
1456
+ fromJSON(object) {
1457
+ return {
1458
+ organizationId: isSet(object.organizationId)
1459
+ ? globalThis.String(object.organizationId)
1460
+ : isSet(object.organization_id)
1461
+ ? globalThis.String(object.organization_id)
1462
+ : "",
1463
+ query: isSet(object.query) ? globalThis.String(object.query) : "",
1464
+ constraints: isSet(object.constraints) ? exports.RetrievalConstraints.fromJSON(object.constraints) : undefined,
1465
+ sessionId: isSet(object.sessionId)
1466
+ ? globalThis.String(object.sessionId)
1467
+ : isSet(object.session_id)
1468
+ ? globalThis.String(object.session_id)
1469
+ : "",
1470
+ };
1471
+ },
1472
+ toJSON(message) {
1473
+ const obj = {};
1474
+ if (message.organizationId !== "") {
1475
+ obj.organizationId = message.organizationId;
1476
+ }
1477
+ if (message.query !== "") {
1478
+ obj.query = message.query;
1479
+ }
1480
+ if (message.constraints !== undefined) {
1481
+ obj.constraints = exports.RetrievalConstraints.toJSON(message.constraints);
1482
+ }
1483
+ if (message.sessionId !== "") {
1484
+ obj.sessionId = message.sessionId;
1485
+ }
1486
+ return obj;
1487
+ },
1488
+ create(base) {
1489
+ return exports.RetrieveRequest.fromPartial(base !== null && base !== void 0 ? base : {});
1490
+ },
1491
+ fromPartial(object) {
1492
+ var _a, _b, _c;
1493
+ const message = createBaseRetrieveRequest();
1494
+ message.organizationId = (_a = object.organizationId) !== null && _a !== void 0 ? _a : "";
1495
+ message.query = (_b = object.query) !== null && _b !== void 0 ? _b : "";
1496
+ message.constraints = (object.constraints !== undefined && object.constraints !== null)
1497
+ ? exports.RetrievalConstraints.fromPartial(object.constraints)
1498
+ : undefined;
1499
+ message.sessionId = (_c = object.sessionId) !== null && _c !== void 0 ? _c : "";
1500
+ return message;
1501
+ },
1502
+ };
1503
+ function createBaseRetrieveResponse() {
1504
+ return { threads: [], plan: undefined };
1505
+ }
1506
+ exports.RetrieveResponse = {
1507
+ encode(message, writer = new wire_1.BinaryWriter()) {
1508
+ for (const v of message.threads) {
1509
+ exports.RetrievedThread.encode(v, writer.uint32(10).fork()).join();
1510
+ }
1511
+ if (message.plan !== undefined) {
1512
+ exports.RetrievalPlan.encode(message.plan, writer.uint32(18).fork()).join();
1513
+ }
1514
+ return writer;
1515
+ },
1516
+ decode(input, length) {
1517
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
1518
+ const end = length === undefined ? reader.len : reader.pos + length;
1519
+ const message = createBaseRetrieveResponse();
1520
+ while (reader.pos < end) {
1521
+ const tag = reader.uint32();
1522
+ switch (tag >>> 3) {
1523
+ case 1: {
1524
+ if (tag !== 10) {
1525
+ break;
1526
+ }
1527
+ message.threads.push(exports.RetrievedThread.decode(reader, reader.uint32()));
1528
+ continue;
1529
+ }
1530
+ case 2: {
1531
+ if (tag !== 18) {
1532
+ break;
1533
+ }
1534
+ message.plan = exports.RetrievalPlan.decode(reader, reader.uint32());
1535
+ continue;
1536
+ }
1537
+ }
1538
+ if ((tag & 7) === 4 || tag === 0) {
1539
+ break;
1540
+ }
1541
+ reader.skip(tag & 7);
1542
+ }
1543
+ return message;
1544
+ },
1545
+ fromJSON(object) {
1546
+ return {
1547
+ threads: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.threads)
1548
+ ? object.threads.map((e) => exports.RetrievedThread.fromJSON(e))
1549
+ : [],
1550
+ plan: isSet(object.plan) ? exports.RetrievalPlan.fromJSON(object.plan) : undefined,
1551
+ };
1552
+ },
1553
+ toJSON(message) {
1554
+ var _a;
1555
+ const obj = {};
1556
+ if ((_a = message.threads) === null || _a === void 0 ? void 0 : _a.length) {
1557
+ obj.threads = message.threads.map((e) => exports.RetrievedThread.toJSON(e));
1558
+ }
1559
+ if (message.plan !== undefined) {
1560
+ obj.plan = exports.RetrievalPlan.toJSON(message.plan);
1561
+ }
1562
+ return obj;
1563
+ },
1564
+ create(base) {
1565
+ return exports.RetrieveResponse.fromPartial(base !== null && base !== void 0 ? base : {});
1566
+ },
1567
+ fromPartial(object) {
1568
+ var _a;
1569
+ const message = createBaseRetrieveResponse();
1570
+ message.threads = ((_a = object.threads) === null || _a === void 0 ? void 0 : _a.map((e) => exports.RetrievedThread.fromPartial(e))) || [];
1571
+ message.plan = (object.plan !== undefined && object.plan !== null)
1572
+ ? exports.RetrievalPlan.fromPartial(object.plan)
1573
+ : undefined;
1574
+ return message;
1575
+ },
1576
+ };
1577
+ function createBaseExplainRetrievalRequest() {
1578
+ return { organizationId: "", query: "", constraints: undefined, sessionId: "" };
1579
+ }
1580
+ exports.ExplainRetrievalRequest = {
1581
+ encode(message, writer = new wire_1.BinaryWriter()) {
1582
+ if (message.organizationId !== "") {
1583
+ writer.uint32(10).string(message.organizationId);
1584
+ }
1585
+ if (message.query !== "") {
1586
+ writer.uint32(18).string(message.query);
1587
+ }
1588
+ if (message.constraints !== undefined) {
1589
+ exports.RetrievalConstraints.encode(message.constraints, writer.uint32(26).fork()).join();
1590
+ }
1591
+ if (message.sessionId !== "") {
1592
+ writer.uint32(34).string(message.sessionId);
1593
+ }
1594
+ return writer;
1595
+ },
1596
+ decode(input, length) {
1597
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
1598
+ const end = length === undefined ? reader.len : reader.pos + length;
1599
+ const message = createBaseExplainRetrievalRequest();
1600
+ while (reader.pos < end) {
1601
+ const tag = reader.uint32();
1602
+ switch (tag >>> 3) {
1603
+ case 1: {
1604
+ if (tag !== 10) {
1605
+ break;
1606
+ }
1607
+ message.organizationId = reader.string();
1608
+ continue;
1609
+ }
1610
+ case 2: {
1611
+ if (tag !== 18) {
1612
+ break;
1613
+ }
1614
+ message.query = reader.string();
1615
+ continue;
1616
+ }
1617
+ case 3: {
1618
+ if (tag !== 26) {
1619
+ break;
1620
+ }
1621
+ message.constraints = exports.RetrievalConstraints.decode(reader, reader.uint32());
1622
+ continue;
1623
+ }
1624
+ case 4: {
1625
+ if (tag !== 34) {
1626
+ break;
1627
+ }
1628
+ message.sessionId = reader.string();
1629
+ continue;
1630
+ }
1631
+ }
1632
+ if ((tag & 7) === 4 || tag === 0) {
1633
+ break;
1634
+ }
1635
+ reader.skip(tag & 7);
1636
+ }
1637
+ return message;
1638
+ },
1639
+ fromJSON(object) {
1640
+ return {
1641
+ organizationId: isSet(object.organizationId)
1642
+ ? globalThis.String(object.organizationId)
1643
+ : isSet(object.organization_id)
1644
+ ? globalThis.String(object.organization_id)
1645
+ : "",
1646
+ query: isSet(object.query) ? globalThis.String(object.query) : "",
1647
+ constraints: isSet(object.constraints) ? exports.RetrievalConstraints.fromJSON(object.constraints) : undefined,
1648
+ sessionId: isSet(object.sessionId)
1649
+ ? globalThis.String(object.sessionId)
1650
+ : isSet(object.session_id)
1651
+ ? globalThis.String(object.session_id)
1652
+ : "",
1653
+ };
1654
+ },
1655
+ toJSON(message) {
1656
+ const obj = {};
1657
+ if (message.organizationId !== "") {
1658
+ obj.organizationId = message.organizationId;
1659
+ }
1660
+ if (message.query !== "") {
1661
+ obj.query = message.query;
1662
+ }
1663
+ if (message.constraints !== undefined) {
1664
+ obj.constraints = exports.RetrievalConstraints.toJSON(message.constraints);
1665
+ }
1666
+ if (message.sessionId !== "") {
1667
+ obj.sessionId = message.sessionId;
1668
+ }
1669
+ return obj;
1670
+ },
1671
+ create(base) {
1672
+ return exports.ExplainRetrievalRequest.fromPartial(base !== null && base !== void 0 ? base : {});
1673
+ },
1674
+ fromPartial(object) {
1675
+ var _a, _b, _c;
1676
+ const message = createBaseExplainRetrievalRequest();
1677
+ message.organizationId = (_a = object.organizationId) !== null && _a !== void 0 ? _a : "";
1678
+ message.query = (_b = object.query) !== null && _b !== void 0 ? _b : "";
1679
+ message.constraints = (object.constraints !== undefined && object.constraints !== null)
1680
+ ? exports.RetrievalConstraints.fromPartial(object.constraints)
1681
+ : undefined;
1682
+ message.sessionId = (_c = object.sessionId) !== null && _c !== void 0 ? _c : "";
1683
+ return message;
1684
+ },
1685
+ };
1686
+ function createBaseSubQueryResult() {
1687
+ return { subQuery: undefined, threads: [] };
1688
+ }
1689
+ exports.SubQueryResult = {
1690
+ encode(message, writer = new wire_1.BinaryWriter()) {
1691
+ if (message.subQuery !== undefined) {
1692
+ exports.SubQuery.encode(message.subQuery, writer.uint32(10).fork()).join();
1693
+ }
1694
+ for (const v of message.threads) {
1695
+ exports.RetrievedThread.encode(v, writer.uint32(18).fork()).join();
1696
+ }
1697
+ return writer;
1698
+ },
1699
+ decode(input, length) {
1700
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
1701
+ const end = length === undefined ? reader.len : reader.pos + length;
1702
+ const message = createBaseSubQueryResult();
1703
+ while (reader.pos < end) {
1704
+ const tag = reader.uint32();
1705
+ switch (tag >>> 3) {
1706
+ case 1: {
1707
+ if (tag !== 10) {
1708
+ break;
1709
+ }
1710
+ message.subQuery = exports.SubQuery.decode(reader, reader.uint32());
1711
+ continue;
1712
+ }
1713
+ case 2: {
1714
+ if (tag !== 18) {
1715
+ break;
1716
+ }
1717
+ message.threads.push(exports.RetrievedThread.decode(reader, reader.uint32()));
1718
+ continue;
1719
+ }
1720
+ }
1721
+ if ((tag & 7) === 4 || tag === 0) {
1722
+ break;
1723
+ }
1724
+ reader.skip(tag & 7);
1725
+ }
1726
+ return message;
1727
+ },
1728
+ fromJSON(object) {
1729
+ return {
1730
+ subQuery: isSet(object.subQuery)
1731
+ ? exports.SubQuery.fromJSON(object.subQuery)
1732
+ : isSet(object.sub_query)
1733
+ ? exports.SubQuery.fromJSON(object.sub_query)
1734
+ : undefined,
1735
+ threads: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.threads)
1736
+ ? object.threads.map((e) => exports.RetrievedThread.fromJSON(e))
1737
+ : [],
1738
+ };
1739
+ },
1740
+ toJSON(message) {
1741
+ var _a;
1742
+ const obj = {};
1743
+ if (message.subQuery !== undefined) {
1744
+ obj.subQuery = exports.SubQuery.toJSON(message.subQuery);
1745
+ }
1746
+ if ((_a = message.threads) === null || _a === void 0 ? void 0 : _a.length) {
1747
+ obj.threads = message.threads.map((e) => exports.RetrievedThread.toJSON(e));
1748
+ }
1749
+ return obj;
1750
+ },
1751
+ create(base) {
1752
+ return exports.SubQueryResult.fromPartial(base !== null && base !== void 0 ? base : {});
1753
+ },
1754
+ fromPartial(object) {
1755
+ var _a;
1756
+ const message = createBaseSubQueryResult();
1757
+ message.subQuery = (object.subQuery !== undefined && object.subQuery !== null)
1758
+ ? exports.SubQuery.fromPartial(object.subQuery)
1759
+ : undefined;
1760
+ message.threads = ((_a = object.threads) === null || _a === void 0 ? void 0 : _a.map((e) => exports.RetrievedThread.fromPartial(e))) || [];
1761
+ return message;
1762
+ },
1763
+ };
1764
+ function createBaseExplainRetrievalResponse() {
1765
+ return { plan: undefined, subQueryResults: [], finalThreads: [] };
1766
+ }
1767
+ exports.ExplainRetrievalResponse = {
1768
+ encode(message, writer = new wire_1.BinaryWriter()) {
1769
+ if (message.plan !== undefined) {
1770
+ exports.RetrievalPlan.encode(message.plan, writer.uint32(10).fork()).join();
1771
+ }
1772
+ for (const v of message.subQueryResults) {
1773
+ exports.SubQueryResult.encode(v, writer.uint32(18).fork()).join();
1774
+ }
1775
+ for (const v of message.finalThreads) {
1776
+ exports.RetrievedThread.encode(v, writer.uint32(26).fork()).join();
1777
+ }
1778
+ return writer;
1779
+ },
1780
+ decode(input, length) {
1781
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
1782
+ const end = length === undefined ? reader.len : reader.pos + length;
1783
+ const message = createBaseExplainRetrievalResponse();
1784
+ while (reader.pos < end) {
1785
+ const tag = reader.uint32();
1786
+ switch (tag >>> 3) {
1787
+ case 1: {
1788
+ if (tag !== 10) {
1789
+ break;
1790
+ }
1791
+ message.plan = exports.RetrievalPlan.decode(reader, reader.uint32());
1792
+ continue;
1793
+ }
1794
+ case 2: {
1795
+ if (tag !== 18) {
1796
+ break;
1797
+ }
1798
+ message.subQueryResults.push(exports.SubQueryResult.decode(reader, reader.uint32()));
1799
+ continue;
1800
+ }
1801
+ case 3: {
1802
+ if (tag !== 26) {
1803
+ break;
1804
+ }
1805
+ message.finalThreads.push(exports.RetrievedThread.decode(reader, reader.uint32()));
1806
+ continue;
1807
+ }
1808
+ }
1809
+ if ((tag & 7) === 4 || tag === 0) {
1810
+ break;
1811
+ }
1812
+ reader.skip(tag & 7);
1813
+ }
1814
+ return message;
1815
+ },
1816
+ fromJSON(object) {
1817
+ return {
1818
+ plan: isSet(object.plan) ? exports.RetrievalPlan.fromJSON(object.plan) : undefined,
1819
+ subQueryResults: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.subQueryResults)
1820
+ ? object.subQueryResults.map((e) => exports.SubQueryResult.fromJSON(e))
1821
+ : globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.sub_query_results)
1822
+ ? object.sub_query_results.map((e) => exports.SubQueryResult.fromJSON(e))
1823
+ : [],
1824
+ finalThreads: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.finalThreads)
1825
+ ? object.finalThreads.map((e) => exports.RetrievedThread.fromJSON(e))
1826
+ : globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.final_threads)
1827
+ ? object.final_threads.map((e) => exports.RetrievedThread.fromJSON(e))
1828
+ : [],
1829
+ };
1830
+ },
1831
+ toJSON(message) {
1832
+ var _a, _b;
1833
+ const obj = {};
1834
+ if (message.plan !== undefined) {
1835
+ obj.plan = exports.RetrievalPlan.toJSON(message.plan);
1836
+ }
1837
+ if ((_a = message.subQueryResults) === null || _a === void 0 ? void 0 : _a.length) {
1838
+ obj.subQueryResults = message.subQueryResults.map((e) => exports.SubQueryResult.toJSON(e));
1839
+ }
1840
+ if ((_b = message.finalThreads) === null || _b === void 0 ? void 0 : _b.length) {
1841
+ obj.finalThreads = message.finalThreads.map((e) => exports.RetrievedThread.toJSON(e));
1842
+ }
1843
+ return obj;
1844
+ },
1845
+ create(base) {
1846
+ return exports.ExplainRetrievalResponse.fromPartial(base !== null && base !== void 0 ? base : {});
1847
+ },
1848
+ fromPartial(object) {
1849
+ var _a, _b;
1850
+ const message = createBaseExplainRetrievalResponse();
1851
+ message.plan = (object.plan !== undefined && object.plan !== null)
1852
+ ? exports.RetrievalPlan.fromPartial(object.plan)
1853
+ : undefined;
1854
+ message.subQueryResults = ((_a = object.subQueryResults) === null || _a === void 0 ? void 0 : _a.map((e) => exports.SubQueryResult.fromPartial(e))) || [];
1855
+ message.finalThreads = ((_b = object.finalThreads) === null || _b === void 0 ? void 0 : _b.map((e) => exports.RetrievedThread.fromPartial(e))) || [];
1856
+ return message;
1857
+ },
1858
+ };
1859
+ function toTimestamp(date) {
1860
+ const seconds = Math.trunc(date.getTime() / 1000);
1861
+ const nanos = (date.getTime() % 1000) * 1000000;
1862
+ return { seconds, nanos };
1863
+ }
1864
+ function fromTimestamp(t) {
1865
+ let millis = (t.seconds || 0) * 1000;
1866
+ millis += (t.nanos || 0) / 1000000;
1867
+ return new globalThis.Date(millis);
1868
+ }
1869
+ function fromJsonTimestamp(o) {
1870
+ if (o instanceof globalThis.Date) {
1871
+ return o;
1872
+ }
1873
+ else if (typeof o === "string") {
1874
+ return new globalThis.Date(o);
1875
+ }
1876
+ else {
1877
+ return fromTimestamp(timestamp_pb_1.Timestamp.fromJSON(o));
1878
+ }
1879
+ }
1880
+ function isObject(value) {
1881
+ return typeof value === "object" && value !== null;
1882
+ }
1883
+ function isSet(value) {
1884
+ return value !== null && value !== undefined;
1885
+ }