funda-ui 4.7.601 → 4.7.604

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.
@@ -56,6 +56,7 @@ export declare type ChatboxProps = {
56
56
  model?: string;
57
57
  baseUrl?: string;
58
58
  apiKey?: string;
59
+ token?: string | (() => string);
59
60
  defaultMessages?: MessageDetail[];
60
61
  verbose?: boolean;
61
62
  reasoningSwitchLabel?: string;
package/Chatbox/index.js CHANGED
@@ -5320,6 +5320,16 @@ var Chatbox = function Chatbox(props) {
5320
5320
  requestBody: "{\n \"model\": \"{model}\",\n \"messages\": [{\n \"role\": \"user\",\n \"content\": \"{message}\"\n }],\n \"stream\": true\n}",
5321
5321
  responseExtractor: "data.choices.0.delta.content"
5322
5322
  });
5323
+ var tokenFormat = function tokenFormat(inputTokenValue) {
5324
+ if (typeof inputTokenValue === 'undefined') return '';
5325
+
5326
+ // Resolve token value (string or function)
5327
+ if (typeof inputTokenValue === 'function') {
5328
+ return inputTokenValue();
5329
+ } else {
5330
+ return inputTokenValue || '';
5331
+ }
5332
+ };
5323
5333
 
5324
5334
  //
5325
5335
  var rootRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
