@dataclouder/ngx-agent-cards 0.0.75
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 +314 -0
- package/fesm2022/dataclouder-ngx-agent-cards.mjs +2872 -0
- package/fesm2022/dataclouder-ngx-agent-cards.mjs.map +1 -0
- package/index.d.ts +5 -0
- package/lib/components/chat/dc-chat.component.d.ts +60 -0
- package/lib/components/chat-message/chat-message.component.d.ts +28 -0
- package/lib/components/chat-settings/dc-conversation-userchat-settings.component.d.ts +46 -0
- package/lib/components/dc-agent-card-details/dc-agent-card-details.component.d.ts +18 -0
- package/lib/components/dc-agent-card-lists/agent-card-default-ui/agent-card-default-ui.component.d.ts +15 -0
- package/lib/components/dc-agent-card-lists/dc-agent-card-lists.component.d.ts +42 -0
- package/lib/components/dc-agent-form/dc-agent-card-form.component.d.ts +121 -0
- package/lib/components/dc-agent-form/generic-form/generic-form.component.d.ts +23 -0
- package/lib/components/extraction.regex.d.ts +7 -0
- package/lib/components/icons/icon-map.d.ts +9 -0
- package/lib/components/icons/icons.component.d.ts +15 -0
- package/lib/components/prompt-preview-dialog/prompt-preview-dialog.component.d.ts +11 -0
- package/lib/components/provider-selector/provider-selector.component.d.ts +39 -0
- package/lib/components/translate-dialog/translate-dialog.component.d.ts +22 -0
- package/lib/models/agent.models.d.ts +192 -0
- package/lib/models/agent.utils.d.ts +1 -0
- package/lib/models/conversation-ai.class.d.ts +27 -0
- package/lib/models/conversation-enums.d.ts +47 -0
- package/lib/models/stavernUtils.d.ts +15 -0
- package/lib/models/user-data-exchange.d.ts +16 -0
- package/lib/pipes/scenario.pipe.d.ts +18 -0
- package/lib/pipes/speed.pipe.d.ts +14 -0
- package/lib/pipes/truncate.pipe.d.ts +7 -0
- package/lib/services/audio.service.d.ts +27 -0
- package/lib/services/dc-conversation-builder.service.d.ts +27 -0
- package/package.json +45 -0
- package/public-api.d.ts +15 -0
package/README.md
ADDED
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
# Description
|
|
2
|
+
|
|
3
|
+
This is an experimental and unstable Angular library for chatting with AI assistants.
|
|
4
|
+
|
|
5
|
+
Uses the concept of character Specifications but improves with this new concept called ConversationAI.
|
|
6
|
+
|
|
7
|
+
## Settings
|
|
8
|
+
|
|
9
|
+
The library depends on your own connections with LLMs, so you need to provide a service that implements the specifications.
|
|
10
|
+
|
|
11
|
+
Any model works well.
|
|
12
|
+
|
|
13
|
+
Provide this service in your `main.ts` using the function `provideChatAIService`:
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { provideChatAIService } from '@dataclouder/ngx-agent-cards';
|
|
17
|
+
|
|
18
|
+
provideChatAIService(AgentCardsService);
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Create your own service implementing the interface:
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
import { AgentCardsAbstractService } from '@dataclouder/ngx-agent-cards';
|
|
25
|
+
|
|
26
|
+
export class AgentCardsService implements AgentCardsAbstractService {
|
|
27
|
+
constructor(private httpService: HttpService, private userService: UserService) {}
|
|
28
|
+
|
|
29
|
+
public async callChatCompletion(conversation: ConversationPromptSettings): Promise<any> {
|
|
30
|
+
// Implementation here
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Dependencies
|
|
36
|
+
|
|
37
|
+
1. Angular Core
|
|
38
|
+
|
|
39
|
+
2. Angular cdk only for internal dialog, dont forget to include css
|
|
40
|
+
@import '@angular/cdk/overlay-prebuilt.css';
|
|
41
|
+
|
|
42
|
+
3. @dataclouder/storage-uploader to upload to GCP
|
|
43
|
+
|
|
44
|
+
```
|
|
45
|
+
"@angular/common": ">=18.0.0",
|
|
46
|
+
"@angular/core": ">=18.0.0",
|
|
47
|
+
"@angular/cdk": ">=18.0.0",
|
|
48
|
+
"@dataclouder/storage-uploader": ">=0.0.4"
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Implementing Abstract Service
|
|
52
|
+
|
|
53
|
+
in order to make this library compatible with your own logic you have provide a service implemeting AgentCardsAbstractService.
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
export abstract class AgentCardsAbstractService {
|
|
58
|
+
// call the llm to implement the completion
|
|
59
|
+
abstract callChatCompletion(conversation: ConversationDTO): Promise<any>;
|
|
60
|
+
// get the id of your card
|
|
61
|
+
abstract findConversationCard(id: string): Promise<IAgentCard>;
|
|
62
|
+
// get all conversation cards
|
|
63
|
+
abstract getAllConversationCards(): Promise<IAgentCard[]>;
|
|
64
|
+
|
|
65
|
+
abstract saveConversationCard(conversation: IAgentCard): Promise<IAgentCard>;
|
|
66
|
+
|
|
67
|
+
abstract deleteConversationCard(id: string): Promise<IAgentCard>;
|
|
68
|
+
|
|
69
|
+
abstract getTextAudioFile(tts: any): Promise<any>;
|
|
70
|
+
|
|
71
|
+
abstract getConversationUserSettings(): Promise<ChatUserSettings>;
|
|
72
|
+
|
|
73
|
+
abstract getConversationChatSettings(): Promise<ConversationPromptSettings>;
|
|
74
|
+
|
|
75
|
+
// strategy to save converstionUserSettings.
|
|
76
|
+
abstract saveConversationUserChatSettings(conversation: ChatUserSettings): Promise<ChatUserSettings>;
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Components
|
|
81
|
+
|
|
82
|
+

|
|
83
|
+
|
|
84
|
+
- **ConversationCardListsComponent**: Connects with backends shows availible conversations.
|
|
85
|
+
|
|
86
|
+
- **DcAgentCardDetailsComponent**: Visualize Conversation Card details and start a conversation.
|
|
87
|
+
|
|
88
|
+
- **DCChatComponent**: Start a conversation:
|
|
89
|
+
|
|
90
|
+
<div style="display: flex; align-items: flex-start; gap: 20px;">
|
|
91
|
+
<div style="flex: 1">
|
|
92
|
+
<strong> *DCAgentCardFormComponent</strong>: This component is used to manage the conversation card data.
|
|
93
|
+
</div>
|
|
94
|
+
<div style="flex: 1">
|
|
95
|
+
<img src="./docs/conversation-form.png" alt="Component Diagram">
|
|
96
|
+
</div>
|
|
97
|
+
</div>
|
|
98
|
+
|
|
99
|
+
<div style="display: flex; align-items: flex-start; gap: 20px;">
|
|
100
|
+
<div style="flex: 1">
|
|
101
|
+
<strong> *DCChatSettingsComponent</strong>: this is use to change chat settings
|
|
102
|
+
</div>
|
|
103
|
+
<div style="flex: 1">
|
|
104
|
+
<img src="./docs/chat-settings.png" alt="Component Diagram">
|
|
105
|
+
</div>
|
|
106
|
+
</div>
|
|
107
|
+
- **ChatMessageComponent**
|
|
108
|
+
|
|
109
|
+
## Changing CSS components.
|
|
110
|
+
|
|
111
|
+
There are 3 options, to custom a DC component.
|
|
112
|
+
|
|
113
|
+
1. HARD: totaly custom: need to know the libraries, import the raw components and rewrite the logic, or copy same logic just change what you need.
|
|
114
|
+
2. Pass the component you want to substitude. WIP
|
|
115
|
+
|
|
116
|
+
3. EASY: Pass the CSS.
|
|
117
|
+
|
|
118
|
+
## About conversations tecnical explanation
|
|
119
|
+
|
|
120
|
+
Character AI is evolving quickly, but there is no clear path on who is leading or proposing new standards.
|
|
121
|
+
|
|
122
|
+
For now, all implementations contain V2 of character AI.
|
|
123
|
+
|
|
124
|
+
This project contains better explanations about a Char.
|
|
125
|
+
|
|
126
|
+
https://github.com/Bronya-Rand/Prom-Spec-V3
|
|
127
|
+
|
|
128
|
+
This project goes beyond that, providing a new abstraction that can contain one or multiple characters and more conditions for the characters' interactions.
|
|
129
|
+
|
|
130
|
+
I call this:
|
|
131
|
+
|
|
132
|
+
Conversation AI V1
|
|
133
|
+
|
|
134
|
+
Here are the specs for V1:
|
|
135
|
+
|
|
136
|
+
This first version can only have one character. I need to understand a little bit more to create conversations with multiple characters, which I'll include in the second version.
|
|
137
|
+
|
|
138
|
+
```typescript
|
|
139
|
+
export interface IAgentCard {
|
|
140
|
+
version: string;
|
|
141
|
+
id: string;
|
|
142
|
+
title: string;
|
|
143
|
+
|
|
144
|
+
characterCard: CharaCard;
|
|
145
|
+
|
|
146
|
+
textEngine: TextEngines;
|
|
147
|
+
conversationType: ScenarioType;
|
|
148
|
+
lang: string;
|
|
149
|
+
|
|
150
|
+
tts: {
|
|
151
|
+
voice: string;
|
|
152
|
+
secondaryVoice: string;
|
|
153
|
+
speed: string;
|
|
154
|
+
speedRate: number;
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
metaApp: {
|
|
158
|
+
isPublished: boolean;
|
|
159
|
+
isPublic: any;
|
|
160
|
+
authorId: string;
|
|
161
|
+
authorEmail: string;
|
|
162
|
+
createdAt: Date;
|
|
163
|
+
updatedAt: Date;
|
|
164
|
+
takenCount: number;
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
`characterCard`: The card you want to use to talk.
|
|
170
|
+
|
|
171
|
+
`textEngine`: In order to read text, there are multiple formats in markdown. Depending on your format, the engine needs to read and highlight in different ways. Also, the app itself can create its own engine to add more functionalities.
|
|
172
|
+
|
|
173
|
+
`conversationType`: This can be general purpose just to tag it, or the app can modify the conversation depending on the type.
|
|
174
|
+
|
|
175
|
+
`lang`: The main language where the app is intended to operate.
|
|
176
|
+
|
|
177
|
+
`tts`: Extra functionalities to add TTS. I need to think more on this. In the future, voices will probably be free or downloadable. For now, it is only the ID of the voice. There are only two voices in the first approach.
|
|
178
|
+
|
|
179
|
+
`metaApp`: Everything your app needs to work. Audit data, how many times your app has been used, if the conversation is a challenge type, you can count how many passed or failed, etc.
|
|
180
|
+
|
|
181
|
+
### How works
|
|
182
|
+
|
|
183
|
+
multiple systems need to use chats, and add functionalities for chatting.
|
|
184
|
+
|
|
185
|
+
This functionality is usually the same.
|
|
186
|
+
|
|
187
|
+
Conversation Types
|
|
188
|
+
|
|
189
|
+
- General
|
|
190
|
+
- Reflextion:
|
|
191
|
+
- Role Play
|
|
192
|
+
- Role Play With Narrador
|
|
193
|
+
- Challenge
|
|
194
|
+
|
|
195
|
+
### How User and Chat Settings works.
|
|
196
|
+
|
|
197
|
+
This is one of the biggest problems, app need to handle this an provide a service that is able to retrive this settings.
|
|
198
|
+
|
|
199
|
+
There are multiple ways to use the chat, and there are
|
|
200
|
+
functionalities availible, Users can save this functions and thats why you need the object ChatUserSettings,
|
|
201
|
+
Chat are settings that does not depend on the user but in the application.
|
|
202
|
+
|
|
203
|
+
Check the object.
|
|
204
|
+
|
|
205
|
+
#### ChatUserSettings
|
|
206
|
+
|
|
207
|
+
Conversation Chat User Settings.
|
|
208
|
+
This is an implementation app can handle, it can be locally settings by defult saving on browers or DB.
|
|
209
|
+
basically user have the object ChatUserSettings
|
|
210
|
+
|
|
211
|
+
```typescript
|
|
212
|
+
export class ChatUserSettings {
|
|
213
|
+
realTime: boolean;
|
|
214
|
+
repeatRecording: boolean;
|
|
215
|
+
fixGrammar: boolean;
|
|
216
|
+
superHearing: boolean;
|
|
217
|
+
voice: string;
|
|
218
|
+
autoTranslate: boolean;
|
|
219
|
+
highlightWords: boolean;
|
|
220
|
+
synthVoice: boolean;
|
|
221
|
+
modelName: string;
|
|
222
|
+
provider: string;
|
|
223
|
+
speed: string;
|
|
224
|
+
speedRate: number; // temporal
|
|
225
|
+
}
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
#### ConversationPromptSettings
|
|
229
|
+
|
|
230
|
+
```typescript
|
|
231
|
+
export class ConversationPromptSettings {
|
|
232
|
+
messages?: ChatMessage[];
|
|
233
|
+
last_prompt?: string;
|
|
234
|
+
conversationType?: ConversationType;
|
|
235
|
+
textEngine?: string;
|
|
236
|
+
voice?: string; // first voice
|
|
237
|
+
secondaryVoice?: string; // apply for narrator
|
|
238
|
+
overrideConversationSettings?: Partial<ChatUserSettings>;
|
|
239
|
+
}
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
Those are object to need to think how to store, create and pass to the chat.
|
|
243
|
+
|
|
244
|
+
### How to parse conversation instructions.
|
|
245
|
+
|
|
246
|
+
In order to adapt the conversartion to the current user, Character Cards use some wild words that are parsed before conversation start, so LLM is aware of name age and other data to make a custum conversation.
|
|
247
|
+
|
|
248
|
+
this Wilds are
|
|
249
|
+
|
|
250
|
+
{{user}}:
|
|
251
|
+
{{}}:
|
|
252
|
+
|
|
253
|
+
Polilan add more wilds for the same porpuse that helps to add context.
|
|
254
|
+
|
|
255
|
+
{{word}}: is the words the user is studing
|
|
256
|
+
{{targe}}: is the language the user wants to learn
|
|
257
|
+
{{base}}: is the user native language
|
|
258
|
+
|
|
259
|
+
TODO: this same logic can apply for every diferent app, think on how to abstract and create standard for this.
|
|
260
|
+
|
|
261
|
+
##### Build messages to start a conversation
|
|
262
|
+
|
|
263
|
+
- conversation need attached all the data from the character card.
|
|
264
|
+
- this is my format.
|
|
265
|
+
|
|
266
|
+

|
|
267
|
+
|
|
268
|
+
### Componentes in details
|
|
269
|
+
|
|
270
|
+
1. **DCDCAgentCardFormComponent**
|
|
271
|
+
|
|
272
|
+
#### Inputs:
|
|
273
|
+
|
|
274
|
+
**conversationCardId**: string; is the id for the conversation to modify will look up for this in api otherwise is empty card. if is not passed will look for the id in the URL.
|
|
275
|
+
|
|
276
|
+
**storageSettings**: StorageSettings: you can override the default setting for cropping:
|
|
277
|
+
{ cropImageSettings: { path: '', fileName: '', resizeToWidth: 450 }, ratioType: AspectType.Vertical_9_16, resolutions: [ResolutionType.MediumLarge], };
|
|
278
|
+
|
|
279
|
+
#### Outputs
|
|
280
|
+
|
|
281
|
+
onImageLoaded: when the image is loaded in the storage.
|
|
282
|
+
|
|
283
|
+
onSave: when user click save
|
|
284
|
+
|
|
285
|
+
2. **ChatComponent**
|
|
286
|
+
|
|
287
|
+
### Inputs
|
|
288
|
+
|
|
289
|
+
**chatUserSettings** : if you want to hardcode the settings, otherwise will use the provided AgentCardsAbstractService
|
|
290
|
+
|
|
291
|
+
**conversationCardId**:
|
|
292
|
+
|
|
293
|
+
### Outputs
|
|
294
|
+
|
|
295
|
+
### How to add TTS.
|
|
296
|
+
|
|
297
|
+
There are multiple services that impruve Speaking App Capabilities, i think in future backend will handle all of them and front will only send the settings.
|
|
298
|
+
|
|
299
|
+
For now backend need to implement a service. tts.
|
|
300
|
+
|
|
301
|
+
### How to build and publish new version of this library
|
|
302
|
+
|
|
303
|
+
the component need the cropper as dependency, make sure you already installed or compile that library.
|
|
304
|
+
inside the angular
|
|
305
|
+
is required to build first the dependencies locally
|
|
306
|
+
|
|
307
|
+
npm run build:storage-uploader
|
|
308
|
+
npm run build:core-components
|
|
309
|
+
npm run publish:conversations
|
|
310
|
+
|
|
311
|
+
after that i recommend to remove /dist folder, why ? becouse project path is linked to dist folder first if exits, and the to the source code. so in order to code easier i recommend to remove the dist folder.
|
|
312
|
+
|
|
313
|
+
- npm run build
|
|
314
|
+
- npm run publish
|