@haylee-ai/chat-sdk 1.0.2 → 1.0.4
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 +78 -126
- package/dist/index.cjs +4 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -11
- package/dist/index.d.ts +2 -11
- package/dist/index.js +5 -14
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -84,7 +84,6 @@ await client.messages.stream(
|
|
|
84
84
|
- [HayleeAI](#classeshayleeaimd)
|
|
85
85
|
- [HayleeAIClient](#classeshayleeaiclientmd)
|
|
86
86
|
- [HayleeAIError](#classeshayleeaierrormd)
|
|
87
|
-
- [IHistoryPayload](#classesihistorypayloadmd)
|
|
88
87
|
- [LlmTokenContent](#classesllmtokencontentmd)
|
|
89
88
|
- [LlmTokenEvent](#classesllmtokeneventmd)
|
|
90
89
|
- [MessageService](#classesmessageservicemd)
|
|
@@ -113,7 +112,7 @@ await client.messages.stream(
|
|
|
113
112
|
|
|
114
113
|
# Class: AuthenticationError
|
|
115
114
|
|
|
116
|
-
Defined in: [src/errors/authentication.error.ts:3](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/
|
|
115
|
+
Defined in: [src/errors/authentication.error.ts:3](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/errors/authentication.error.ts#L3)
|
|
117
116
|
|
|
118
117
|
## Extends
|
|
119
118
|
|
|
@@ -125,7 +124,7 @@ Defined in: [src/errors/authentication.error.ts:3](https://github.com/vonuyvicoo
|
|
|
125
124
|
|
|
126
125
|
> **new AuthenticationError**(`message`): `AuthenticationError`
|
|
127
126
|
|
|
128
|
-
Defined in: [src/errors/authentication.error.ts:6](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/
|
|
127
|
+
Defined in: [src/errors/authentication.error.ts:6](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/errors/authentication.error.ts#L6)
|
|
129
128
|
|
|
130
129
|
#### Parameters
|
|
131
130
|
|
|
@@ -171,7 +170,7 @@ Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/li
|
|
|
171
170
|
|
|
172
171
|
> `readonly` **name**: `string` = `"AuthenticationError"`
|
|
173
172
|
|
|
174
|
-
Defined in: [src/errors/authentication.error.ts:4](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/
|
|
173
|
+
Defined in: [src/errors/authentication.error.ts:4](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/errors/authentication.error.ts#L4)
|
|
175
174
|
|
|
176
175
|
#### Overrides
|
|
177
176
|
|
|
@@ -322,7 +321,7 @@ https://v8.dev/docs/stack-trace-api#customizing-stack-traces
|
|
|
322
321
|
|
|
323
322
|
# Class: AuthorizationError
|
|
324
323
|
|
|
325
|
-
Defined in: [src/errors/authorization.error.ts:3](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/
|
|
324
|
+
Defined in: [src/errors/authorization.error.ts:3](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/errors/authorization.error.ts#L3)
|
|
326
325
|
|
|
327
326
|
## Extends
|
|
328
327
|
|
|
@@ -334,7 +333,7 @@ Defined in: [src/errors/authorization.error.ts:3](https://github.com/vonuyvicoo/
|
|
|
334
333
|
|
|
335
334
|
> **new AuthorizationError**(`message`): `AuthorizationError`
|
|
336
335
|
|
|
337
|
-
Defined in: [src/errors/authorization.error.ts:6](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/
|
|
336
|
+
Defined in: [src/errors/authorization.error.ts:6](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/errors/authorization.error.ts#L6)
|
|
338
337
|
|
|
339
338
|
#### Parameters
|
|
340
339
|
|
|
@@ -380,7 +379,7 @@ Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/li
|
|
|
380
379
|
|
|
381
380
|
> `readonly` **name**: `string` = `"AuthorizationError"`
|
|
382
381
|
|
|
383
|
-
Defined in: [src/errors/authorization.error.ts:4](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/
|
|
382
|
+
Defined in: [src/errors/authorization.error.ts:4](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/errors/authorization.error.ts#L4)
|
|
384
383
|
|
|
385
384
|
#### Overrides
|
|
386
385
|
|
|
@@ -531,7 +530,7 @@ https://v8.dev/docs/stack-trace-api#customizing-stack-traces
|
|
|
531
530
|
|
|
532
531
|
# Class: BaseEvent
|
|
533
532
|
|
|
534
|
-
Defined in: [src/messages/types.ts:12](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/
|
|
533
|
+
Defined in: [src/messages/types.ts:12](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/messages/types.ts#L12)
|
|
535
534
|
|
|
536
535
|
Base event for Streaming
|
|
537
536
|
BaseEvent
|
|
@@ -557,7 +556,7 @@ Base event for Streaming
|
|
|
557
556
|
|
|
558
557
|
> **kind**: [`EventKind`](#enumerationseventkindmd)
|
|
559
558
|
|
|
560
|
-
Defined in: [src/messages/types.ts:16](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/
|
|
559
|
+
Defined in: [src/messages/types.ts:16](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/messages/types.ts#L16)
|
|
561
560
|
|
|
562
561
|
Used to separate streams
|
|
563
562
|
|
|
@@ -567,7 +566,7 @@ Used to separate streams
|
|
|
567
566
|
|
|
568
567
|
> **node**: `string`
|
|
569
568
|
|
|
570
|
-
Defined in: [src/messages/types.ts:20](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/
|
|
569
|
+
Defined in: [src/messages/types.ts:20](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/messages/types.ts#L20)
|
|
571
570
|
|
|
572
571
|
Source node in langgraph
|
|
573
572
|
|
|
@@ -582,7 +581,7 @@ Source node in langgraph
|
|
|
582
581
|
|
|
583
582
|
# Class: CreateMessageDto
|
|
584
583
|
|
|
585
|
-
Defined in: [src/types/chat.interface.ts:8](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/
|
|
584
|
+
Defined in: [src/types/chat.interface.ts:8](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/types/chat.interface.ts#L8)
|
|
586
585
|
|
|
587
586
|
DTO for creating a message
|
|
588
587
|
|
|
@@ -598,13 +597,11 @@ DTO for creating a message
|
|
|
598
597
|
|
|
599
598
|
## Properties
|
|
600
599
|
|
|
601
|
-
### conversation\
|
|
600
|
+
### conversation\_id?
|
|
602
601
|
|
|
603
|
-
> **conversation\
|
|
602
|
+
> `optional` **conversation\_id**: `string`
|
|
604
603
|
|
|
605
|
-
Defined in: [src/types/chat.interface.ts:13](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/
|
|
606
|
-
|
|
607
|
-
Array of messages
|
|
604
|
+
Defined in: [src/types/chat.interface.ts:13](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/types/chat.interface.ts#L13)
|
|
608
605
|
|
|
609
606
|
***
|
|
610
607
|
|
|
@@ -612,7 +609,7 @@ Array of messages
|
|
|
612
609
|
|
|
613
610
|
> **message**: `string`
|
|
614
611
|
|
|
615
|
-
Defined in: [src/types/chat.interface.ts:11](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/
|
|
612
|
+
Defined in: [src/types/chat.interface.ts:11](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/types/chat.interface.ts#L11)
|
|
616
613
|
|
|
617
614
|
User message
|
|
618
615
|
|
|
@@ -627,7 +624,7 @@ User message
|
|
|
627
624
|
|
|
628
625
|
# Class: EndEvent
|
|
629
626
|
|
|
630
|
-
Defined in: [src/messages/types.ts:49](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/
|
|
627
|
+
Defined in: [src/messages/types.ts:49](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/messages/types.ts#L49)
|
|
631
628
|
|
|
632
629
|
## Constructors
|
|
633
630
|
|
|
@@ -645,7 +642,7 @@ Defined in: [src/messages/types.ts:49](https://github.com/vonuyvicoo/haylee-ai-c
|
|
|
645
642
|
|
|
646
643
|
> **success**: `boolean`
|
|
647
644
|
|
|
648
|
-
Defined in: [src/messages/types.ts:50](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/
|
|
645
|
+
Defined in: [src/messages/types.ts:50](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/messages/types.ts#L50)
|
|
649
646
|
|
|
650
647
|
|
|
651
648
|
<a name="classeshayleeaimd"></a>
|
|
@@ -658,7 +655,7 @@ Defined in: [src/messages/types.ts:50](https://github.com/vonuyvicoo/haylee-ai-c
|
|
|
658
655
|
|
|
659
656
|
# Class: HayleeAI
|
|
660
657
|
|
|
661
|
-
Defined in: [src/index.ts:7](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/
|
|
658
|
+
Defined in: [src/index.ts:7](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/index.ts#L7)
|
|
662
659
|
|
|
663
660
|
Instantiate a new HayleeAI connection
|
|
664
661
|
|
|
@@ -672,7 +669,7 @@ Instantiate a new HayleeAI connection
|
|
|
672
669
|
|
|
673
670
|
> **new HayleeAI**(`options`): `HayleeAI`
|
|
674
671
|
|
|
675
|
-
Defined in: [src/index.ts:13](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/
|
|
672
|
+
Defined in: [src/index.ts:13](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/index.ts#L13)
|
|
676
673
|
|
|
677
674
|
#### Parameters
|
|
678
675
|
|
|
@@ -696,7 +693,7 @@ HayleeAIChatClientOptions
|
|
|
696
693
|
|
|
697
694
|
> **messages**: [`MessageService`](#classesmessageservicemd)
|
|
698
695
|
|
|
699
|
-
Defined in: [src/index.ts:8](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/
|
|
696
|
+
Defined in: [src/index.ts:8](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/index.ts#L8)
|
|
700
697
|
|
|
701
698
|
## Methods
|
|
702
699
|
|
|
@@ -704,7 +701,7 @@ Defined in: [src/index.ts:8](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/bl
|
|
|
704
701
|
|
|
705
702
|
> **\_stream**(`payload`, `signal?`): `AsyncGenerator`\<`string`, `void`, `unknown`\>
|
|
706
703
|
|
|
707
|
-
Defined in: [src/\_internal/client.ts:35](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/
|
|
704
|
+
Defined in: [src/\_internal/client.ts:35](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/_internal/client.ts#L35)
|
|
708
705
|
|
|
709
706
|
Internal stream callout
|
|
710
707
|
|
|
@@ -741,7 +738,7 @@ Abort signal
|
|
|
741
738
|
|
|
742
739
|
# Class: HayleeAIClient
|
|
743
740
|
|
|
744
|
-
Defined in: [src/\_internal/client.ts:18](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/
|
|
741
|
+
Defined in: [src/\_internal/client.ts:18](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/_internal/client.ts#L18)
|
|
745
742
|
|
|
746
743
|
Internal HayleeAI Client. Do not use unless necessary.
|
|
747
744
|
HayleeAIClient
|
|
@@ -756,7 +753,7 @@ Internal HayleeAI Client. Do not use unless necessary.
|
|
|
756
753
|
|
|
757
754
|
> **new HayleeAIClient**(`options`): `HayleeAIClient`
|
|
758
755
|
|
|
759
|
-
Defined in: [src/\_internal/client.ts:26](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/
|
|
756
|
+
Defined in: [src/\_internal/client.ts:26](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/_internal/client.ts#L26)
|
|
760
757
|
|
|
761
758
|
#### Parameters
|
|
762
759
|
|
|
@@ -776,7 +773,7 @@ Auth, and baseURL
|
|
|
776
773
|
|
|
777
774
|
> **\_stream**(`payload`, `signal?`): `AsyncGenerator`\<`string`, `void`, `unknown`\>
|
|
778
775
|
|
|
779
|
-
Defined in: [src/\_internal/client.ts:35](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/
|
|
776
|
+
Defined in: [src/\_internal/client.ts:35](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/_internal/client.ts#L35)
|
|
780
777
|
|
|
781
778
|
Internal stream callout
|
|
782
779
|
|
|
@@ -809,7 +806,7 @@ Abort signal
|
|
|
809
806
|
|
|
810
807
|
# Class: HayleeAIError
|
|
811
808
|
|
|
812
|
-
Defined in: [src/errors/base.ts:1](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/
|
|
809
|
+
Defined in: [src/errors/base.ts:1](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/errors/base.ts#L1)
|
|
813
810
|
|
|
814
811
|
## Extends
|
|
815
812
|
|
|
@@ -828,7 +825,7 @@ Defined in: [src/errors/base.ts:1](https://github.com/vonuyvicoo/haylee-ai-chat-
|
|
|
828
825
|
|
|
829
826
|
> **new HayleeAIError**(`message`): `HayleeAIError`
|
|
830
827
|
|
|
831
|
-
Defined in: [src/errors/base.ts:4](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/
|
|
828
|
+
Defined in: [src/errors/base.ts:4](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/errors/base.ts#L4)
|
|
832
829
|
|
|
833
830
|
#### Parameters
|
|
834
831
|
|
|
@@ -874,7 +871,7 @@ Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/li
|
|
|
874
871
|
|
|
875
872
|
> `readonly` **name**: `string` = `"HayleeAIError"`
|
|
876
873
|
|
|
877
|
-
Defined in: [src/errors/base.ts:2](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/
|
|
874
|
+
Defined in: [src/errors/base.ts:2](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/errors/base.ts#L2)
|
|
878
875
|
|
|
879
876
|
#### Overrides
|
|
880
877
|
|
|
@@ -1015,51 +1012,6 @@ https://v8.dev/docs/stack-trace-api#customizing-stack-traces
|
|
|
1015
1012
|
`Error.prepareStackTrace`
|
|
1016
1013
|
|
|
1017
1014
|
|
|
1018
|
-
<a name="classesihistorypayloadmd"></a>
|
|
1019
|
-
|
|
1020
|
-
[**@haylee-ai/chat-sdk v1.0.0**](#readmemd)
|
|
1021
|
-
|
|
1022
|
-
***
|
|
1023
|
-
|
|
1024
|
-
[@haylee-ai/chat-sdk](#readmemd) / IHistoryPayload
|
|
1025
|
-
|
|
1026
|
-
# Class: IHistoryPayload
|
|
1027
|
-
|
|
1028
|
-
Defined in: [src/types/chat.interface.ts:30](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/types/chat.interface.ts#L30)
|
|
1029
|
-
|
|
1030
|
-
History payload
|
|
1031
|
-
|
|
1032
|
-
## Constructors
|
|
1033
|
-
|
|
1034
|
-
### Constructor
|
|
1035
|
-
|
|
1036
|
-
> **new IHistoryPayload**(): `IHistoryPayload`
|
|
1037
|
-
|
|
1038
|
-
#### Returns
|
|
1039
|
-
|
|
1040
|
-
`IHistoryPayload`
|
|
1041
|
-
|
|
1042
|
-
## Properties
|
|
1043
|
-
|
|
1044
|
-
### content
|
|
1045
|
-
|
|
1046
|
-
> **content**: `string`
|
|
1047
|
-
|
|
1048
|
-
Defined in: [src/types/chat.interface.ts:34](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/types/chat.interface.ts#L34)
|
|
1049
|
-
|
|
1050
|
-
Content of message
|
|
1051
|
-
|
|
1052
|
-
***
|
|
1053
|
-
|
|
1054
|
-
### role
|
|
1055
|
-
|
|
1056
|
-
> **role**: [`Role`](#enumerationsrolemd)
|
|
1057
|
-
|
|
1058
|
-
Defined in: [src/types/chat.interface.ts:32](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/59c8fa0cba19cdc5e1906fd5e3e644b622e90950/src/types/chat.interface.ts#L32)
|
|
1059
|
-
|
|
1060
|
-
Role of message sender
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
1015
|
<a name="classesllmtokencontentmd"></a>
|
|
1064
1016
|
|
|
1065
1017
|
[**@haylee-ai/chat-sdk v1.0.0**](#readmemd)
|
|
@@ -1070,7 +1022,7 @@ Role of message sender
|
|
|
1070
1022
|
|
|
1071
1023
|
# Class: LlmTokenContent
|
|
1072
1024
|
|
|
1073
|
-
Defined in: [src/messages/types.ts:27](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/
|
|
1025
|
+
Defined in: [src/messages/types.ts:27](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/messages/types.ts#L27)
|
|
1074
1026
|
|
|
1075
1027
|
LLmTokenContent
|
|
1076
1028
|
|
|
@@ -1090,7 +1042,7 @@ LLmTokenContent
|
|
|
1090
1042
|
|
|
1091
1043
|
> **text**: `string`
|
|
1092
1044
|
|
|
1093
|
-
Defined in: [src/messages/types.ts:35](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/
|
|
1045
|
+
Defined in: [src/messages/types.ts:35](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/messages/types.ts#L35)
|
|
1094
1046
|
|
|
1095
1047
|
***
|
|
1096
1048
|
|
|
@@ -1098,7 +1050,7 @@ Defined in: [src/messages/types.ts:35](https://github.com/vonuyvicoo/haylee-ai-c
|
|
|
1098
1050
|
|
|
1099
1051
|
> **type**: `"text"`
|
|
1100
1052
|
|
|
1101
|
-
Defined in: [src/messages/types.ts:31](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/
|
|
1053
|
+
Defined in: [src/messages/types.ts:31](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/messages/types.ts#L31)
|
|
1102
1054
|
|
|
1103
1055
|
|
|
1104
1056
|
<a name="classesllmtokeneventmd"></a>
|
|
@@ -1111,7 +1063,7 @@ Defined in: [src/messages/types.ts:31](https://github.com/vonuyvicoo/haylee-ai-c
|
|
|
1111
1063
|
|
|
1112
1064
|
# Class: LlmTokenEvent
|
|
1113
1065
|
|
|
1114
|
-
Defined in: [src/messages/types.ts:38](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/
|
|
1066
|
+
Defined in: [src/messages/types.ts:38](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/messages/types.ts#L38)
|
|
1115
1067
|
|
|
1116
1068
|
Base event for Streaming
|
|
1117
1069
|
BaseEvent
|
|
@@ -1140,7 +1092,7 @@ Base event for Streaming
|
|
|
1140
1092
|
|
|
1141
1093
|
> **content**: [`LlmTokenContent`](#classesllmtokencontentmd)[]
|
|
1142
1094
|
|
|
1143
|
-
Defined in: [src/messages/types.ts:42](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/
|
|
1095
|
+
Defined in: [src/messages/types.ts:42](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/messages/types.ts#L42)
|
|
1144
1096
|
|
|
1145
1097
|
***
|
|
1146
1098
|
|
|
@@ -1148,7 +1100,7 @@ Defined in: [src/messages/types.ts:42](https://github.com/vonuyvicoo/haylee-ai-c
|
|
|
1148
1100
|
|
|
1149
1101
|
> **kind**: [`EventKind`](#enumerationseventkindmd)
|
|
1150
1102
|
|
|
1151
|
-
Defined in: [src/messages/types.ts:16](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/
|
|
1103
|
+
Defined in: [src/messages/types.ts:16](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/messages/types.ts#L16)
|
|
1152
1104
|
|
|
1153
1105
|
Used to separate streams
|
|
1154
1106
|
|
|
@@ -1162,7 +1114,7 @@ Used to separate streams
|
|
|
1162
1114
|
|
|
1163
1115
|
> **model**: `string`
|
|
1164
1116
|
|
|
1165
|
-
Defined in: [src/messages/types.ts:46](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/
|
|
1117
|
+
Defined in: [src/messages/types.ts:46](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/messages/types.ts#L46)
|
|
1166
1118
|
|
|
1167
1119
|
***
|
|
1168
1120
|
|
|
@@ -1170,7 +1122,7 @@ Defined in: [src/messages/types.ts:46](https://github.com/vonuyvicoo/haylee-ai-c
|
|
|
1170
1122
|
|
|
1171
1123
|
> **node**: `string`
|
|
1172
1124
|
|
|
1173
|
-
Defined in: [src/messages/types.ts:20](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/
|
|
1125
|
+
Defined in: [src/messages/types.ts:20](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/messages/types.ts#L20)
|
|
1174
1126
|
|
|
1175
1127
|
#### Inherited from
|
|
1176
1128
|
|
|
@@ -1187,7 +1139,7 @@ Defined in: [src/messages/types.ts:20](https://github.com/vonuyvicoo/haylee-ai-c
|
|
|
1187
1139
|
|
|
1188
1140
|
# Class: MessageService
|
|
1189
1141
|
|
|
1190
|
-
Defined in: [src/messages/message.service.ts:
|
|
1142
|
+
Defined in: [src/messages/message.service.ts:49](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/messages/message.service.ts#L49)
|
|
1191
1143
|
|
|
1192
1144
|
## Constructors
|
|
1193
1145
|
|
|
@@ -1195,7 +1147,7 @@ Defined in: [src/messages/message.service.ts:50](https://github.com/vonuyvicoo/h
|
|
|
1195
1147
|
|
|
1196
1148
|
> **new MessageService**(`client`): `MessageService`
|
|
1197
1149
|
|
|
1198
|
-
Defined in: [src/messages/message.service.ts:
|
|
1150
|
+
Defined in: [src/messages/message.service.ts:51](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/messages/message.service.ts#L51)
|
|
1199
1151
|
|
|
1200
1152
|
#### Parameters
|
|
1201
1153
|
|
|
@@ -1213,7 +1165,7 @@ Defined in: [src/messages/message.service.ts:52](https://github.com/vonuyvicoo/h
|
|
|
1213
1165
|
|
|
1214
1166
|
> **stream**(`payload`, `options?`): `Promise`\<`void`\>
|
|
1215
1167
|
|
|
1216
|
-
Defined in: [src/messages/message.service.ts:
|
|
1168
|
+
Defined in: [src/messages/message.service.ts:57](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/messages/message.service.ts#L57)
|
|
1217
1169
|
|
|
1218
1170
|
#### Parameters
|
|
1219
1171
|
|
|
@@ -1244,7 +1196,7 @@ Config for streaming
|
|
|
1244
1196
|
|
|
1245
1197
|
# Class: NotFoundError
|
|
1246
1198
|
|
|
1247
|
-
Defined in: [src/errors/not-found.error.ts:3](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/
|
|
1199
|
+
Defined in: [src/errors/not-found.error.ts:3](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/errors/not-found.error.ts#L3)
|
|
1248
1200
|
|
|
1249
1201
|
## Extends
|
|
1250
1202
|
|
|
@@ -1256,7 +1208,7 @@ Defined in: [src/errors/not-found.error.ts:3](https://github.com/vonuyvicoo/hayl
|
|
|
1256
1208
|
|
|
1257
1209
|
> **new NotFoundError**(`message`): `NotFoundError`
|
|
1258
1210
|
|
|
1259
|
-
Defined in: [src/errors/not-found.error.ts:6](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/
|
|
1211
|
+
Defined in: [src/errors/not-found.error.ts:6](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/errors/not-found.error.ts#L6)
|
|
1260
1212
|
|
|
1261
1213
|
#### Parameters
|
|
1262
1214
|
|
|
@@ -1302,7 +1254,7 @@ Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/li
|
|
|
1302
1254
|
|
|
1303
1255
|
> `readonly` **name**: `string` = `"NotFoundError"`
|
|
1304
1256
|
|
|
1305
|
-
Defined in: [src/errors/not-found.error.ts:4](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/
|
|
1257
|
+
Defined in: [src/errors/not-found.error.ts:4](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/errors/not-found.error.ts#L4)
|
|
1306
1258
|
|
|
1307
1259
|
#### Overrides
|
|
1308
1260
|
|
|
@@ -1453,7 +1405,7 @@ https://v8.dev/docs/stack-trace-api#customizing-stack-traces
|
|
|
1453
1405
|
|
|
1454
1406
|
# Class: ValidationError
|
|
1455
1407
|
|
|
1456
|
-
Defined in: [src/errors/validation.error.ts:3](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/
|
|
1408
|
+
Defined in: [src/errors/validation.error.ts:3](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/errors/validation.error.ts#L3)
|
|
1457
1409
|
|
|
1458
1410
|
## Extends
|
|
1459
1411
|
|
|
@@ -1465,7 +1417,7 @@ Defined in: [src/errors/validation.error.ts:3](https://github.com/vonuyvicoo/hay
|
|
|
1465
1417
|
|
|
1466
1418
|
> **new ValidationError**(`message`, `details?`): `ValidationError`
|
|
1467
1419
|
|
|
1468
|
-
Defined in: [src/errors/validation.error.ts:5](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/
|
|
1420
|
+
Defined in: [src/errors/validation.error.ts:5](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/errors/validation.error.ts#L5)
|
|
1469
1421
|
|
|
1470
1422
|
#### Parameters
|
|
1471
1423
|
|
|
@@ -1503,7 +1455,7 @@ Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/li
|
|
|
1503
1455
|
|
|
1504
1456
|
> `optional` **details**: `any`
|
|
1505
1457
|
|
|
1506
|
-
Defined in: [src/errors/validation.error.ts:5](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/
|
|
1458
|
+
Defined in: [src/errors/validation.error.ts:5](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/errors/validation.error.ts#L5)
|
|
1507
1459
|
|
|
1508
1460
|
***
|
|
1509
1461
|
|
|
@@ -1523,7 +1475,7 @@ Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/li
|
|
|
1523
1475
|
|
|
1524
1476
|
> `readonly` **name**: `string` = `"ValidationError"`
|
|
1525
1477
|
|
|
1526
|
-
Defined in: [src/errors/validation.error.ts:4](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/
|
|
1478
|
+
Defined in: [src/errors/validation.error.ts:4](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/errors/validation.error.ts#L4)
|
|
1527
1479
|
|
|
1528
1480
|
#### Overrides
|
|
1529
1481
|
|
|
@@ -1674,7 +1626,7 @@ https://v8.dev/docs/stack-trace-api#customizing-stack-traces
|
|
|
1674
1626
|
|
|
1675
1627
|
# Enumeration: EventKind
|
|
1676
1628
|
|
|
1677
|
-
Defined in: [src/messages/types.ts:1](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/
|
|
1629
|
+
Defined in: [src/messages/types.ts:1](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/messages/types.ts#L1)
|
|
1678
1630
|
|
|
1679
1631
|
## Enumeration Members
|
|
1680
1632
|
|
|
@@ -1682,7 +1634,7 @@ Defined in: [src/messages/types.ts:1](https://github.com/vonuyvicoo/haylee-ai-ch
|
|
|
1682
1634
|
|
|
1683
1635
|
> **LLM\_TOKEN**: `"llm_token"`
|
|
1684
1636
|
|
|
1685
|
-
Defined in: [src/messages/types.ts:2](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/
|
|
1637
|
+
Defined in: [src/messages/types.ts:2](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/messages/types.ts#L2)
|
|
1686
1638
|
|
|
1687
1639
|
***
|
|
1688
1640
|
|
|
@@ -1690,7 +1642,7 @@ Defined in: [src/messages/types.ts:2](https://github.com/vonuyvicoo/haylee-ai-ch
|
|
|
1690
1642
|
|
|
1691
1643
|
> **TOOLS**: `"tools"`
|
|
1692
1644
|
|
|
1693
|
-
Defined in: [src/messages/types.ts:3](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/
|
|
1645
|
+
Defined in: [src/messages/types.ts:3](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/messages/types.ts#L3)
|
|
1694
1646
|
|
|
1695
1647
|
|
|
1696
1648
|
<a name="enumerationsrolemd"></a>
|
|
@@ -1703,7 +1655,7 @@ Defined in: [src/messages/types.ts:3](https://github.com/vonuyvicoo/haylee-ai-ch
|
|
|
1703
1655
|
|
|
1704
1656
|
# Enumeration: Role
|
|
1705
1657
|
|
|
1706
|
-
Defined in: [src/types/chat.interface.ts:19](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/
|
|
1658
|
+
Defined in: [src/types/chat.interface.ts:19](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/types/chat.interface.ts#L19)
|
|
1707
1659
|
|
|
1708
1660
|
## Enumeration Members
|
|
1709
1661
|
|
|
@@ -1711,7 +1663,7 @@ Defined in: [src/types/chat.interface.ts:19](https://github.com/vonuyvicoo/hayle
|
|
|
1711
1663
|
|
|
1712
1664
|
> **AI**: `"ai"`
|
|
1713
1665
|
|
|
1714
|
-
Defined in: [src/types/chat.interface.ts:21](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/
|
|
1666
|
+
Defined in: [src/types/chat.interface.ts:21](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/types/chat.interface.ts#L21)
|
|
1715
1667
|
|
|
1716
1668
|
***
|
|
1717
1669
|
|
|
@@ -1719,7 +1671,7 @@ Defined in: [src/types/chat.interface.ts:21](https://github.com/vonuyvicoo/hayle
|
|
|
1719
1671
|
|
|
1720
1672
|
> **HUMAN**: `"human"`
|
|
1721
1673
|
|
|
1722
|
-
Defined in: [src/types/chat.interface.ts:20](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/
|
|
1674
|
+
Defined in: [src/types/chat.interface.ts:20](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/types/chat.interface.ts#L20)
|
|
1723
1675
|
|
|
1724
1676
|
|
|
1725
1677
|
<a name="enumerationstoolstatusmd"></a>
|
|
@@ -1732,7 +1684,7 @@ Defined in: [src/types/chat.interface.ts:20](https://github.com/vonuyvicoo/hayle
|
|
|
1732
1684
|
|
|
1733
1685
|
# Enumeration: ToolStatus
|
|
1734
1686
|
|
|
1735
|
-
Defined in: [src/messages/types.ts:62](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/
|
|
1687
|
+
Defined in: [src/messages/types.ts:62](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/messages/types.ts#L62)
|
|
1736
1688
|
|
|
1737
1689
|
## Enumeration Members
|
|
1738
1690
|
|
|
@@ -1740,7 +1692,7 @@ Defined in: [src/messages/types.ts:62](https://github.com/vonuyvicoo/haylee-ai-c
|
|
|
1740
1692
|
|
|
1741
1693
|
> **END**: `"END"`
|
|
1742
1694
|
|
|
1743
|
-
Defined in: [src/messages/types.ts:64](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/
|
|
1695
|
+
Defined in: [src/messages/types.ts:64](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/messages/types.ts#L64)
|
|
1744
1696
|
|
|
1745
1697
|
***
|
|
1746
1698
|
|
|
@@ -1748,7 +1700,7 @@ Defined in: [src/messages/types.ts:64](https://github.com/vonuyvicoo/haylee-ai-c
|
|
|
1748
1700
|
|
|
1749
1701
|
> **ERROR**: `"ERROR"`
|
|
1750
1702
|
|
|
1751
|
-
Defined in: [src/messages/types.ts:65](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/
|
|
1703
|
+
Defined in: [src/messages/types.ts:65](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/messages/types.ts#L65)
|
|
1752
1704
|
|
|
1753
1705
|
***
|
|
1754
1706
|
|
|
@@ -1756,7 +1708,7 @@ Defined in: [src/messages/types.ts:65](https://github.com/vonuyvicoo/haylee-ai-c
|
|
|
1756
1708
|
|
|
1757
1709
|
> **START**: `"START"`
|
|
1758
1710
|
|
|
1759
|
-
Defined in: [src/messages/types.ts:63](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/
|
|
1711
|
+
Defined in: [src/messages/types.ts:63](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/messages/types.ts#L63)
|
|
1760
1712
|
|
|
1761
1713
|
|
|
1762
1714
|
<a name="interfacesmessageserviceoptionsmd"></a>
|
|
@@ -1769,7 +1721,7 @@ Defined in: [src/messages/types.ts:63](https://github.com/vonuyvicoo/haylee-ai-c
|
|
|
1769
1721
|
|
|
1770
1722
|
# Interface: MessageServiceOptions
|
|
1771
1723
|
|
|
1772
|
-
Defined in: [src/messages/message.service.ts:
|
|
1724
|
+
Defined in: [src/messages/message.service.ts:12](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/messages/message.service.ts#L12)
|
|
1773
1725
|
|
|
1774
1726
|
## Properties
|
|
1775
1727
|
|
|
@@ -1777,7 +1729,7 @@ Defined in: [src/messages/message.service.ts:13](https://github.com/vonuyvicoo/h
|
|
|
1777
1729
|
|
|
1778
1730
|
> `optional` **signal**: `AbortSignal`
|
|
1779
1731
|
|
|
1780
|
-
Defined in: [src/messages/message.service.ts:
|
|
1732
|
+
Defined in: [src/messages/message.service.ts:46](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/messages/message.service.ts#L46)
|
|
1781
1733
|
|
|
1782
1734
|
AbortSignal for terminating the upstream stream
|
|
1783
1735
|
|
|
@@ -1787,7 +1739,7 @@ AbortSignal for terminating the upstream stream
|
|
|
1787
1739
|
|
|
1788
1740
|
> `optional` **onEnd**(`ev`): `void`
|
|
1789
1741
|
|
|
1790
|
-
Defined in: [src/messages/message.service.ts:
|
|
1742
|
+
Defined in: [src/messages/message.service.ts:22](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/messages/message.service.ts#L22)
|
|
1791
1743
|
|
|
1792
1744
|
triggers upon stream end
|
|
1793
1745
|
|
|
@@ -1809,7 +1761,7 @@ EndEvent
|
|
|
1809
1761
|
|
|
1810
1762
|
> `optional` **onError**(`err`): `void`
|
|
1811
1763
|
|
|
1812
|
-
Defined in: [src/messages/message.service.ts:
|
|
1764
|
+
Defined in: [src/messages/message.service.ts:42](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/messages/message.service.ts#L42)
|
|
1813
1765
|
|
|
1814
1766
|
Streams errors on runtime
|
|
1815
1767
|
|
|
@@ -1829,7 +1781,7 @@ Streams errors on runtime
|
|
|
1829
1781
|
|
|
1830
1782
|
> `optional` **onLlmToken**(`ev`): `void`
|
|
1831
1783
|
|
|
1832
|
-
Defined in: [src/messages/message.service.ts:
|
|
1784
|
+
Defined in: [src/messages/message.service.ts:17](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/messages/message.service.ts#L17)
|
|
1833
1785
|
|
|
1834
1786
|
Streams llm tokens for output
|
|
1835
1787
|
|
|
@@ -1849,7 +1801,7 @@ Streams llm tokens for output
|
|
|
1849
1801
|
|
|
1850
1802
|
> `optional` **onToolEnd**(`ev`): `void`
|
|
1851
1803
|
|
|
1852
|
-
Defined in: [src/messages/message.service.ts:
|
|
1804
|
+
Defined in: [src/messages/message.service.ts:32](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/messages/message.service.ts#L32)
|
|
1853
1805
|
|
|
1854
1806
|
Streams tool end updates
|
|
1855
1807
|
|
|
@@ -1871,7 +1823,7 @@ ToolEvent
|
|
|
1871
1823
|
|
|
1872
1824
|
> `optional` **onToolError**(`ev`): `void`
|
|
1873
1825
|
|
|
1874
|
-
Defined in: [src/messages/message.service.ts:
|
|
1826
|
+
Defined in: [src/messages/message.service.ts:37](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/messages/message.service.ts#L37)
|
|
1875
1827
|
|
|
1876
1828
|
Streams tool errors
|
|
1877
1829
|
|
|
@@ -1893,7 +1845,7 @@ ToolEvent
|
|
|
1893
1845
|
|
|
1894
1846
|
> `optional` **onToolStart**(`ev`): `void`
|
|
1895
1847
|
|
|
1896
|
-
Defined in: [src/messages/message.service.ts:
|
|
1848
|
+
Defined in: [src/messages/message.service.ts:27](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/messages/message.service.ts#L27)
|
|
1897
1849
|
|
|
1898
1850
|
Streams tool start updates
|
|
1899
1851
|
|
|
@@ -1920,7 +1872,7 @@ ToolEvent
|
|
|
1920
1872
|
|
|
1921
1873
|
# Interface: ToolContent
|
|
1922
1874
|
|
|
1923
|
-
Defined in: [src/messages/types.ts:68](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/
|
|
1875
|
+
Defined in: [src/messages/types.ts:68](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/messages/types.ts#L68)
|
|
1924
1876
|
|
|
1925
1877
|
## Properties
|
|
1926
1878
|
|
|
@@ -1928,7 +1880,7 @@ Defined in: [src/messages/types.ts:68](https://github.com/vonuyvicoo/haylee-ai-c
|
|
|
1928
1880
|
|
|
1929
1881
|
> **params**: `unknown`
|
|
1930
1882
|
|
|
1931
|
-
Defined in: [src/messages/types.ts:69](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/
|
|
1883
|
+
Defined in: [src/messages/types.ts:69](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/messages/types.ts#L69)
|
|
1932
1884
|
|
|
1933
1885
|
|
|
1934
1886
|
<a name="interfacestooleventmd"></a>
|
|
@@ -1941,7 +1893,7 @@ Defined in: [src/messages/types.ts:69](https://github.com/vonuyvicoo/haylee-ai-c
|
|
|
1941
1893
|
|
|
1942
1894
|
# Interface: ToolEvent
|
|
1943
1895
|
|
|
1944
|
-
Defined in: [src/messages/types.ts:53](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/
|
|
1896
|
+
Defined in: [src/messages/types.ts:53](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/messages/types.ts#L53)
|
|
1945
1897
|
|
|
1946
1898
|
Base event for Streaming
|
|
1947
1899
|
BaseEvent
|
|
@@ -1956,7 +1908,7 @@ Base event for Streaming
|
|
|
1956
1908
|
|
|
1957
1909
|
> `optional` **content**: [`ToolContent`](#interfacestoolcontentmd)
|
|
1958
1910
|
|
|
1959
|
-
Defined in: [src/messages/types.ts:54](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/
|
|
1911
|
+
Defined in: [src/messages/types.ts:54](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/messages/types.ts#L54)
|
|
1960
1912
|
|
|
1961
1913
|
***
|
|
1962
1914
|
|
|
@@ -1964,7 +1916,7 @@ Defined in: [src/messages/types.ts:54](https://github.com/vonuyvicoo/haylee-ai-c
|
|
|
1964
1916
|
|
|
1965
1917
|
> `optional` **error**: `unknown`
|
|
1966
1918
|
|
|
1967
|
-
Defined in: [src/messages/types.ts:59](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/
|
|
1919
|
+
Defined in: [src/messages/types.ts:59](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/messages/types.ts#L59)
|
|
1968
1920
|
|
|
1969
1921
|
***
|
|
1970
1922
|
|
|
@@ -1972,7 +1924,7 @@ Defined in: [src/messages/types.ts:59](https://github.com/vonuyvicoo/haylee-ai-c
|
|
|
1972
1924
|
|
|
1973
1925
|
> **kind**: [`EventKind`](#enumerationseventkindmd)
|
|
1974
1926
|
|
|
1975
|
-
Defined in: [src/messages/types.ts:16](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/
|
|
1927
|
+
Defined in: [src/messages/types.ts:16](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/messages/types.ts#L16)
|
|
1976
1928
|
|
|
1977
1929
|
Used to separate streams
|
|
1978
1930
|
|
|
@@ -1986,7 +1938,7 @@ Used to separate streams
|
|
|
1986
1938
|
|
|
1987
1939
|
> **name**: `string`
|
|
1988
1940
|
|
|
1989
|
-
Defined in: [src/messages/types.ts:55](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/
|
|
1941
|
+
Defined in: [src/messages/types.ts:55](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/messages/types.ts#L55)
|
|
1990
1942
|
|
|
1991
1943
|
***
|
|
1992
1944
|
|
|
@@ -1994,7 +1946,7 @@ Defined in: [src/messages/types.ts:55](https://github.com/vonuyvicoo/haylee-ai-c
|
|
|
1994
1946
|
|
|
1995
1947
|
> **node**: `string`
|
|
1996
1948
|
|
|
1997
|
-
Defined in: [src/messages/types.ts:20](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/
|
|
1949
|
+
Defined in: [src/messages/types.ts:20](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/messages/types.ts#L20)
|
|
1998
1950
|
|
|
1999
1951
|
#### Inherited from
|
|
2000
1952
|
|
|
@@ -2006,7 +1958,7 @@ Defined in: [src/messages/types.ts:20](https://github.com/vonuyvicoo/haylee-ai-c
|
|
|
2006
1958
|
|
|
2007
1959
|
> **results**: [`ToolResultContent`](#interfacestoolresultcontentmd)[]
|
|
2008
1960
|
|
|
2009
|
-
Defined in: [src/messages/types.ts:58](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/
|
|
1961
|
+
Defined in: [src/messages/types.ts:58](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/messages/types.ts#L58)
|
|
2010
1962
|
|
|
2011
1963
|
***
|
|
2012
1964
|
|
|
@@ -2014,7 +1966,7 @@ Defined in: [src/messages/types.ts:58](https://github.com/vonuyvicoo/haylee-ai-c
|
|
|
2014
1966
|
|
|
2015
1967
|
> **status**: [`ToolStatus`](#enumerationstoolstatusmd)
|
|
2016
1968
|
|
|
2017
|
-
Defined in: [src/messages/types.ts:57](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/
|
|
1969
|
+
Defined in: [src/messages/types.ts:57](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/messages/types.ts#L57)
|
|
2018
1970
|
|
|
2019
1971
|
***
|
|
2020
1972
|
|
|
@@ -2022,7 +1974,7 @@ Defined in: [src/messages/types.ts:57](https://github.com/vonuyvicoo/haylee-ai-c
|
|
|
2022
1974
|
|
|
2023
1975
|
> `optional` **tool\_call\_id**: `string`
|
|
2024
1976
|
|
|
2025
|
-
Defined in: [src/messages/types.ts:56](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/
|
|
1977
|
+
Defined in: [src/messages/types.ts:56](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/messages/types.ts#L56)
|
|
2026
1978
|
|
|
2027
1979
|
|
|
2028
1980
|
<a name="interfacestoolresultcontentmd"></a>
|
|
@@ -2035,7 +1987,7 @@ Defined in: [src/messages/types.ts:56](https://github.com/vonuyvicoo/haylee-ai-c
|
|
|
2035
1987
|
|
|
2036
1988
|
# Interface: ToolResultContent
|
|
2037
1989
|
|
|
2038
|
-
Defined in: [src/messages/types.ts:72](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/
|
|
1990
|
+
Defined in: [src/messages/types.ts:72](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/messages/types.ts#L72)
|
|
2039
1991
|
|
|
2040
1992
|
## Properties
|
|
2041
1993
|
|
|
@@ -2043,7 +1995,7 @@ Defined in: [src/messages/types.ts:72](https://github.com/vonuyvicoo/haylee-ai-c
|
|
|
2043
1995
|
|
|
2044
1996
|
> **content**: `any`
|
|
2045
1997
|
|
|
2046
|
-
Defined in: [src/messages/types.ts:76](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/
|
|
1998
|
+
Defined in: [src/messages/types.ts:76](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/messages/types.ts#L76)
|
|
2047
1999
|
|
|
2048
2000
|
***
|
|
2049
2001
|
|
|
@@ -2051,7 +2003,7 @@ Defined in: [src/messages/types.ts:76](https://github.com/vonuyvicoo/haylee-ai-c
|
|
|
2051
2003
|
|
|
2052
2004
|
> **type**: `string`
|
|
2053
2005
|
|
|
2054
|
-
Defined in: [src/messages/types.ts:74](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/
|
|
2006
|
+
Defined in: [src/messages/types.ts:74](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/messages/types.ts#L74)
|
|
2055
2007
|
|
|
2056
2008
|
|
|
2057
2009
|
<a name="type-aliaseshayleeaichatclientoptionsmd"></a>
|
|
@@ -2066,7 +2018,7 @@ Defined in: [src/messages/types.ts:74](https://github.com/vonuyvicoo/haylee-ai-c
|
|
|
2066
2018
|
|
|
2067
2019
|
> **HayleeAIChatClientOptions** = `object`
|
|
2068
2020
|
|
|
2069
|
-
Defined in: [src/\_internal/client.ts:9](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/
|
|
2021
|
+
Defined in: [src/\_internal/client.ts:9](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/_internal/client.ts#L9)
|
|
2070
2022
|
|
|
2071
2023
|
Options for the HayleeAI Client
|
|
2072
2024
|
|
|
@@ -2076,6 +2028,6 @@ Options for the HayleeAI Client
|
|
|
2076
2028
|
|
|
2077
2029
|
> `optional` **baseUrl**: `string`
|
|
2078
2030
|
|
|
2079
|
-
Defined in: [src/\_internal/client.ts:10](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/
|
|
2031
|
+
Defined in: [src/\_internal/client.ts:10](https://github.com/vonuyvicoo/haylee-ai-chat-sdk/blob/018702b4a1a1d71cf27b821e9dea5ad0b3aa5d5b/src/_internal/client.ts#L10)
|
|
2080
2032
|
|
|
2081
2033
|
Optional base URL, defaults to production
|
package/dist/index.cjs
CHANGED
|
@@ -37,7 +37,6 @@ __export(index_exports, {
|
|
|
37
37
|
HayleeAI: () => HayleeAI,
|
|
38
38
|
HayleeAIClient: () => HayleeAIClient,
|
|
39
39
|
HayleeAIError: () => HayleeAIError,
|
|
40
|
-
IHistoryPayload: () => IHistoryPayload,
|
|
41
40
|
LlmTokenContent: () => LlmTokenContent,
|
|
42
41
|
LlmTokenEvent: () => LlmTokenEvent,
|
|
43
42
|
MessageService: () => MessageService,
|
|
@@ -268,27 +267,19 @@ var AuthenticationError = class _AuthenticationError extends HayleeAIError {
|
|
|
268
267
|
var import_class_validator = require("class-validator");
|
|
269
268
|
var CreateMessageDto = class {
|
|
270
269
|
message;
|
|
271
|
-
|
|
272
|
-
conversation_history;
|
|
270
|
+
conversation_id;
|
|
273
271
|
};
|
|
274
272
|
__decorateClass([
|
|
275
273
|
(0, import_class_validator.IsString)()
|
|
276
274
|
], CreateMessageDto.prototype, "message", 2);
|
|
275
|
+
__decorateClass([
|
|
276
|
+
(0, import_class_validator.IsOptional)()
|
|
277
|
+
], CreateMessageDto.prototype, "conversation_id", 2);
|
|
277
278
|
var Role = /* @__PURE__ */ ((Role2) => {
|
|
278
279
|
Role2["HUMAN"] = "human";
|
|
279
280
|
Role2["AI"] = "ai";
|
|
280
281
|
return Role2;
|
|
281
282
|
})(Role || {});
|
|
282
|
-
var IHistoryPayload = class {
|
|
283
|
-
role;
|
|
284
|
-
content;
|
|
285
|
-
};
|
|
286
|
-
__decorateClass([
|
|
287
|
-
(0, import_class_validator.IsEnum)(Role)
|
|
288
|
-
], IHistoryPayload.prototype, "role", 2);
|
|
289
|
-
__decorateClass([
|
|
290
|
-
(0, import_class_validator.IsString)()
|
|
291
|
-
], IHistoryPayload.prototype, "content", 2);
|
|
292
283
|
|
|
293
284
|
// src/index.ts
|
|
294
285
|
var HayleeAI = class extends HayleeAIClient {
|
|
@@ -312,7 +303,6 @@ var HayleeAI = class extends HayleeAIClient {
|
|
|
312
303
|
HayleeAI,
|
|
313
304
|
HayleeAIClient,
|
|
314
305
|
HayleeAIError,
|
|
315
|
-
IHistoryPayload,
|
|
316
306
|
LlmTokenContent,
|
|
317
307
|
LlmTokenEvent,
|
|
318
308
|
MessageService,
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/_internal/client.ts","../src/messages/types.ts","../src/errors/base.ts","../src/errors/parse.error.ts","../src/_shared/parse.helper.ts","../src/messages/message.service.ts","../src/errors/validation.error.ts","../src/errors/not-found.error.ts","../src/errors/authorization.error.ts","../src/errors/authentication.error.ts","../src/types/chat.interface.ts"],"sourcesContent":["import { HayleeAIClient, HayleeAIChatClientOptions } from \"./_internal/client\";\nimport { MessageService } from \"./messages\";\n\n/**\n * Instantiate a new HayleeAI connection\n */\nclass HayleeAI extends HayleeAIClient {\n public messages: MessageService;\n\n /**\n * @param options - HayleeAIChatClientOptions \n */\n constructor(options: HayleeAIChatClientOptions){\n super(options);\n this.messages = new MessageService(this);\n }\n}\n\nexport {\n HayleeAI,\n HayleeAIChatClientOptions \n}\nexport * from \"./errors\";\nexport * from \"./messages\";\nexport * from \"./types/chat.interface\";\nexport * from \"./_internal/client\";\n","import { CreateMessageDto } from \"@/types/chat.interface\";\nimport { fetchEventSource } from \"@microsoft/fetch-event-source\";\n\n/**\n * Options for the HayleeAI Client \n * @property apiKey - API key for authentication\n * @property baseUrl - Optional base URL, defaults to production\n */\nexport type HayleeAIChatClientOptions = {\n baseUrl?: string;\n}\n\n/**\n * Internal HayleeAI Client. Do not use unless necessary.\n * @class HayleeAIClient \n * @property baseURL - Base URL to make requests to\n */\nexport class HayleeAIClient {\n /**\n * @property baseURL - the base URL to make requests to\n */\n private baseURL: string;\n /**\n * @param options - Auth, and baseURL\n */\n constructor(options: HayleeAIChatClientOptions) {\n this.baseURL = options.baseUrl || \"http://localhost:3000/api/v1/chat\";\n }\n\n /**\n * Internal stream callout\n * @param payload - Message DTO\n * @param [signal] - Abort signal\n */\n async *_stream(payload: CreateMessageDto, signal?: AbortSignal) {\n const queue: string[] = [];\n let resolve: (() => void) | null = null;\n let done = false;\n\n fetchEventSource(`${this.baseURL}`, {\n headers: {\n 'Content-Type': 'application/json',\n },\n credentials: 'include',\n method: 'POST',\n body: JSON.stringify(payload),\n openWhenHidden: true,\n onmessage(ev) {\n queue.push(ev.data);\n resolve?.(); // wake up the generator\n },\n onclose() {\n done = true;\n resolve?.();\n },\n onerror(err) {\n done = true;\n resolve?.();\n throw err;\n },\n signal\n });\n\n if (signal) {\n signal.addEventListener(\"abort\", () => {\n done = true;\n resolve?.();\n });\n }\n\n while (!done || queue.length > 0) {\n if (queue.length === 0) {\n //wait until onmessage pushes something\n await new Promise<void>(r => { resolve = r; });\n }\n while (queue.length > 0) {\n yield queue.shift()!;\n }\n }\n }}\n","export enum EventKind {\n LLM_TOKEN = \"llm_token\",\n TOOLS = \"tools\"\n}\n\n/**\n * Base event for Streaming\n * @class BaseEvent\n * @property kind - Used to separate streams\n * @property node - Source node in langgraph\n */\nexport class BaseEvent {\n /*\n * @property kind - Used to separate streams\n */\n kind!: EventKind;\n /**\n * @property node - Source node in langgraph\n */\n node!: string;\n}\n\n\n/**\n * @class LLmTokenContent\n */\nexport class LlmTokenContent {\n /**\n * @property type - Always text\n */\n type!: \"text\";\n /**\n * @property text - The text content\n */\n text!: string;\n}\n\nexport class LlmTokenEvent extends BaseEvent {\n /**\n * @property content - An array of LlmTokenContent. Always an array. Non-empty or empty. Make sure to handle all items in the array.\n */\n content!: LlmTokenContent[];\n /**\n * @property model - The LLM model used.\n */\n model!: string;\n}\n\nexport class EndEvent {\n success!: boolean;\n}\n\nexport interface ToolEvent extends BaseEvent {\n content?: ToolContent;\n name: string;\n tool_call_id?: string;\n status: ToolStatus;\n results: ToolResultContent[];\n error?: unknown;\n}\n\nexport enum ToolStatus {\n START = \"START\",\n END = \"END\",\n ERROR = \"ERROR\"\n}\n\nexport interface ToolContent {\n params: unknown;\n}\n\nexport interface ToolResultContent {\n /* type is text or json */\n type: string;\n /* can be string or object or array, ANY */\n content: any;\n}\n\n","export class HayleeAIError extends Error {\n public readonly name: string = \"HayleeAIError\";\n\n constructor(message: string) {\n super(message);\n Object.setPrototypeOf(this, HayleeAIError.prototype);\n }\n}\n","import { HayleeAIError } from \"./base\";\n\nexport class ParseError extends HayleeAIError {\n public readonly name: string = \"ParseError\";\n constructor(message: string, public details?: any){\n super(message);\n Object.setPrototypeOf(this, ParseError.prototype);\n }\n}\n","import { ParseError } from \"@/errors/parse.error\";\n\nexport function parseEvent<T>(data: string): T {\n try {\n return JSON.parse(data) as T;\n } catch {\n throw new ParseError(\"Failed to parse event data to JSON.\");\n }\n}\n","import { CreateMessageDto } from \"../types/chat.interface\";\nimport { parseEvent } from \"@/_shared/parse.helper\";\nimport { BaseEvent, EndEvent, EventKind, LlmTokenEvent, ToolEvent, ToolStatus } from \"./types\";\nimport { HayleeAIClient } from \"@/_internal/client\";\nimport { type } from \"os\";\n\n/**\n * @property onLlmToken - Streams llm tokens for output\n * @property onSearchUpdate - Streams pending / done updates along with search results if status is DONE\n * @property onError - Streams errors on runtime\n * @property signal - AbortSignal for terminating the upstream stream\n */\nexport interface MessageServiceOptions {\n /**\n * Streams llm tokens for output\n * @param ev - LlmTokenEvent\n */\n onLlmToken?(ev: LlmTokenEvent): void;\n /**\n * triggers upon stream end\n * @param ev - EndEvent\n * */\n onEnd?(ev: EndEvent): void;\n /**\n * Streams tool start updates\n * @param ev - ToolEvent\n */\n onToolStart?(ev: ToolEvent): void;\n /**\n * Streams tool end updates\n * @param ev - ToolEvent\n */\n onToolEnd?(ev: ToolEvent): void;\n /**\n * Streams tool errors\n * @param ev - ToolEvent\n */\n onToolError?(ev: ToolEvent): void;\n /**\n * Streams errors on runtime\n * @param err - Error or unknown value\n */\n onError?(err: unknown): void;\n /**\n * @property signal - Abort signal to abort the stream\n */\n signal?: AbortSignal;\n}\n\nexport class MessageService {\n\n constructor(private readonly client: HayleeAIClient) {}\n\n /**\n * @param payload - The create message payload\n * @param options - Config for streaming\n */\n async stream(payload: CreateMessageDto, options?: MessageServiceOptions) {\n\n for await (const ev of this.client._stream(payload, options?.signal)) {\n if(!ev || !ev.trim()) continue;\n try {\n const event = parseEvent<BaseEvent>(ev);\n\n switch(event.kind) {\n case EventKind.LLM_TOKEN: {\n options?.onLlmToken?.(event as LlmTokenEvent);\n break;\n }\n case EventKind.TOOLS: {\n const typedEvent = event as ToolEvent;\n if(typedEvent.status == ToolStatus.START) {\n options?.onToolStart?.(typedEvent);\n } else if (typedEvent.status == ToolStatus.END) {\n options?.onToolEnd?.(typedEvent);\n } else if(typedEvent.status == ToolStatus.ERROR) {\n options?.onToolError?.(typedEvent);\n }\n break;\n }\n }\n } catch (err) {\n options?.onEnd?.({ success: false });\n //throw new ParseError(\"Failed to parse event data to JSON.\")\n console.error(\"Failed to parse event data to JSON.\", err);\n options?.onError?.(err);\n }\n }\n options?.onEnd?.({ success: true });\n }\n\n}\n","import { HayleeAIError } from \"./base\";\n\nexport class ValidationError extends HayleeAIError {\n public readonly name: string = \"ValidationError\";\n constructor(message: string, public details?: any){\n super(message);\n Object.setPrototypeOf(this, ValidationError.prototype);\n }\n}\n","import { HayleeAIError } from \"./base\";\n\nexport class NotFoundError extends HayleeAIError {\n public readonly name: string = \"NotFoundError\";\n\n constructor(message: string) {\n super(message);\n Object.setPrototypeOf(this, NotFoundError.prototype);\n }\n}\n","import { HayleeAIError } from \"./base\";\n\nexport class AuthorizationError extends HayleeAIError {\n public readonly name: string = \"AuthorizationError\";\n\n constructor(message: string) {\n super(message);\n Object.setPrototypeOf(this, AuthorizationError.prototype);\n }\n}\n\n\n","import { HayleeAIError } from \"./base\";\n\nexport class AuthenticationError extends HayleeAIError {\n public readonly name: string = \"AuthenticationError\";\n\n constructor(message: string) {\n super(message);\n Object.setPrototypeOf(this, AuthenticationError.prototype);\n }\n}\n\n","import { IsEnum, IsString } from \"class-validator\";\n\n/** \n * DTO for creating a message\n * @property message - User message\n * @property conversation_history - Array of messages\n */\nexport class CreateMessageDto {\n /* Message to send */\n @IsString()\n message!: string;\n /* Array of messages */\n conversation_history!: IHistoryPayload[];\n}\n\n/*\n * @enum Role - Role of message\n */\nexport enum Role {\n HUMAN = \"human\",\n AI = \"ai\"\n}\n\n\n/**\n * History payload\n * @property role - Role of message sender\n * @property content - Content of message\n */\nexport class IHistoryPayload {\n @IsEnum(Role)\n role!: Role;\n @IsString()\n content!: string;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,gCAAiC;AAgB1B,IAAM,iBAAN,MAAqB;AAAA;AAAA;AAAA;AAAA,EAIhB;AAAA;AAAA;AAAA;AAAA,EAIR,YAAY,SAAoC;AAC5C,SAAK,UAAU,QAAQ,WAAW;AAAA,EACtC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,OAAO,QAAQ,SAA2B,QAAsB;AAC5D,UAAM,QAAkB,CAAC;AACzB,QAAI,UAA+B;AACnC,QAAI,OAAO;AAEX,oDAAiB,GAAG,KAAK,OAAO,IAAI;AAAA,MAChC,SAAS;AAAA,QACL,gBAAgB;AAAA,MACpB;AAAA,MACA,aAAa;AAAA,MACb,QAAQ;AAAA,MACR,MAAM,KAAK,UAAU,OAAO;AAAA,MAC5B,gBAAgB;AAAA,MAChB,UAAU,IAAI;AACV,cAAM,KAAK,GAAG,IAAI;AAClB,kBAAU;AAAA,MACd;AAAA,MACA,UAAU;AACN,eAAO;AACP,kBAAU;AAAA,MACd;AAAA,MACA,QAA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SAAS;AAAA,EACzD;AAAA,EAJgB,OAAe;AAKnC;;;ACNO,IAAM,gBAAN,MAAM,uBAAsB,cAAc;AAAA,EAC7B,OAAe;AAAA,EAE/B,YAAY,SAAiB;AACzB,UAAM,OAAO;AACb,WAAO,eAAe,MAAM,eAAc,SAAS;AAAA,EACvD;AACJ;;;ACPO,IAAM,qBAAN,MAAM,4BAA2B,cAAc;AAAA,EAClC,OAAe;AAAA,EAE/B,YAAY,SAAiB;AACzB,UAAM,OAAO;AACb,WAAO,eAAe,MAAM,oBAAmB,SAAS;AAAA,EAC5D;AACJ;;;ACPO,IAAM,sBAAN,MAAM,6BAA4B,cAAc;AAAA,EACnC,OAAe;AAAA,EAE/B,YAAY,SAAiB;AACzB,UAAM,OAAO;AACb,WAAO,eAAe,MAAM,qBAAoB,SAAS;AAAA,EAC7D;AACJ;;;ACTA,6BAAiC;AAO1B,IAAM,mBAAN,MAAuB;AAAA,EAG1B;AAAA;AAAA,EAEA;AACJ;AAHI;AAAA,MADC,iCAAS;AAAA,GAFD,iBAGT;AAQG,IAAK,OAAL,kBAAKC,UAAL;AACH,EAAAA,MAAA,WAAQ;AACR,EAAAA,MAAA,QAAK;AAFG,SAAAA;AAAA,GAAA;AAWL,IAAM,kBAAN,MAAsB;AAAA,EAEzB;AAAA,EAEA;AACJ;AAHI;AAAA,MADC,+BAAO,IAAI;AAAA,GADH,gBAET;AAEA;AAAA,MADC,iCAAS;AAAA,GAHD,gBAIT;;;AX3BJ,IAAM,WAAN,cAAuB,eAAe;AAAA,EAC3B;AAAA;AAAA;AAAA;AAAA,EAKP,YAAY,SAAmC;AAC3C,UAAM,OAAO;AACb,SAAK,WAAW,IAAI,eAAe,IAAI;AAAA,EAC3C;AACJ;","names":["EventKind","ToolStatus","Role"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/_internal/client.ts","../src/messages/types.ts","../src/errors/base.ts","../src/errors/parse.error.ts","../src/_shared/parse.helper.ts","../src/messages/message.service.ts","../src/errors/validation.error.ts","../src/errors/not-found.error.ts","../src/errors/authorization.error.ts","../src/errors/authentication.error.ts","../src/types/chat.interface.ts"],"sourcesContent":["import { HayleeAIClient, HayleeAIChatClientOptions } from \"./_internal/client\";\nimport { MessageService } from \"./messages\";\n\n/**\n * Instantiate a new HayleeAI connection\n */\nclass HayleeAI extends HayleeAIClient {\n public messages: MessageService;\n\n /**\n * @param options - HayleeAIChatClientOptions \n */\n constructor(options: HayleeAIChatClientOptions){\n super(options);\n this.messages = new MessageService(this);\n }\n}\n\nexport {\n HayleeAI,\n HayleeAIChatClientOptions \n}\nexport * from \"./errors\";\nexport * from \"./messages\";\nexport * from \"./types/chat.interface\";\nexport * from \"./_internal/client\";\n","import { CreateMessageDto } from \"@/types/chat.interface\";\nimport { fetchEventSource } from \"@microsoft/fetch-event-source\";\n\n/**\n * Options for the HayleeAI Client \n * @property apiKey - API key for authentication\n * @property baseUrl - Optional base URL, defaults to production\n */\nexport type HayleeAIChatClientOptions = {\n baseUrl?: string;\n}\n\n/**\n * Internal HayleeAI Client. Do not use unless necessary.\n * @class HayleeAIClient \n * @property baseURL - Base URL to make requests to\n */\nexport class HayleeAIClient {\n /**\n * @property baseURL - the base URL to make requests to\n */\n private baseURL: string;\n /**\n * @param options - Auth, and baseURL\n */\n constructor(options: HayleeAIChatClientOptions) {\n this.baseURL = options.baseUrl || \"http://localhost:3000/api/v1/chat\";\n }\n\n /**\n * Internal stream callout\n * @param payload - Message DTO\n * @param [signal] - Abort signal\n */\n async *_stream(payload: CreateMessageDto, signal?: AbortSignal) {\n const queue: string[] = [];\n let resolve: (() => void) | null = null;\n let done = false;\n\n fetchEventSource(`${this.baseURL}`, {\n headers: {\n 'Content-Type': 'application/json',\n },\n credentials: 'include',\n method: 'POST',\n body: JSON.stringify(payload),\n openWhenHidden: true,\n onmessage(ev) {\n queue.push(ev.data);\n resolve?.(); // wake up the generator\n },\n onclose() {\n done = true;\n resolve?.();\n },\n onerror(err) {\n done = true;\n resolve?.();\n throw err;\n },\n signal\n });\n\n if (signal) {\n signal.addEventListener(\"abort\", () => {\n done = true;\n resolve?.();\n });\n }\n\n while (!done || queue.length > 0) {\n if (queue.length === 0) {\n //wait until onmessage pushes something\n await new Promise<void>(r => { resolve = r; });\n }\n while (queue.length > 0) {\n yield queue.shift()!;\n }\n }\n }}\n","export enum EventKind {\n LLM_TOKEN = \"llm_token\",\n TOOLS = \"tools\"\n}\n\n/**\n * Base event for Streaming\n * @class BaseEvent\n * @property kind - Used to separate streams\n * @property node - Source node in langgraph\n */\nexport class BaseEvent {\n /*\n * @property kind - Used to separate streams\n */\n kind!: EventKind;\n /**\n * @property node - Source node in langgraph\n */\n node!: string;\n}\n\n\n/**\n * @class LLmTokenContent\n */\nexport class LlmTokenContent {\n /**\n * @property type - Always text\n */\n type!: \"text\";\n /**\n * @property text - The text content\n */\n text!: string;\n}\n\nexport class LlmTokenEvent extends BaseEvent {\n /**\n * @property content - An array of LlmTokenContent. Always an array. Non-empty or empty. Make sure to handle all items in the array.\n */\n content!: LlmTokenContent[];\n /**\n * @property model - The LLM model used.\n */\n model!: string;\n}\n\nexport class EndEvent {\n success!: boolean;\n}\n\nexport interface ToolEvent extends BaseEvent {\n content?: ToolContent;\n name: string;\n tool_call_id?: string;\n status: ToolStatus;\n results: ToolResultContent[];\n error?: unknown;\n}\n\nexport enum ToolStatus {\n START = \"START\",\n END = \"END\",\n ERROR = \"ERROR\"\n}\n\nexport interface ToolContent {\n params: unknown;\n}\n\nexport interface ToolResultContent {\n /* type is text or json */\n type: string;\n /* can be string or object or array, ANY */\n content: any;\n}\n\n","export class HayleeAIError extends Error {\n public readonly name: string = \"HayleeAIError\";\n\n constructor(message: string) {\n super(message);\n Object.setPrototypeOf(this, HayleeAIError.prototype);\n }\n}\n","import { HayleeAIError } from \"./base\";\n\nexport class ParseError extends HayleeAIError {\n public readonly name: string = \"ParseError\";\n constructor(message: string, public details?: any){\n super(message);\n Object.setPrototypeOf(this, ParseError.prototype);\n }\n}\n","import { ParseError } from \"@/errors/parse.error\";\n\nexport function parseEvent<T>(data: string): T {\n try {\n return JSON.parse(data) as T;\n } catch {\n throw new ParseError(\"Failed to parse event data to JSON.\");\n }\n}\n","import { CreateMessageDto } from \"../types/chat.interface\";\nimport { parseEvent } from \"@/_shared/parse.helper\";\nimport { BaseEvent, EndEvent, EventKind, LlmTokenEvent, ToolEvent, ToolStatus } from \"./types\";\nimport { HayleeAIClient } from \"@/_internal/client\";\n\n/**\n * @property onLlmToken - Streams llm tokens for output\n * @property onSearchUpdate - Streams pending / done updates along with search results if status is DONE\n * @property onError - Streams errors on runtime\n * @property signal - AbortSignal for terminating the upstream stream\n */\nexport interface MessageServiceOptions {\n /**\n * Streams llm tokens for output\n * @param ev - LlmTokenEvent\n */\n onLlmToken?(ev: LlmTokenEvent): void;\n /**\n * triggers upon stream end\n * @param ev - EndEvent\n * */\n onEnd?(ev: EndEvent): void;\n /**\n * Streams tool start updates\n * @param ev - ToolEvent\n */\n onToolStart?(ev: ToolEvent): void;\n /**\n * Streams tool end updates\n * @param ev - ToolEvent\n */\n onToolEnd?(ev: ToolEvent): void;\n /**\n * Streams tool errors\n * @param ev - ToolEvent\n */\n onToolError?(ev: ToolEvent): void;\n /**\n * Streams errors on runtime\n * @param err - Error or unknown value\n */\n onError?(err: unknown): void;\n /**\n * @property signal - Abort signal to abort the stream\n */\n signal?: AbortSignal;\n}\n\nexport class MessageService {\n\n constructor(private readonly client: HayleeAIClient) {}\n\n /**\n * @param payload - The create message payload\n * @param options - Config for streaming\n */\n async stream(payload: CreateMessageDto, options?: MessageServiceOptions) {\n\n for await (const ev of this.client._stream(payload, options?.signal)) {\n if(!ev || !ev.trim()) continue;\n try {\n const event = parseEvent<BaseEvent>(ev);\n\n switch(event.kind) {\n case EventKind.LLM_TOKEN: {\n options?.onLlmToken?.(event as LlmTokenEvent);\n break;\n }\n case EventKind.TOOLS: {\n const typedEvent = event as ToolEvent;\n if(typedEvent.status == ToolStatus.START) {\n options?.onToolStart?.(typedEvent);\n } else if (typedEvent.status == ToolStatus.END) {\n options?.onToolEnd?.(typedEvent);\n } else if(typedEvent.status == ToolStatus.ERROR) {\n options?.onToolError?.(typedEvent);\n }\n break;\n }\n }\n } catch (err) {\n options?.onEnd?.({ success: false });\n //throw new ParseError(\"Failed to parse event data to JSON.\")\n console.error(\"Failed to parse event data to JSON.\", err);\n options?.onError?.(err);\n }\n }\n options?.onEnd?.({ success: true });\n }\n\n}\n","import { HayleeAIError } from \"./base\";\n\nexport class ValidationError extends HayleeAIError {\n public readonly name: string = \"ValidationError\";\n constructor(message: string, public details?: any){\n super(message);\n Object.setPrototypeOf(this, ValidationError.prototype);\n }\n}\n","import { HayleeAIError } from \"./base\";\n\nexport class NotFoundError extends HayleeAIError {\n public readonly name: string = \"NotFoundError\";\n\n constructor(message: string) {\n super(message);\n Object.setPrototypeOf(this, NotFoundError.prototype);\n }\n}\n","import { HayleeAIError } from \"./base\";\n\nexport class AuthorizationError extends HayleeAIError {\n public readonly name: string = \"AuthorizationError\";\n\n constructor(message: string) {\n super(message);\n Object.setPrototypeOf(this, AuthorizationError.prototype);\n }\n}\n\n\n","import { HayleeAIError } from \"./base\";\n\nexport class AuthenticationError extends HayleeAIError {\n public readonly name: string = \"AuthenticationError\";\n\n constructor(message: string) {\n super(message);\n Object.setPrototypeOf(this, AuthenticationError.prototype);\n }\n}\n\n","import { IsOptional, IsString } from \"class-validator\";\n\n/** \n * DTO for creating a message\n * @property message - User message\n * @property conversation_history - Array of messages\n */\nexport class CreateMessageDto {\n /* Message to send */\n @IsString()\n message!: string;\n @IsOptional()\n conversation_id?: string;\n}\n\n/*\n * @enum Role - Role of message\n */\nexport enum Role {\n HUMAN = \"human\",\n AI = \"ai\"\n}\n\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAA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HI;AAAA,MADC,iCAAS;AAAA,GAFD,iBAGT;AAEA;AAAA,MADC,mCAAW;AAAA,GAJH,iBAKT;AAMG,IAAK,OAAL,kBAAKC,UAAL;AACH,EAAAA,MAAA,WAAQ;AACR,EAAAA,MAAA,QAAK;AAFG,SAAAA;AAAA,GAAA;;;AXZZ,IAAM,WAAN,cAAuB,eAAe;AAAA,EAC3B;AAAA;AAAA;AAAA;AAAA,EAKP,YAAY,SAAmC;AAC3C,UAAM,OAAO;AACb,SAAK,WAAW,IAAI,eAAe,IAAI;AAAA,EAC3C;AACJ;","names":["EventKind","ToolStatus","Role"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -5,21 +5,12 @@
|
|
|
5
5
|
*/
|
|
6
6
|
declare class CreateMessageDto {
|
|
7
7
|
message: string;
|
|
8
|
-
|
|
8
|
+
conversation_id?: string;
|
|
9
9
|
}
|
|
10
10
|
declare enum Role {
|
|
11
11
|
HUMAN = "human",
|
|
12
12
|
AI = "ai"
|
|
13
13
|
}
|
|
14
|
-
/**
|
|
15
|
-
* History payload
|
|
16
|
-
* @property role - Role of message sender
|
|
17
|
-
* @property content - Content of message
|
|
18
|
-
*/
|
|
19
|
-
declare class IHistoryPayload {
|
|
20
|
-
role: Role;
|
|
21
|
-
content: string;
|
|
22
|
-
}
|
|
23
14
|
|
|
24
15
|
/**
|
|
25
16
|
* Options for the HayleeAI Client
|
|
@@ -204,4 +195,4 @@ declare class HayleeAI extends HayleeAIClient {
|
|
|
204
195
|
constructor(options: HayleeAIChatClientOptions);
|
|
205
196
|
}
|
|
206
197
|
|
|
207
|
-
export { AuthenticationError, AuthorizationError, BaseEvent, CreateMessageDto, EndEvent, EventKind, HayleeAI, type HayleeAIChatClientOptions, HayleeAIClient, HayleeAIError,
|
|
198
|
+
export { AuthenticationError, AuthorizationError, BaseEvent, CreateMessageDto, EndEvent, EventKind, HayleeAI, type HayleeAIChatClientOptions, HayleeAIClient, HayleeAIError, LlmTokenContent, LlmTokenEvent, MessageService, type MessageServiceOptions, NotFoundError, Role, type ToolContent, type ToolEvent, type ToolResultContent, ToolStatus, ValidationError };
|
package/dist/index.d.ts
CHANGED
|
@@ -5,21 +5,12 @@
|
|
|
5
5
|
*/
|
|
6
6
|
declare class CreateMessageDto {
|
|
7
7
|
message: string;
|
|
8
|
-
|
|
8
|
+
conversation_id?: string;
|
|
9
9
|
}
|
|
10
10
|
declare enum Role {
|
|
11
11
|
HUMAN = "human",
|
|
12
12
|
AI = "ai"
|
|
13
13
|
}
|
|
14
|
-
/**
|
|
15
|
-
* History payload
|
|
16
|
-
* @property role - Role of message sender
|
|
17
|
-
* @property content - Content of message
|
|
18
|
-
*/
|
|
19
|
-
declare class IHistoryPayload {
|
|
20
|
-
role: Role;
|
|
21
|
-
content: string;
|
|
22
|
-
}
|
|
23
14
|
|
|
24
15
|
/**
|
|
25
16
|
* Options for the HayleeAI Client
|
|
@@ -204,4 +195,4 @@ declare class HayleeAI extends HayleeAIClient {
|
|
|
204
195
|
constructor(options: HayleeAIChatClientOptions);
|
|
205
196
|
}
|
|
206
197
|
|
|
207
|
-
export { AuthenticationError, AuthorizationError, BaseEvent, CreateMessageDto, EndEvent, EventKind, HayleeAI, type HayleeAIChatClientOptions, HayleeAIClient, HayleeAIError,
|
|
198
|
+
export { AuthenticationError, AuthorizationError, BaseEvent, CreateMessageDto, EndEvent, EventKind, HayleeAI, type HayleeAIChatClientOptions, HayleeAIClient, HayleeAIError, LlmTokenContent, LlmTokenEvent, MessageService, type MessageServiceOptions, NotFoundError, Role, type ToolContent, type ToolEvent, type ToolResultContent, ToolStatus, ValidationError };
|
package/dist/index.js
CHANGED
|
@@ -226,30 +226,22 @@ var AuthenticationError = class _AuthenticationError extends HayleeAIError {
|
|
|
226
226
|
};
|
|
227
227
|
|
|
228
228
|
// src/types/chat.interface.ts
|
|
229
|
-
import {
|
|
229
|
+
import { IsOptional, IsString } from "class-validator";
|
|
230
230
|
var CreateMessageDto = class {
|
|
231
231
|
message;
|
|
232
|
-
|
|
233
|
-
conversation_history;
|
|
232
|
+
conversation_id;
|
|
234
233
|
};
|
|
235
234
|
__decorateClass([
|
|
236
235
|
IsString()
|
|
237
236
|
], CreateMessageDto.prototype, "message", 2);
|
|
237
|
+
__decorateClass([
|
|
238
|
+
IsOptional()
|
|
239
|
+
], CreateMessageDto.prototype, "conversation_id", 2);
|
|
238
240
|
var Role = /* @__PURE__ */ ((Role2) => {
|
|
239
241
|
Role2["HUMAN"] = "human";
|
|
240
242
|
Role2["AI"] = "ai";
|
|
241
243
|
return Role2;
|
|
242
244
|
})(Role || {});
|
|
243
|
-
var IHistoryPayload = class {
|
|
244
|
-
role;
|
|
245
|
-
content;
|
|
246
|
-
};
|
|
247
|
-
__decorateClass([
|
|
248
|
-
IsEnum(Role)
|
|
249
|
-
], IHistoryPayload.prototype, "role", 2);
|
|
250
|
-
__decorateClass([
|
|
251
|
-
IsString()
|
|
252
|
-
], IHistoryPayload.prototype, "content", 2);
|
|
253
245
|
|
|
254
246
|
// src/index.ts
|
|
255
247
|
var HayleeAI = class extends HayleeAIClient {
|
|
@@ -272,7 +264,6 @@ export {
|
|
|
272
264
|
HayleeAI,
|
|
273
265
|
HayleeAIClient,
|
|
274
266
|
HayleeAIError,
|
|
275
|
-
IHistoryPayload,
|
|
276
267
|
LlmTokenContent,
|
|
277
268
|
LlmTokenEvent,
|
|
278
269
|
MessageService,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/_internal/client.ts","../src/messages/types.ts","../src/errors/base.ts","../src/errors/parse.error.ts","../src/_shared/parse.helper.ts","../src/messages/message.service.ts","../src/errors/validation.error.ts","../src/errors/not-found.error.ts","../src/errors/authorization.error.ts","../src/errors/authentication.error.ts","../src/types/chat.interface.ts","../src/index.ts"],"sourcesContent":["import { CreateMessageDto } from \"@/types/chat.interface\";\nimport { fetchEventSource } from \"@microsoft/fetch-event-source\";\n\n/**\n * Options for the HayleeAI Client \n * @property apiKey - API key for authentication\n * @property baseUrl - Optional base URL, defaults to production\n */\nexport type HayleeAIChatClientOptions = {\n baseUrl?: string;\n}\n\n/**\n * Internal HayleeAI Client. Do not use unless necessary.\n * @class HayleeAIClient \n * @property baseURL - Base URL to make requests to\n */\nexport class HayleeAIClient {\n /**\n * @property baseURL - the base URL to make requests to\n */\n private baseURL: string;\n /**\n * @param options - Auth, and baseURL\n */\n constructor(options: HayleeAIChatClientOptions) {\n this.baseURL = options.baseUrl || \"http://localhost:3000/api/v1/chat\";\n }\n\n /**\n * Internal stream callout\n * @param payload - Message DTO\n * @param [signal] - Abort signal\n */\n async *_stream(payload: CreateMessageDto, signal?: AbortSignal) {\n const queue: string[] = [];\n let resolve: (() => void) | null = null;\n let done = false;\n\n fetchEventSource(`${this.baseURL}`, {\n headers: {\n 'Content-Type': 'application/json',\n },\n credentials: 'include',\n method: 'POST',\n body: JSON.stringify(payload),\n openWhenHidden: true,\n onmessage(ev) {\n queue.push(ev.data);\n resolve?.(); // wake up the generator\n },\n onclose() {\n done = true;\n resolve?.();\n },\n onerror(err) {\n done = true;\n resolve?.();\n throw err;\n },\n signal\n });\n\n if (signal) {\n signal.addEventListener(\"abort\", () => {\n done = true;\n resolve?.();\n });\n }\n\n while (!done || queue.length > 0) {\n if (queue.length === 0) {\n //wait until onmessage pushes something\n await new Promise<void>(r => { resolve = r; });\n }\n while (queue.length > 0) {\n yield queue.shift()!;\n }\n }\n }}\n","export enum EventKind {\n LLM_TOKEN = \"llm_token\",\n TOOLS = \"tools\"\n}\n\n/**\n * Base event for Streaming\n * @class BaseEvent\n * @property kind - Used to separate streams\n * @property node - Source node in langgraph\n */\nexport class BaseEvent {\n /*\n * @property kind - Used to separate streams\n */\n kind!: EventKind;\n /**\n * @property node - Source node in langgraph\n */\n node!: string;\n}\n\n\n/**\n * @class LLmTokenContent\n */\nexport class LlmTokenContent {\n /**\n * @property type - Always text\n */\n type!: \"text\";\n /**\n * @property text - The text content\n */\n text!: string;\n}\n\nexport class LlmTokenEvent extends BaseEvent {\n /**\n * @property content - An array of LlmTokenContent. Always an array. Non-empty or empty. Make sure to handle all items in the array.\n */\n content!: LlmTokenContent[];\n /**\n * @property model - The LLM model used.\n */\n model!: string;\n}\n\nexport class EndEvent {\n success!: boolean;\n}\n\nexport interface ToolEvent extends BaseEvent {\n content?: ToolContent;\n name: string;\n tool_call_id?: string;\n status: ToolStatus;\n results: ToolResultContent[];\n error?: unknown;\n}\n\nexport enum ToolStatus {\n START = \"START\",\n END = \"END\",\n ERROR = \"ERROR\"\n}\n\nexport interface ToolContent {\n params: unknown;\n}\n\nexport interface ToolResultContent {\n /* type is text or json */\n type: string;\n /* can be string or object or array, ANY */\n content: any;\n}\n\n","export class HayleeAIError extends Error {\n public readonly name: string = \"HayleeAIError\";\n\n constructor(message: string) {\n super(message);\n Object.setPrototypeOf(this, HayleeAIError.prototype);\n }\n}\n","import { HayleeAIError } from \"./base\";\n\nexport class ParseError extends HayleeAIError {\n public readonly name: string = \"ParseError\";\n constructor(message: string, public details?: any){\n super(message);\n Object.setPrototypeOf(this, ParseError.prototype);\n }\n}\n","import { ParseError } from \"@/errors/parse.error\";\n\nexport function parseEvent<T>(data: string): T {\n try {\n return JSON.parse(data) as T;\n } catch {\n throw new ParseError(\"Failed to parse event data to JSON.\");\n }\n}\n","import { CreateMessageDto } from \"../types/chat.interface\";\nimport { parseEvent } from \"@/_shared/parse.helper\";\nimport { BaseEvent, EndEvent, EventKind, LlmTokenEvent, ToolEvent, ToolStatus } from \"./types\";\nimport { HayleeAIClient } from \"@/_internal/client\";\nimport { type } from \"os\";\n\n/**\n * @property onLlmToken - Streams llm tokens for output\n * @property onSearchUpdate - Streams pending / done updates along with search results if status is DONE\n * @property onError - Streams errors on runtime\n * @property signal - AbortSignal for terminating the upstream stream\n */\nexport interface MessageServiceOptions {\n /**\n * Streams llm tokens for output\n * @param ev - LlmTokenEvent\n */\n onLlmToken?(ev: LlmTokenEvent): void;\n /**\n * triggers upon stream end\n * @param ev - EndEvent\n * */\n onEnd?(ev: EndEvent): void;\n /**\n * Streams tool start updates\n * @param ev - ToolEvent\n */\n onToolStart?(ev: ToolEvent): void;\n /**\n * Streams tool end updates\n * @param ev - ToolEvent\n */\n onToolEnd?(ev: ToolEvent): void;\n /**\n * Streams tool errors\n * @param ev - ToolEvent\n */\n onToolError?(ev: ToolEvent): void;\n /**\n * Streams errors on runtime\n * @param err - Error or unknown value\n */\n onError?(err: unknown): void;\n /**\n * @property signal - Abort signal to abort the stream\n */\n signal?: AbortSignal;\n}\n\nexport class MessageService {\n\n constructor(private readonly client: HayleeAIClient) {}\n\n /**\n * @param payload - The create message payload\n * @param options - Config for streaming\n */\n async stream(payload: CreateMessageDto, options?: MessageServiceOptions) {\n\n for await (const ev of this.client._stream(payload, options?.signal)) {\n if(!ev || !ev.trim()) continue;\n try {\n const event = parseEvent<BaseEvent>(ev);\n\n switch(event.kind) {\n case EventKind.LLM_TOKEN: {\n options?.onLlmToken?.(event as LlmTokenEvent);\n break;\n }\n case EventKind.TOOLS: {\n const typedEvent = event as ToolEvent;\n if(typedEvent.status == ToolStatus.START) {\n options?.onToolStart?.(typedEvent);\n } else if (typedEvent.status == ToolStatus.END) {\n options?.onToolEnd?.(typedEvent);\n } else if(typedEvent.status == ToolStatus.ERROR) {\n options?.onToolError?.(typedEvent);\n }\n break;\n }\n }\n } catch (err) {\n options?.onEnd?.({ success: false });\n //throw new ParseError(\"Failed to parse event data to JSON.\")\n console.error(\"Failed to parse event data to JSON.\", err);\n options?.onError?.(err);\n }\n }\n options?.onEnd?.({ success: true });\n }\n\n}\n","import { HayleeAIError } from \"./base\";\n\nexport class ValidationError extends HayleeAIError {\n public readonly name: string = \"ValidationError\";\n constructor(message: string, public details?: any){\n super(message);\n Object.setPrototypeOf(this, ValidationError.prototype);\n }\n}\n","import { HayleeAIError } from \"./base\";\n\nexport class NotFoundError extends HayleeAIError {\n public readonly name: string = \"NotFoundError\";\n\n constructor(message: string) {\n super(message);\n Object.setPrototypeOf(this, NotFoundError.prototype);\n }\n}\n","import { HayleeAIError } from \"./base\";\n\nexport class AuthorizationError extends HayleeAIError {\n public readonly name: string = \"AuthorizationError\";\n\n constructor(message: string) {\n super(message);\n Object.setPrototypeOf(this, AuthorizationError.prototype);\n }\n}\n\n\n","import { HayleeAIError } from \"./base\";\n\nexport class AuthenticationError extends HayleeAIError {\n public readonly name: string = \"AuthenticationError\";\n\n constructor(message: string) {\n super(message);\n Object.setPrototypeOf(this, AuthenticationError.prototype);\n }\n}\n\n","import { IsEnum, IsString } from \"class-validator\";\n\n/** \n * DTO for creating a message\n * @property message - User message\n * @property conversation_history - Array of messages\n */\nexport class CreateMessageDto {\n /* Message to send */\n @IsString()\n message!: string;\n /* Array of messages */\n conversation_history!: IHistoryPayload[];\n}\n\n/*\n * @enum Role - Role of message\n */\nexport enum Role {\n HUMAN = \"human\",\n AI = \"ai\"\n}\n\n\n/**\n * History payload\n * @property role - Role of message sender\n * @property content - Content of message\n */\nexport class IHistoryPayload {\n @IsEnum(Role)\n role!: Role;\n @IsString()\n content!: string;\n};\n","import { HayleeAIClient, HayleeAIChatClientOptions } from \"./_internal/client\";\nimport { MessageService } from \"./messages\";\n\n/**\n * Instantiate a new HayleeAI connection\n */\nclass HayleeAI extends HayleeAIClient {\n public messages: MessageService;\n\n /**\n * @param options - HayleeAIChatClientOptions \n */\n constructor(options: HayleeAIChatClientOptions){\n super(options);\n this.messages = new MessageService(this);\n }\n}\n\nexport {\n HayleeAI,\n HayleeAIChatClientOptions \n}\nexport * from \"./errors\";\nexport * from \"./messages\";\nexport * from \"./types/chat.interface\";\nexport * from \"./_internal/client\";\n"],"mappings":";;;;;;;;;;;;AACA,SAAS,wBAAwB;AAgB1B,IAAM,iBAAN,MAAqB;AAAA;AAAA;AAAA;AAAA,EAIhB;AAAA;AAAA;AAAA;AAAA,EAIR,YAAY,SAAoC;AAC5C,SAAK,UAAU,QAAQ,WAAW;AAAA,EACtC;AAAA;AAAA;AAAA;AAAA;AAAA;AA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AAAA,EAEA;AACJ;AAHI;AAAA,EADC,OAAO,IAAI;AAAA,GADH,gBAET;AAEA;AAAA,EADC,SAAS;AAAA,GAHD,gBAIT;;;AC3BJ,IAAM,WAAN,cAAuB,eAAe;AAAA,EAC3B;AAAA;AAAA;AAAA;AAAA,EAKP,YAAY,SAAmC;AAC3C,UAAM,OAAO;AACb,SAAK,WAAW,IAAI,eAAe,IAAI;AAAA,EAC3C;AACJ;","names":["EventKind","ToolStatus","Role"]}
|
|
1
|
+
{"version":3,"sources":["../src/_internal/client.ts","../src/messages/types.ts","../src/errors/base.ts","../src/errors/parse.error.ts","../src/_shared/parse.helper.ts","../src/messages/message.service.ts","../src/errors/validation.error.ts","../src/errors/not-found.error.ts","../src/errors/authorization.error.ts","../src/errors/authentication.error.ts","../src/types/chat.interface.ts","../src/index.ts"],"sourcesContent":["import { CreateMessageDto } from \"@/types/chat.interface\";\nimport { fetchEventSource } from \"@microsoft/fetch-event-source\";\n\n/**\n * Options for the HayleeAI Client \n * @property apiKey - API key for authentication\n * @property baseUrl - Optional base URL, defaults to production\n */\nexport type HayleeAIChatClientOptions = {\n baseUrl?: string;\n}\n\n/**\n * Internal HayleeAI Client. Do not use unless necessary.\n * @class HayleeAIClient \n * @property baseURL - Base URL to make requests to\n */\nexport class HayleeAIClient {\n /**\n * @property baseURL - the base URL to make requests to\n */\n private baseURL: string;\n /**\n * @param options - Auth, and baseURL\n */\n constructor(options: HayleeAIChatClientOptions) {\n this.baseURL = options.baseUrl || \"http://localhost:3000/api/v1/chat\";\n }\n\n /**\n * Internal stream callout\n * @param payload - Message DTO\n * @param [signal] - Abort signal\n */\n async *_stream(payload: CreateMessageDto, signal?: AbortSignal) {\n const queue: string[] = [];\n let resolve: (() => void) | null = null;\n let done = false;\n\n fetchEventSource(`${this.baseURL}`, {\n headers: {\n 'Content-Type': 'application/json',\n },\n credentials: 'include',\n method: 'POST',\n body: JSON.stringify(payload),\n openWhenHidden: true,\n onmessage(ev) {\n queue.push(ev.data);\n resolve?.(); // wake up the generator\n },\n onclose() {\n done = true;\n resolve?.();\n },\n onerror(err) {\n done = true;\n resolve?.();\n throw err;\n },\n signal\n });\n\n if (signal) {\n signal.addEventListener(\"abort\", () => {\n done = true;\n resolve?.();\n });\n }\n\n while (!done || queue.length > 0) {\n if (queue.length === 0) {\n //wait until onmessage pushes something\n await new Promise<void>(r => { resolve = r; });\n }\n while (queue.length > 0) {\n yield queue.shift()!;\n }\n }\n }}\n","export enum EventKind {\n LLM_TOKEN = \"llm_token\",\n TOOLS = \"tools\"\n}\n\n/**\n * Base event for Streaming\n * @class BaseEvent\n * @property kind - Used to separate streams\n * @property node - Source node in langgraph\n */\nexport class BaseEvent {\n /*\n * @property kind - Used to separate streams\n */\n kind!: EventKind;\n /**\n * @property node - Source node in langgraph\n */\n node!: string;\n}\n\n\n/**\n * @class LLmTokenContent\n */\nexport class LlmTokenContent {\n /**\n * @property type - Always text\n */\n type!: \"text\";\n /**\n * @property text - The text content\n */\n text!: string;\n}\n\nexport class LlmTokenEvent extends BaseEvent {\n /**\n * @property content - An array of LlmTokenContent. Always an array. Non-empty or empty. Make sure to handle all items in the array.\n */\n content!: LlmTokenContent[];\n /**\n * @property model - The LLM model used.\n */\n model!: string;\n}\n\nexport class EndEvent {\n success!: boolean;\n}\n\nexport interface ToolEvent extends BaseEvent {\n content?: ToolContent;\n name: string;\n tool_call_id?: string;\n status: ToolStatus;\n results: ToolResultContent[];\n error?: unknown;\n}\n\nexport enum ToolStatus {\n START = \"START\",\n END = \"END\",\n ERROR = \"ERROR\"\n}\n\nexport interface ToolContent {\n params: unknown;\n}\n\nexport interface ToolResultContent {\n /* type is text or json */\n type: string;\n /* can be string or object or array, ANY */\n content: any;\n}\n\n","export class HayleeAIError extends Error {\n public readonly name: string = \"HayleeAIError\";\n\n constructor(message: string) {\n super(message);\n Object.setPrototypeOf(this, HayleeAIError.prototype);\n }\n}\n","import { HayleeAIError } from \"./base\";\n\nexport class ParseError extends HayleeAIError {\n public readonly name: string = \"ParseError\";\n constructor(message: string, public details?: any){\n super(message);\n Object.setPrototypeOf(this, ParseError.prototype);\n }\n}\n","import { ParseError } from \"@/errors/parse.error\";\n\nexport function parseEvent<T>(data: string): T {\n try {\n return JSON.parse(data) as T;\n } catch {\n throw new ParseError(\"Failed to parse event data to JSON.\");\n }\n}\n","import { CreateMessageDto } from \"../types/chat.interface\";\nimport { parseEvent } from \"@/_shared/parse.helper\";\nimport { BaseEvent, EndEvent, EventKind, LlmTokenEvent, ToolEvent, ToolStatus } from \"./types\";\nimport { HayleeAIClient } from \"@/_internal/client\";\n\n/**\n * @property onLlmToken - Streams llm tokens for output\n * @property onSearchUpdate - Streams pending / done updates along with search results if status is DONE\n * @property onError - Streams errors on runtime\n * @property signal - AbortSignal for terminating the upstream stream\n */\nexport interface MessageServiceOptions {\n /**\n * Streams llm tokens for output\n * @param ev - LlmTokenEvent\n */\n onLlmToken?(ev: LlmTokenEvent): void;\n /**\n * triggers upon stream end\n * @param ev - EndEvent\n * */\n onEnd?(ev: EndEvent): void;\n /**\n * Streams tool start updates\n * @param ev - ToolEvent\n */\n onToolStart?(ev: ToolEvent): void;\n /**\n * Streams tool end updates\n * @param ev - ToolEvent\n */\n onToolEnd?(ev: ToolEvent): void;\n /**\n * Streams tool errors\n * @param ev - ToolEvent\n */\n onToolError?(ev: ToolEvent): void;\n /**\n * Streams errors on runtime\n * @param err - Error or unknown value\n */\n onError?(err: unknown): void;\n /**\n * @property signal - Abort signal to abort the stream\n */\n signal?: AbortSignal;\n}\n\nexport class MessageService {\n\n constructor(private readonly client: HayleeAIClient) {}\n\n /**\n * @param payload - The create message payload\n * @param options - Config for streaming\n */\n async stream(payload: CreateMessageDto, options?: MessageServiceOptions) {\n\n for await (const ev of this.client._stream(payload, options?.signal)) {\n if(!ev || !ev.trim()) continue;\n try {\n const event = parseEvent<BaseEvent>(ev);\n\n switch(event.kind) {\n case EventKind.LLM_TOKEN: {\n options?.onLlmToken?.(event as LlmTokenEvent);\n break;\n }\n case EventKind.TOOLS: {\n const typedEvent = event as ToolEvent;\n if(typedEvent.status == ToolStatus.START) {\n options?.onToolStart?.(typedEvent);\n } else if (typedEvent.status == ToolStatus.END) {\n options?.onToolEnd?.(typedEvent);\n } else if(typedEvent.status == ToolStatus.ERROR) {\n options?.onToolError?.(typedEvent);\n }\n break;\n }\n }\n } catch (err) {\n options?.onEnd?.({ success: false });\n //throw new ParseError(\"Failed to parse event data to JSON.\")\n console.error(\"Failed to parse event data to JSON.\", err);\n options?.onError?.(err);\n }\n }\n options?.onEnd?.({ success: true });\n }\n\n}\n","import { HayleeAIError } from \"./base\";\n\nexport class ValidationError extends HayleeAIError {\n public readonly name: string = \"ValidationError\";\n constructor(message: string, public details?: any){\n super(message);\n Object.setPrototypeOf(this, ValidationError.prototype);\n }\n}\n","import { HayleeAIError } from \"./base\";\n\nexport class NotFoundError extends HayleeAIError {\n public readonly name: string = \"NotFoundError\";\n\n constructor(message: string) {\n super(message);\n Object.setPrototypeOf(this, NotFoundError.prototype);\n }\n}\n","import { HayleeAIError } from \"./base\";\n\nexport class AuthorizationError extends HayleeAIError {\n public readonly name: string = \"AuthorizationError\";\n\n constructor(message: string) {\n super(message);\n Object.setPrototypeOf(this, AuthorizationError.prototype);\n }\n}\n\n\n","import { HayleeAIError } from \"./base\";\n\nexport class AuthenticationError extends HayleeAIError {\n public readonly name: string = \"AuthenticationError\";\n\n constructor(message: string) {\n super(message);\n Object.setPrototypeOf(this, AuthenticationError.prototype);\n }\n}\n\n","import { IsOptional, IsString } from \"class-validator\";\n\n/** \n * DTO for creating a message\n * @property message - User message\n * @property conversation_history - Array of messages\n */\nexport class CreateMessageDto {\n /* Message to send */\n @IsString()\n message!: string;\n @IsOptional()\n conversation_id?: string;\n}\n\n/*\n * @enum Role - Role of message\n */\nexport enum Role {\n HUMAN = \"human\",\n AI = \"ai\"\n}\n\n\n","import { HayleeAIClient, HayleeAIChatClientOptions } from \"./_internal/client\";\nimport { MessageService } from \"./messages\";\n\n/**\n * Instantiate a new HayleeAI connection\n */\nclass HayleeAI extends HayleeAIClient {\n public messages: MessageService;\n\n /**\n * @param options - HayleeAIChatClientOptions \n */\n constructor(options: HayleeAIChatClientOptions){\n super(options);\n this.messages = new MessageService(this);\n }\n}\n\nexport {\n HayleeAI,\n HayleeAIChatClientOptions \n}\nexport * from \"./errors\";\nexport * from \"./messages\";\nexport * from \"./types/chat.interface\";\nexport * from \"./_internal/client\";\n"],"mappings":";;;;;;;;;;;;AACA,SAAS,wBAAwB;AAgB1B,IAAM,iBAAN,MAAqB;AAAA;AAAA;AAAA;AAAA,EAIhB;AAAA;AAAA;AAAA;AAAA,EAIR,YAAY,SAAoC;AAC5C,SAAK,UAAU,QAAQ,WAAW;AAAA,EACtC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,OAAO,QAAQ,SAA2B,QAAsB;AAC5D,UAAM,QAAkB,CAAC;AACzB,QAAI,UAA+B;AACnC,QAAI,OAAO;AAEX,qBAAiB,GAAG,KAAK,OAAO,IAAI;AAAA,MAChC,SAAS;AAAA,QACL,gBAAgB;AAAA,MACpB;AAAA,MACA,aAAa;AAAA,MACb,QAAQ;AAAA,MACR,MAAM,KAAK,UAAU,OAAO;AAAA,MAC5B,gBAAgB;AAAA,MAChB,UAAU,IAAI;AACV,cAAM,KAAK,GAAG,IAAI;AAClB,kBAAU;AAAA,MACd;AAAA,MACA,UAAU;AACN,eAAO;AACP,kBAAU;AAAA,MACd;AAAA,MACA,QAAQ,KAAK;AACT,eAAO;AACP,kBAAU;AACV,cAAM;AAAA,MACV;AAAA,MACA;AAAA,IACJ,CAAC;AAED,QAAI,QAAQ;AACR,aAAO,iBAAiB,SAAS,MAAM;AACnC,eAAO;AACP,kBAAU;AAAA,MACd,CAAC;AAAA,IACL;AAEA,WAAO,CAAC,QAAQ,MAAM,SAAS,GAAG;AAC9B,UAAI,MAAM,WAAW,GAAG;AAEpB,cAAM,IAAI,QAAc,OAAK;AAAE,oBAAU;AAAA,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