@@ -5476,6 +5486,7 @@ var Chatbox = function Chatbox(props) {
5476
5486
  model = currentProps.model,
5477
5487
  baseUrl = currentProps.baseUrl,
5478
5488
  apiKey = currentProps.apiKey,
5489
+ token = currentProps.token,
5479
5490
  verbose = currentProps.verbose,
5480
5491
  reasoningSwitchLabel = currentProps.reasoningSwitchLabel,
5481
5492
  stopLabel = currentProps.stopLabel,
@@ -5521,7 +5532,7 @@ var Chatbox = function Chatbox(props) {
5521
5532
  var requestApiUrl = apiUrl.replace(/\{baseUrl\}/g, baseUrl);
5522
5533
 
5523
5534
  // header config
5524
- var _headerConfig = headerConfig.replace(/\{apiKey\}/g, apiKey).replace(/\'/g, '"'); // !!! REQUIRED !!!
5535
+ var _headerConfig = headerConfig.replace(/\{apiKey\}/g, apiKey).replace(/\{token\}/g, tokenFormat(token)).replace(/\'/g, '"'); // !!! REQUIRED !!!
5525
5536
  var headerConfigRes = typeof _headerConfig !== 'undefined' ? (0,validate.isJSON)(_headerConfig) ? JSON.parse(_headerConfig) : undefined : {
5526
5537
  'Content-Type': 'application/json'
5527
5538
  };
@@ -5554,6 +5565,7 @@ var Chatbox = function Chatbox(props) {
5554
5565
  model: model,
5555
5566
  baseUrl: baseUrl,
5556
5567
  apiKey: apiKey,
5568
+ token: token,
5557
5569
  verbose: verbose,
5558
5570
  reasoningSwitchLabel: reasoningSwitchLabel,
5559
5571
  stopLabel: stopLabel,
@@ -6368,7 +6380,7 @@ var Chatbox = function Chatbox(props) {
6368
6380
  setEnableStreamMode(currentStreamMode);
6369
6381
  _context8.prev = 2;
6370
6382
  // Parse and interpolate request body template
6371
- requestBodyRes = JSON.parse((args().requestBodyTmpl || '{}').replace(/\{model\}/g, args().model).replace(/\{message\}/g, msg).replace(/\{token\}/g, chatId)); //
6383
+ requestBodyRes = JSON.parse((args().requestBodyTmpl || '{}').replace(/\{model\}/g, args().model).replace(/\{message\}/g, msg).replace(/\{chatId\}/g, chatId).replace(/\{token\}/g, tokenFormat(args().token))); //
6372
6384
  // If a formatter function exists, it is used to process the request body
6373
6385
  if (!(typeof args().requestBodyFormatter === 'function')) {
6374
6386
  _context8.next = 8;
@@ -56,6 +56,7 @@ export declare type ChatboxProps = {
56
56
  model?: string;
57
57
  baseUrl?: string;
58
58
  apiKey?: string;
59
+ token?: string | (() => string);
59
60
  defaultMessages?: MessageDetail[];
60
61
  verbose?: boolean;
61
62
  reasoningSwitchLabel?: string;
@@ -5320,6 +5320,16 @@ var Chatbox = function Chatbox(props) {
5320
5320
  requestBody: "{\n \"model\": \"{model}\",\n \"messages\": [{\n \"role\": \"user\",\n \"content\": \"{message}\"\n }],\n \"stream\": true\n}",
5321
5321
  responseExtractor: "data.choices.0.delta.content"
5322
5322
  });
5323
+ var tokenFormat = function tokenFormat(inputTokenValue) {
5324
+ if (typeof inputTokenValue === 'undefined') return '';
5325
+
5326
+ // Resolve token value (string or function)
5327
+ if (typeof inputTokenValue === 'function') {
5328
+ return inputTokenValue();
5329
+ } else {
5330
+ return inputTokenValue || '';
5331
+ }
5332
+ };
5323
5333
 
5324
5334
  //
5325
5335
  var rootRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
@@ -5476,6 +5486,7 @@ var Chatbox = function Chatbox(props) {
5476
5486
  model = currentProps.model,
5477
5487
  baseUrl = currentProps.baseUrl,
5478
5488
  apiKey = currentProps.apiKey,
5489
+ token = currentProps.token,
5479
5490
  verbose = currentProps.verbose,
5480
5491
  reasoningSwitchLabel = currentProps.reasoningSwitchLabel,
5481
5492
  stopLabel = currentProps.stopLabel,
@@ -5521,7 +5532,7 @@ var Chatbox = function Chatbox(props) {
5521
5532
  var requestApiUrl = apiUrl.replace(/\{baseUrl\}/g, baseUrl);
5522
5533
 
5523
5534
  // header config
5524
- var _headerConfig = headerConfig.replace(/\{apiKey\}/g, apiKey).replace(/\'/g, '"'); // !!! REQUIRED !!!
5535
+ var _headerConfig = headerConfig.replace(/\{apiKey\}/g, apiKey).replace(/\{token\}/g, tokenFormat(token)).replace(/\'/g, '"'); // !!! REQUIRED !!!
5525
5536
  var headerConfigRes = typeof _headerConfig !== 'undefined' ? (0,validate.isJSON)(_headerConfig) ? JSON.parse(_headerConfig) : undefined : {
5526
5537
  'Content-Type': 'application/json'
5527
5538
  };
@@ -5554,6 +5565,7 @@ var Chatbox = function Chatbox(props) {
5554
5565
  model: model,
5555
5566
  baseUrl: baseUrl,
5556
5567
  apiKey: apiKey,
5568
+ token: token,
5557
5569
  verbose: verbose,
5558
5570
  reasoningSwitchLabel: reasoningSwitchLabel,
5559
5571
  stopLabel: stopLabel,
@@ -6368,7 +6380,7 @@ var Chatbox = function Chatbox(props) {
6368
6380
  setEnableStreamMode(currentStreamMode);
6369
6381
  _context8.prev = 2;
6370
6382
  // Parse and interpolate request body template
6371
- requestBodyRes = JSON.parse((args().requestBodyTmpl || '{}').replace(/\{model\}/g, args().model).replace(/\{message\}/g, msg).replace(/\{token\}/g, chatId)); //
6383
+ requestBodyRes = JSON.parse((args().requestBodyTmpl || '{}').replace(/\{model\}/g, args().model).replace(/\{message\}/g, msg).replace(/\{chatId\}/g, chatId).replace(/\{token\}/g, tokenFormat(args().token))); //
6372
6384
  // If a formatter function exists, it is used to process the request body
6373
6385
  if (!(typeof args().requestBodyFormatter === 'function')) {
6374
6386
  _context8.next = 8;
@@ -102,6 +102,7 @@ export type ChatboxProps = {
102
102
  model?: string;
103
103
  baseUrl?: string;
104
104
  apiKey?: string;
105
+ token?: string | (() => string);
105
106
  defaultMessages?: MessageDetail[];
106
107
  verbose?: boolean;
107
108
  reasoningSwitchLabel?: string;
@@ -169,6 +170,19 @@ const Chatbox = (props: ChatboxProps) => {
169
170
  });
170
171
 
171
172
 
173
+ const tokenFormat = (inputTokenValue: any) => {
174
+ if (typeof inputTokenValue === 'undefined') return '';
175
+
176
+ // Resolve token value (string or function)
177
+ if (typeof inputTokenValue === 'function') {
178
+ return inputTokenValue();
179
+ } else {
180
+ return inputTokenValue || '';
181
+ }
182
+ };
183
+
184
+
185
+
172
186
  //
173
187
  const rootRef = useRef<HTMLDivElement>(null);
174
188
  const msgContainerRef = useRef<HTMLDivElement>(null);
@@ -301,6 +315,7 @@ const Chatbox = (props: ChatboxProps) => {
301
315
  model,
302
316
  baseUrl,
303
317
  apiKey,
318
+ token,
304
319
  verbose,
305
320
  reasoningSwitchLabel,
306
321
  stopLabel,
@@ -351,9 +366,9 @@ const Chatbox = (props: ChatboxProps) => {
351
366
  // request API
352
367
  const requestApiUrl = apiUrl.replace(/\{baseUrl\}/g, baseUrl);
353
368
 
354
-
355
369
  // header config
356
370
  const _headerConfig = headerConfig.replace(/\{apiKey\}/g, apiKey)
371
+ .replace(/\{token\}/g, tokenFormat(token))
357
372
  .replace(/\'/g, '"'); // !!! REQUIRED !!!
358
373
  const headerConfigRes = typeof _headerConfig !== 'undefined' ? (isJSON(_headerConfig) ? JSON.parse(_headerConfig) : undefined) : {'Content-Type':'application/json'};
359
374
 
@@ -388,6 +403,7 @@ const Chatbox = (props: ChatboxProps) => {
388
403
  model,
389
404
  baseUrl,
390
405
  apiKey,
406
+ token,
391
407
  verbose,
392
408
  reasoningSwitchLabel,
393
409
  stopLabel,
@@ -1060,7 +1076,8 @@ const Chatbox = (props: ChatboxProps) => {
1060
1076
  (args().requestBodyTmpl || '{}')
1061
1077
  .replace(/\{model\}/g, args().model)
1062
1078
  .replace(/\{message\}/g, msg)
1063
- .replace(/\{token\}/g, chatId)
1079
+ .replace(/\{chatId\}/g, chatId)
1080
+ .replace(/\{token\}/g, tokenFormat(args().token) as string)
1064
1081
  );
1065
1082
 
1066
1083
  //
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "author": "UIUX Lab",
3
3
  "email": "uiuxlab@gmail.com",
4
4
  "name": "funda-ui",
5
- "version": "4.7.601",
5
+ "version": "4.7.604",
6
6
  "description": "React components using pure Bootstrap 5+ which does not contain any external style and script libraries.",
7
7
  "repository": {
8
8
  "type": "git",