@pairsystems/goodmem-client 1.0.0-dev.cb052d6 → 1.0.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.
- package/README.md +181 -4
- package/dist/api/LLMsApi.js +263 -0
- package/dist/api/MemoriesApi.js +2 -2
- package/dist/index.js +63 -0
- package/dist/model/CreateLLMResponse.js +146 -0
- package/dist/model/LLMCapabilities.js +132 -0
- package/dist/model/LLMCreationRequest.js +318 -0
- package/dist/model/LLMProviderType.js +83 -0
- package/dist/model/LLMResponse.js +366 -0
- package/dist/model/LLMSamplingParams.js +145 -0
- package/dist/model/LLMUpdateRequest.js +274 -0
- package/dist/model/ListLLMsResponse.js +132 -0
- package/dist/streaming.js +246 -43
- package/package.json +1 -1
package/dist/streaming.js
CHANGED
|
@@ -113,6 +113,26 @@ var StreamingClient = exports.StreamingClient = /*#__PURE__*/function () {
|
|
|
113
113
|
if (request.generateAbstract !== undefined) {
|
|
114
114
|
params.append('generateAbstract', request.generateAbstract.toString());
|
|
115
115
|
}
|
|
116
|
+
|
|
117
|
+
// Add ChatPostProcessor parameters
|
|
118
|
+
if (request.ppLlmId) {
|
|
119
|
+
params.append('ppLlmId', request.ppLlmId);
|
|
120
|
+
}
|
|
121
|
+
if (request.ppRerankerId) {
|
|
122
|
+
params.append('ppRerankerId', request.ppRerankerId);
|
|
123
|
+
}
|
|
124
|
+
if (request.ppRelevanceThreshold !== undefined) {
|
|
125
|
+
params.append('ppRelevanceThreshold', request.ppRelevanceThreshold.toString());
|
|
126
|
+
}
|
|
127
|
+
if (request.ppLlmTemp !== undefined) {
|
|
128
|
+
params.append('ppLlmTemp', request.ppLlmTemp.toString());
|
|
129
|
+
}
|
|
130
|
+
if (request.ppMaxResults !== undefined) {
|
|
131
|
+
params.append('ppMaxResults', request.ppMaxResults.toString());
|
|
132
|
+
}
|
|
133
|
+
if (request.ppChronologicalResort !== undefined) {
|
|
134
|
+
params.append('ppChronologicalResort', request.ppChronologicalResort.toString());
|
|
135
|
+
}
|
|
116
136
|
fullURL = "".concat(endpoint, "?").concat(params.toString()); // Set appropriate headers
|
|
117
137
|
headers = {
|
|
118
138
|
'Accept': request.format === StreamingClient.StreamingFormat.SSE ? 'text/event-stream' : 'application/x-ndjson'
|
|
@@ -442,6 +462,171 @@ var StreamingClient = exports.StreamingClient = /*#__PURE__*/function () {
|
|
|
442
462
|
}
|
|
443
463
|
return retrieveMemoryStreamSimple;
|
|
444
464
|
}()
|
|
465
|
+
/**
|
|
466
|
+
* Stream semantic memory retrieval results using ChatPostProcessor
|
|
467
|
+
*
|
|
468
|
+
* @param {AbortSignal} signal - Abort signal for cancellation
|
|
469
|
+
* @param {string} message - Primary query/message for semantic search
|
|
470
|
+
* @param {string[]} spaceIds - Array of space UUIDs to search within
|
|
471
|
+
* @param {number} [requestedSize] - Maximum number of memories to retrieve
|
|
472
|
+
* @param {boolean} [fetchMemory] - Whether to fetch memory definitions
|
|
473
|
+
* @param {boolean} [fetchMemoryContent] - Whether to fetch original content
|
|
474
|
+
* @param {string} [format] - Streaming format ('ndjson' or 'sse', defaults to 'ndjson')
|
|
475
|
+
* @param {string} [ppLlmId] - UUID of LLM for abstract generation
|
|
476
|
+
* @param {string} [ppRerankerId] - UUID of reranker for result reranking
|
|
477
|
+
* @param {number} [ppRelevanceThreshold] - Minimum relevance score
|
|
478
|
+
* @param {number} [ppLlmTemp] - LLM temperature for generation
|
|
479
|
+
* @param {number} [ppMaxResults] - Maximum results to return
|
|
480
|
+
* @param {boolean} [ppChronologicalResort] - Whether to resort by creation time
|
|
481
|
+
* @returns {Promise<AsyncIterableIterator<MemoryStreamResponse>>} Async iterator of streaming events
|
|
482
|
+
*/
|
|
483
|
+
)
|
|
484
|
+
}, {
|
|
485
|
+
key: "retrieveMemoryStreamChat",
|
|
486
|
+
value: (function () {
|
|
487
|
+
var _retrieveMemoryStreamChat = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(signal, message, spaceIds, requestedSize, fetchMemory, fetchMemoryContent, format, ppLlmId, ppRerankerId, ppRelevanceThreshold, ppLlmTemp, ppMaxResults, ppChronologicalResort) {
|
|
488
|
+
var request;
|
|
489
|
+
return _regenerator().w(function (_context5) {
|
|
490
|
+
while (1) switch (_context5.n) {
|
|
491
|
+
case 0:
|
|
492
|
+
request = {
|
|
493
|
+
message: message,
|
|
494
|
+
spaceIds: spaceIds,
|
|
495
|
+
requestedSize: requestedSize,
|
|
496
|
+
fetchMemory: fetchMemory,
|
|
497
|
+
fetchMemoryContent: fetchMemoryContent,
|
|
498
|
+
format: format || StreamingClient.StreamingFormat.NDJSON,
|
|
499
|
+
ppLlmId: ppLlmId,
|
|
500
|
+
ppRerankerId: ppRerankerId,
|
|
501
|
+
ppRelevanceThreshold: ppRelevanceThreshold,
|
|
502
|
+
ppLlmTemp: ppLlmTemp,
|
|
503
|
+
ppMaxResults: ppMaxResults,
|
|
504
|
+
ppChronologicalResort: ppChronologicalResort
|
|
505
|
+
};
|
|
506
|
+
return _context5.a(2, this.retrieveMemoryStream(signal, request));
|
|
507
|
+
}
|
|
508
|
+
}, _callee5, this);
|
|
509
|
+
}));
|
|
510
|
+
function retrieveMemoryStreamChat(_x6, _x7, _x8, _x9, _x0, _x1, _x10, _x11, _x12, _x13, _x14, _x15, _x16) {
|
|
511
|
+
return _retrieveMemoryStreamChat.apply(this, arguments);
|
|
512
|
+
}
|
|
513
|
+
return retrieveMemoryStreamChat;
|
|
514
|
+
}()
|
|
515
|
+
/**
|
|
516
|
+
* Stream semantic memory retrieval using advanced POST endpoint with custom post-processor
|
|
517
|
+
*
|
|
518
|
+
* @param {AbortSignal} signal - Abort signal for cancellation
|
|
519
|
+
* @param {AdvancedMemoryStreamRequest} request - Advanced request with post-processor config
|
|
520
|
+
* @returns {Promise<AsyncIterableIterator<MemoryStreamResponse>>} Async iterator of streaming events
|
|
521
|
+
*/
|
|
522
|
+
)
|
|
523
|
+
}, {
|
|
524
|
+
key: "retrieveMemoryStreamAdvanced",
|
|
525
|
+
value: (function () {
|
|
526
|
+
var _retrieveMemoryStreamAdvanced = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(signal, request) {
|
|
527
|
+
var requestBody, postProcessor, baseURL, endpoint, headers, response, errorText;
|
|
528
|
+
return _regenerator().w(function (_context6) {
|
|
529
|
+
while (1) switch (_context6.n) {
|
|
530
|
+
case 0:
|
|
531
|
+
if (request) {
|
|
532
|
+
_context6.n = 1;
|
|
533
|
+
break;
|
|
534
|
+
}
|
|
535
|
+
throw new Error('Request cannot be null');
|
|
536
|
+
case 1:
|
|
537
|
+
if (request.message) {
|
|
538
|
+
_context6.n = 2;
|
|
539
|
+
break;
|
|
540
|
+
}
|
|
541
|
+
throw new Error('Message is required');
|
|
542
|
+
case 2:
|
|
543
|
+
if (!request.format) {
|
|
544
|
+
request.format = StreamingClient.StreamingFormat.NDJSON;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
// Build request body
|
|
548
|
+
requestBody = {
|
|
549
|
+
message: request.message,
|
|
550
|
+
spaceKeys: []
|
|
551
|
+
}; // Convert spaceIds to spaceKeys array
|
|
552
|
+
if (request.spaceIds && request.spaceIds.length > 0) {
|
|
553
|
+
request.spaceIds.forEach(function (spaceId) {
|
|
554
|
+
requestBody.spaceKeys.push({
|
|
555
|
+
spaceId: spaceId
|
|
556
|
+
});
|
|
557
|
+
});
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
// Add optional parameters
|
|
561
|
+
if (request.requestedSize !== undefined) {
|
|
562
|
+
requestBody.requestedSize = request.requestedSize;
|
|
563
|
+
}
|
|
564
|
+
if (request.fetchMemory !== undefined) {
|
|
565
|
+
requestBody.fetchMemory = request.fetchMemory;
|
|
566
|
+
}
|
|
567
|
+
if (request.fetchMemoryContent !== undefined) {
|
|
568
|
+
requestBody.fetchMemoryContent = request.fetchMemoryContent;
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
// Add post-processor configuration
|
|
572
|
+
if (request.postProcessorName) {
|
|
573
|
+
postProcessor = {
|
|
574
|
+
name: request.postProcessorName
|
|
575
|
+
};
|
|
576
|
+
if (request.postProcessorConfig) {
|
|
577
|
+
postProcessor.config = request.postProcessorConfig;
|
|
578
|
+
}
|
|
579
|
+
requestBody.postProcessor = postProcessor;
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
// Build URL for POST endpoint
|
|
583
|
+
baseURL = this.client.basePath || 'http://localhost:8080';
|
|
584
|
+
endpoint = "".concat(baseURL, "/v1/memories:retrieve"); // Set appropriate headers
|
|
585
|
+
headers = {
|
|
586
|
+
'Accept': request.format === StreamingClient.StreamingFormat.SSE ? 'text/event-stream' : 'application/x-ndjson',
|
|
587
|
+
'Content-Type': 'application/json'
|
|
588
|
+
}; // Add authentication headers
|
|
589
|
+
if (this.client.defaultHeaders) {
|
|
590
|
+
Object.assign(headers, this.client.defaultHeaders);
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
// Make the POST request
|
|
594
|
+
_context6.n = 3;
|
|
595
|
+
return fetch(endpoint, {
|
|
596
|
+
method: 'POST',
|
|
597
|
+
headers: headers,
|
|
598
|
+
body: JSON.stringify(requestBody),
|
|
599
|
+
signal: signal
|
|
600
|
+
});
|
|
601
|
+
case 3:
|
|
602
|
+
response = _context6.v;
|
|
603
|
+
if (response.ok) {
|
|
604
|
+
_context6.n = 5;
|
|
605
|
+
break;
|
|
606
|
+
}
|
|
607
|
+
_context6.n = 4;
|
|
608
|
+
return response.text();
|
|
609
|
+
case 4:
|
|
610
|
+
errorText = _context6.v;
|
|
611
|
+
throw new StreamError(errorText, response.status);
|
|
612
|
+
case 5:
|
|
613
|
+
if (!(request.format === StreamingClient.StreamingFormat.SSE)) {
|
|
614
|
+
_context6.n = 6;
|
|
615
|
+
break;
|
|
616
|
+
}
|
|
617
|
+
return _context6.a(2, this._processSSEStream(response));
|
|
618
|
+
case 6:
|
|
619
|
+
return _context6.a(2, this._processNDJSONStream(response));
|
|
620
|
+
case 7:
|
|
621
|
+
return _context6.a(2);
|
|
622
|
+
}
|
|
623
|
+
}, _callee6, this);
|
|
624
|
+
}));
|
|
625
|
+
function retrieveMemoryStreamAdvanced(_x17, _x18) {
|
|
626
|
+
return _retrieveMemoryStreamAdvanced.apply(this, arguments);
|
|
627
|
+
}
|
|
628
|
+
return retrieveMemoryStreamAdvanced;
|
|
629
|
+
}()
|
|
445
630
|
/**
|
|
446
631
|
* Collects all streaming results into an array
|
|
447
632
|
* @param {AbortSignal} signal - Abort signal for cancellation
|
|
@@ -460,43 +645,43 @@ var StreamingClient = exports.StreamingClient = /*#__PURE__*/function () {
|
|
|
460
645
|
* @returns {Promise<MemoryStreamResponse[]>} Array of streaming events
|
|
461
646
|
*/
|
|
462
647
|
function () {
|
|
463
|
-
var _streamWithTimeout = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
648
|
+
var _streamWithTimeout = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(message, spaceIds, timeoutMs) {
|
|
464
649
|
var controller, timeoutId, stream, results, _t5;
|
|
465
|
-
return _regenerator().w(function (
|
|
466
|
-
while (1) switch (
|
|
650
|
+
return _regenerator().w(function (_context7) {
|
|
651
|
+
while (1) switch (_context7.p = _context7.n) {
|
|
467
652
|
case 0:
|
|
468
653
|
controller = new AbortController();
|
|
469
654
|
timeoutId = setTimeout(function () {
|
|
470
655
|
return controller.abort();
|
|
471
656
|
}, timeoutMs);
|
|
472
|
-
|
|
473
|
-
|
|
657
|
+
_context7.p = 1;
|
|
658
|
+
_context7.n = 2;
|
|
474
659
|
return this.retrieveMemoryStreamSimple(controller.signal, message, spaceIds);
|
|
475
660
|
case 2:
|
|
476
|
-
stream =
|
|
477
|
-
|
|
661
|
+
stream = _context7.v;
|
|
662
|
+
_context7.n = 3;
|
|
478
663
|
return StreamingClient.collectStreamResults(controller.signal, stream);
|
|
479
664
|
case 3:
|
|
480
|
-
results =
|
|
665
|
+
results = _context7.v;
|
|
481
666
|
clearTimeout(timeoutId);
|
|
482
|
-
return
|
|
667
|
+
return _context7.a(2, results);
|
|
483
668
|
case 4:
|
|
484
|
-
|
|
485
|
-
_t5 =
|
|
669
|
+
_context7.p = 4;
|
|
670
|
+
_t5 = _context7.v;
|
|
486
671
|
clearTimeout(timeoutId);
|
|
487
672
|
if (!(_t5.name === 'AbortError' || _t5.message === 'Operation was aborted')) {
|
|
488
|
-
|
|
673
|
+
_context7.n = 5;
|
|
489
674
|
break;
|
|
490
675
|
}
|
|
491
676
|
throw new Error('Streaming operation timed out');
|
|
492
677
|
case 5:
|
|
493
678
|
throw _t5;
|
|
494
679
|
case 6:
|
|
495
|
-
return
|
|
680
|
+
return _context7.a(2);
|
|
496
681
|
}
|
|
497
|
-
},
|
|
682
|
+
}, _callee7, this, [[1, 4]]);
|
|
498
683
|
}));
|
|
499
|
-
function streamWithTimeout(
|
|
684
|
+
function streamWithTimeout(_x19, _x20, _x21) {
|
|
500
685
|
return _streamWithTimeout.apply(this, arguments);
|
|
501
686
|
}
|
|
502
687
|
return streamWithTimeout;
|
|
@@ -504,28 +689,28 @@ var StreamingClient = exports.StreamingClient = /*#__PURE__*/function () {
|
|
|
504
689
|
}], [{
|
|
505
690
|
key: "collectStreamResults",
|
|
506
691
|
value: (function () {
|
|
507
|
-
var _collectStreamResults = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
692
|
+
var _collectStreamResults = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(signal, stream) {
|
|
508
693
|
var results, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, event, _t6, _t7;
|
|
509
|
-
return _regenerator().w(function (
|
|
510
|
-
while (1) switch (
|
|
694
|
+
return _regenerator().w(function (_context8) {
|
|
695
|
+
while (1) switch (_context8.p = _context8.n) {
|
|
511
696
|
case 0:
|
|
512
697
|
results = [];
|
|
513
|
-
|
|
698
|
+
_context8.p = 1;
|
|
514
699
|
_iteratorAbruptCompletion = false;
|
|
515
700
|
_didIteratorError = false;
|
|
516
|
-
|
|
701
|
+
_context8.p = 2;
|
|
517
702
|
_iterator = _asyncIterator(stream);
|
|
518
703
|
case 3:
|
|
519
|
-
|
|
704
|
+
_context8.n = 4;
|
|
520
705
|
return _iterator.next();
|
|
521
706
|
case 4:
|
|
522
|
-
if (!(_iteratorAbruptCompletion = !(_step =
|
|
523
|
-
|
|
707
|
+
if (!(_iteratorAbruptCompletion = !(_step = _context8.v).done)) {
|
|
708
|
+
_context8.n = 7;
|
|
524
709
|
break;
|
|
525
710
|
}
|
|
526
711
|
event = _step.value;
|
|
527
712
|
if (!(signal && signal.aborted)) {
|
|
528
|
-
|
|
713
|
+
_context8.n = 5;
|
|
529
714
|
break;
|
|
530
715
|
}
|
|
531
716
|
throw new Error('Operation was aborted');
|
|
@@ -533,55 +718,55 @@ var StreamingClient = exports.StreamingClient = /*#__PURE__*/function () {
|
|
|
533
718
|
results.push(event);
|
|
534
719
|
case 6:
|
|
535
720
|
_iteratorAbruptCompletion = false;
|
|
536
|
-
|
|
721
|
+
_context8.n = 3;
|
|
537
722
|
break;
|
|
538
723
|
case 7:
|
|
539
|
-
|
|
724
|
+
_context8.n = 9;
|
|
540
725
|
break;
|
|
541
726
|
case 8:
|
|
542
|
-
|
|
543
|
-
_t6 =
|
|
727
|
+
_context8.p = 8;
|
|
728
|
+
_t6 = _context8.v;
|
|
544
729
|
_didIteratorError = true;
|
|
545
730
|
_iteratorError = _t6;
|
|
546
731
|
case 9:
|
|
547
|
-
|
|
548
|
-
|
|
732
|
+
_context8.p = 9;
|
|
733
|
+
_context8.p = 10;
|
|
549
734
|
if (!(_iteratorAbruptCompletion && _iterator["return"] != null)) {
|
|
550
|
-
|
|
735
|
+
_context8.n = 11;
|
|
551
736
|
break;
|
|
552
737
|
}
|
|
553
|
-
|
|
738
|
+
_context8.n = 11;
|
|
554
739
|
return _iterator["return"]();
|
|
555
740
|
case 11:
|
|
556
|
-
|
|
741
|
+
_context8.p = 11;
|
|
557
742
|
if (!_didIteratorError) {
|
|
558
|
-
|
|
743
|
+
_context8.n = 12;
|
|
559
744
|
break;
|
|
560
745
|
}
|
|
561
746
|
throw _iteratorError;
|
|
562
747
|
case 12:
|
|
563
|
-
return
|
|
748
|
+
return _context8.f(11);
|
|
564
749
|
case 13:
|
|
565
|
-
return
|
|
750
|
+
return _context8.f(9);
|
|
566
751
|
case 14:
|
|
567
|
-
|
|
752
|
+
_context8.n = 17;
|
|
568
753
|
break;
|
|
569
754
|
case 15:
|
|
570
|
-
|
|
571
|
-
_t7 =
|
|
755
|
+
_context8.p = 15;
|
|
756
|
+
_t7 = _context8.v;
|
|
572
757
|
if (!(_t7.name === 'AbortError' || _t7.message === 'Operation was aborted')) {
|
|
573
|
-
|
|
758
|
+
_context8.n = 16;
|
|
574
759
|
break;
|
|
575
760
|
}
|
|
576
761
|
throw _t7;
|
|
577
762
|
case 16:
|
|
578
763
|
throw _t7;
|
|
579
764
|
case 17:
|
|
580
|
-
return
|
|
765
|
+
return _context8.a(2, results);
|
|
581
766
|
}
|
|
582
|
-
},
|
|
767
|
+
}, _callee8, null, [[10,, 11, 13], [2, 8, 9, 14], [1, 15]]);
|
|
583
768
|
}));
|
|
584
|
-
function collectStreamResults(
|
|
769
|
+
function collectStreamResults(_x22, _x23) {
|
|
585
770
|
return _collectStreamResults.apply(this, arguments);
|
|
586
771
|
}
|
|
587
772
|
return collectStreamResults;
|
|
@@ -598,6 +783,24 @@ var StreamingClient = exports.StreamingClient = /*#__PURE__*/function () {
|
|
|
598
783
|
* @property {boolean} [fetchMemoryContent] - Whether to fetch memory content details
|
|
599
784
|
* @property {boolean} [generateAbstract] - Whether to generate abstract
|
|
600
785
|
* @property {string} [format] - Streaming format (ndjson or sse)
|
|
786
|
+
* @property {string} [ppLlmId] - UUID of LLM for ChatPostProcessor
|
|
787
|
+
* @property {string} [ppRerankerId] - UUID of reranker for ChatPostProcessor
|
|
788
|
+
* @property {number} [ppRelevanceThreshold] - Minimum relevance score
|
|
789
|
+
* @property {number} [ppLlmTemp] - LLM temperature for generation
|
|
790
|
+
* @property {number} [ppMaxResults] - Maximum results to return
|
|
791
|
+
* @property {boolean} [ppChronologicalResort] - Whether to resort by creation time
|
|
792
|
+
*/
|
|
793
|
+
/**
|
|
794
|
+
* Advanced request parameters for streaming with custom post-processor
|
|
795
|
+
* @typedef {Object} AdvancedMemoryStreamRequest
|
|
796
|
+
* @property {string} message - The search message
|
|
797
|
+
* @property {string[]} [spaceIds] - Array of space IDs to search
|
|
798
|
+
* @property {number} [requestedSize] - Maximum number of results to return
|
|
799
|
+
* @property {boolean} [fetchMemory] - Whether to fetch memory content
|
|
800
|
+
* @property {boolean} [fetchMemoryContent] - Whether to fetch memory content details
|
|
801
|
+
* @property {string} [format] - Streaming format (ndjson or sse)
|
|
802
|
+
* @property {string} [postProcessorName] - Name of custom post-processor
|
|
803
|
+
* @property {Object} [postProcessorConfig] - Configuration for post-processor
|
|
601
804
|
*/
|
|
602
805
|
/**
|
|
603
806
|
* Streaming response event
|