@websolutespa/bom-llm 0.0.34 → 0.0.35

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/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # @websolutespa/bom-llm
2
2
 
3
+ ## 0.0.35
4
+
5
+ ### Patch Changes
6
+
7
+ - Modified: MessageService
8
+ - Added: USE_INSPECT_PARAM
9
+
3
10
  ## 0.0.34
4
11
 
5
12
  ### Patch Changes
package/dist/umd/index.js CHANGED
@@ -19136,6 +19136,26 @@ ${Object.entries(vars).map(_ref2 => {
19136
19136
  response.chunks = this.chunksToChunkItems(chunks, response);
19137
19137
  return response;
19138
19138
  }
19139
+ logChunks(chunks) {
19140
+ chunks.forEach(x => {
19141
+ if (isObject$3(x)) {
19142
+ switch (x.type) {
19143
+ case 'error':
19144
+ console.error('LlmMessageService.error', x);
19145
+ break;
19146
+ case 'log':
19147
+ console.log('LlmMessageService.log', x);
19148
+ break;
19149
+ case 'info':
19150
+ console.log('LlmMessageService.info', x);
19151
+ break;
19152
+ case 'end':
19153
+ console.log('LlmMessageService.end', x);
19154
+ break;
19155
+ }
19156
+ }
19157
+ });
19158
+ }
19139
19159
  chunksToChunkItems(chunks, response) {
19140
19160
  const chunkItems = [];
19141
19161
  chunks.forEach(x => {
@@ -19143,10 +19163,8 @@ ${Object.entries(vars).map(_ref2 => {
19143
19163
  if (isObject$3(x)) {
19144
19164
  switch (x.type) {
19145
19165
  case 'log':
19146
- console.log('LlmMessageService.log', x);
19147
19166
  break;
19148
19167
  case 'error':
19149
- console.error('LlmMessageService.error', x);
19150
19168
  chunkItems.push(x);
19151
19169
  break;
19152
19170
  case 'info':
@@ -19374,6 +19392,7 @@ ${Object.entries(vars).map(_ref2 => {
19374
19392
  for await (const chunk of readChunks(reader)) {
19375
19393
  if (!signal.aborted) {
19376
19394
  const chunks = this.bytesToChunks(chunk);
19395
+ this.logChunks(chunks);
19377
19396
  decodedChunks.push(...chunks);
19378
19397
  const response = this.chunksToResponse(decodedChunks);
19379
19398
  if (typeof onMessage === 'function') {
@@ -19392,10 +19411,21 @@ ${Object.entries(vars).map(_ref2 => {
19392
19411
  }
19393
19412
  }
19394
19413
  } catch (error) {
19414
+ console.error('MessageService.sendMessage.error', error);
19415
+ let errorMessage = typeof error === 'string' ? error : JSON.stringify(error, null, 2);
19395
19416
  if (error instanceof TypeError) {
19396
- console.error('TypeError: Browser may not support async iteration', error);
19417
+ errorMessage = 'TypeError: Browser may not support async iteration';
19418
+ }
19419
+ if (typeof onEnd === 'function') {
19420
+ const errorChunk = {
19421
+ type: 'error',
19422
+ error: errorMessage
19423
+ };
19424
+ decodedChunks.push(errorChunk);
19425
+ const response = this.chunksToResponse(decodedChunks);
19426
+ onEnd(response);
19397
19427
  }
19398
- throw error;
19428
+ // throw (error);
19399
19429
  }
19400
19430
  }
19401
19431
  async mockMessage(request, onMessage, onEnd, onChunk) {
@@ -19471,6 +19501,7 @@ ${Object.entries(vars).map(_ref2 => {
19471
19501
  for await (const chunk of readChunks(reader)) {
19472
19502
  if (!signal.aborted) {
19473
19503
  const chunks = this.bytesToChunks(chunk);
19504
+ this.logChunks(chunks);
19474
19505
  decodedChunks.push(...chunks);
19475
19506
  const response = this.chunksToResponse(decodedChunks);
19476
19507
  if (typeof onMessage === 'function') {
@@ -19488,10 +19519,21 @@ ${Object.entries(vars).map(_ref2 => {
19488
19519
  }
19489
19520
  }
19490
19521
  } catch (error) {
19522
+ console.error('MessageService.mockMessage.error', error);
19523
+ let errorMessage = typeof error === 'string' ? error : JSON.stringify(error, null, 2);
19491
19524
  if (error instanceof TypeError) {
19492
- console.error('TypeError: Browser may not support async iteration', error);
19525
+ errorMessage = 'TypeError: Browser may not support async iteration';
19493
19526
  }
19494
- throw error;
19527
+ if (typeof onEnd === 'function') {
19528
+ const errorChunk = {
19529
+ type: 'error',
19530
+ error: errorMessage
19531
+ };
19532
+ decodedChunks.push(errorChunk);
19533
+ const response = this.chunksToResponse(decodedChunks);
19534
+ onEnd(response);
19535
+ }
19536
+ // throw (error);
19495
19537
  }
19496
19538
  }
19497
19539
  abort() {
@@ -32943,11 +32985,19 @@ void main(void) {
32943
32985
  });
32944
32986
  };
32945
32987
 
32988
+ function hasInspect() {
32989
+ if (!isBrowser$1) {
32990
+ return false;
32991
+ }
32992
+ const url = new URL(window.location.href);
32993
+ return url.searchParams.has('inspect');
32994
+ }
32946
32995
  const StreamError = props => {
32947
32996
  const label = useLabel();
32948
32997
  const [show, setShow] = reactExports.useState(false);
32949
32998
  const classNames = getClassNames('llm__stream-error');
32950
- return /*#__PURE__*/jsxRuntimeExports.jsxs("div", {
32999
+ const shouldShowStreamError = hasInspect() ;
33000
+ return shouldShowStreamError ? /*#__PURE__*/jsxRuntimeExports.jsxs("div", {
32951
33001
  className: classNames,
32952
33002
  children: [/*#__PURE__*/jsxRuntimeExports.jsxs("div", {
32953
33003
  className: getClassNames('llm__stream-error__info'),
@@ -32965,7 +33015,7 @@ void main(void) {
32965
33015
  className: getClassNames('llm__stream-error__error', 'llm__hint'),
32966
33016
  children: JSON.stringify(props.error)
32967
33017
  })]
32968
- });
33018
+ }) : undefined;
32969
33019
  };
32970
33020
 
32971
33021
  const TripAdvisor = props => {