@reverbia/sdk 1.0.0-next.20251208112742 → 1.0.0-next.20251209090511

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.
@@ -395,7 +395,10 @@ interface ToolExecutionResult {
395
395
  error?: string;
396
396
  }
397
397
 
398
- type SendMessageArgs = {
398
+ /**
399
+ * Base arguments for sending a message
400
+ */
401
+ type BaseSendMessageArgs = {
399
402
  messages: LlmapiMessage[];
400
403
  model?: string;
401
404
  /**
@@ -405,22 +408,11 @@ type SendMessageArgs = {
405
408
  * @param chunk - The content delta from the current chunk
406
409
  */
407
410
  onData?: (chunk: string) => void;
408
- /**
409
- * Whether to run tool selection for this message.
410
- * Defaults to true if tools are configured.
411
- */
412
- runTools?: boolean;
413
- };
414
- type SendMessageResult = {
415
- data: LlmapiChatCompletionResponse;
416
- error: null;
417
- toolExecution?: ToolExecutionResult;
418
- } | {
419
- data: null;
420
- error: string;
421
- toolExecution?: ToolExecutionResult;
422
411
  };
423
- type UseChatOptions = {
412
+ /**
413
+ * Base options for useChat hook
414
+ */
415
+ type BaseUseChatOptions = {
424
416
  getToken?: () => Promise<string | null>;
425
417
  baseUrl?: string;
426
418
  /**
@@ -442,6 +434,39 @@ type UseChatOptions = {
442
434
  * @param error - The error that occurred (never an AbortError)
443
435
  */
444
436
  onError?: (error: Error) => void;
437
+ };
438
+ /**
439
+ * Base result type for useChat hook
440
+ */
441
+ type BaseUseChatResult = {
442
+ isLoading: boolean;
443
+ /**
444
+ * Aborts the current streaming request if one is in progress.
445
+ *
446
+ * When a request is aborted, `sendMessage` will return with
447
+ * `{ data: null, error: "Request aborted" }`. The `onError` callback
448
+ * will NOT be called, as aborts are intentional actions, not errors.
449
+ */
450
+ stop: () => void;
451
+ };
452
+
453
+ type SendMessageArgs = BaseSendMessageArgs & {
454
+ /**
455
+ * Whether to run tool selection for this message.
456
+ * Defaults to true if tools are configured.
457
+ */
458
+ runTools?: boolean;
459
+ };
460
+ type SendMessageResult = {
461
+ data: LlmapiChatCompletionResponse;
462
+ error: null;
463
+ toolExecution?: ToolExecutionResult;
464
+ } | {
465
+ data: null;
466
+ error: string;
467
+ toolExecution?: ToolExecutionResult;
468
+ };
469
+ type UseChatOptions = BaseUseChatOptions & {
445
470
  /**
446
471
  * The provider to use for chat completions (default: "api")
447
472
  * "local": Uses a local HuggingFace model (in-browser)
@@ -469,18 +494,9 @@ type UseChatOptions = {
469
494
  */
470
495
  onToolExecution?: (result: ToolExecutionResult) => void;
471
496
  };
472
- type UseChatResult = {
473
- isLoading: boolean;
497
+ type UseChatResult = BaseUseChatResult & {
474
498
  isSelectingTool: boolean;
475
499
  sendMessage: (args: SendMessageArgs) => Promise<SendMessageResult>;
476
- /**
477
- * Aborts the current streaming request if one is in progress.
478
- *
479
- * When a request is aborted, `sendMessage` will return with
480
- * `{ data: null, error: "Request aborted" }`. The `onError` callback
481
- * will NOT be called, as aborts are intentional actions, not errors.
482
- */
483
- stop: () => void;
484
500
  };
485
501
  /**
486
502
  * A React hook for managing chat completions with authentication.
@@ -395,7 +395,10 @@ interface ToolExecutionResult {
395
395
  error?: string;
396
396
  }
397
397
 
398
- type SendMessageArgs = {
398
+ /**
399
+ * Base arguments for sending a message
400
+ */
401
+ type BaseSendMessageArgs = {
399
402
  messages: LlmapiMessage[];
400
403
  model?: string;
401
404
  /**
@@ -405,22 +408,11 @@ type SendMessageArgs = {
405
408
  * @param chunk - The content delta from the current chunk
406
409
  */
407
410
  onData?: (chunk: string) => void;
408
- /**
409
- * Whether to run tool selection for this message.
410
- * Defaults to true if tools are configured.
411
- */
412
- runTools?: boolean;
413
- };
414
- type SendMessageResult = {
415
- data: LlmapiChatCompletionResponse;
416
- error: null;
417
- toolExecution?: ToolExecutionResult;
418
- } | {
419
- data: null;
420
- error: string;
421
- toolExecution?: ToolExecutionResult;
422
411
  };
423
- type UseChatOptions = {
412
+ /**
413
+ * Base options for useChat hook
414
+ */
415
+ type BaseUseChatOptions = {
424
416
  getToken?: () => Promise<string | null>;
425
417
  baseUrl?: string;
426
418
  /**
@@ -442,6 +434,39 @@ type UseChatOptions = {
442
434
  * @param error - The error that occurred (never an AbortError)
443
435
  */
444
436
  onError?: (error: Error) => void;
437
+ };
438
+ /**
439
+ * Base result type for useChat hook
440
+ */
441
+ type BaseUseChatResult = {
442
+ isLoading: boolean;
443
+ /**
444
+ * Aborts the current streaming request if one is in progress.
445
+ *
446
+ * When a request is aborted, `sendMessage` will return with
447
+ * `{ data: null, error: "Request aborted" }`. The `onError` callback
448
+ * will NOT be called, as aborts are intentional actions, not errors.
449
+ */
450
+ stop: () => void;
451
+ };
452
+
453
+ type SendMessageArgs = BaseSendMessageArgs & {
454
+ /**
455
+ * Whether to run tool selection for this message.
456
+ * Defaults to true if tools are configured.
457
+ */
458
+ runTools?: boolean;
459
+ };
460
+ type SendMessageResult = {
461
+ data: LlmapiChatCompletionResponse;
462
+ error: null;
463
+ toolExecution?: ToolExecutionResult;
464
+ } | {
465
+ data: null;
466
+ error: string;
467
+ toolExecution?: ToolExecutionResult;
468
+ };
469
+ type UseChatOptions = BaseUseChatOptions & {
445
470
  /**
446
471
  * The provider to use for chat completions (default: "api")
447
472
  * "local": Uses a local HuggingFace model (in-browser)
@@ -469,18 +494,9 @@ type UseChatOptions = {
469
494
  */
470
495
  onToolExecution?: (result: ToolExecutionResult) => void;
471
496
  };
472
- type UseChatResult = {
473
- isLoading: boolean;
497
+ type UseChatResult = BaseUseChatResult & {
474
498
  isSelectingTool: boolean;
475
499
  sendMessage: (args: SendMessageArgs) => Promise<SendMessageResult>;
476
- /**
477
- * Aborts the current streaming request if one is in progress.
478
- *
479
- * When a request is aborted, `sendMessage` will return with
480
- * `{ data: null, error: "Request aborted" }`. The `onError` callback
481
- * will NOT be called, as aborts are intentional actions, not errors.
482
- */
483
- stop: () => void;
484
500
  };
485
501
  /**
486
502
  * A React hook for managing chat completions with authentication.