@dataclouder/ngx-agent-cards 0.1.55 → 0.1.56
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.
|
@@ -10,6 +10,8 @@ import { TtsService, NgxVertexService, GeneratedAssetsService, VoiceSelectorComp
|
|
|
10
10
|
import { DynamicDialogRef, DynamicDialogConfig, DialogService, DynamicDialogModule } from 'primeng/dynamicdialog';
|
|
11
11
|
import * as i2 from 'primeng/button';
|
|
12
12
|
import { ButtonModule } from 'primeng/button';
|
|
13
|
+
import * as Plyr from 'plyr';
|
|
14
|
+
import { Subject, fromEvent, filter } from 'rxjs';
|
|
13
15
|
import * as i2$3 from 'primeng/progressbar';
|
|
14
16
|
import { ProgressBarModule } from 'primeng/progressbar';
|
|
15
17
|
import * as i1$1 from 'primeng/table';
|
|
@@ -21,7 +23,6 @@ import { DCMicComponent, MicVadComponent } from '@dataclouder/ngx-mic';
|
|
|
21
23
|
import * as i3 from 'primeng/textarea';
|
|
22
24
|
import { TextareaModule } from 'primeng/textarea';
|
|
23
25
|
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
24
|
-
import { fromEvent, filter } from 'rxjs';
|
|
25
26
|
import { map } from 'rxjs/operators';
|
|
26
27
|
import { DomSanitizer } from '@angular/platform-browser';
|
|
27
28
|
import * as i2$4 from 'primeng/popover';
|
|
@@ -1826,6 +1827,8 @@ class ChatMonitorService {
|
|
|
1826
1827
|
this.messageAudioWillPlay$ = this.messageAudioWillPlay.asReadonly();
|
|
1827
1828
|
this.currentMood = signal(null, ...(ngDevMode ? [{ debugName: "currentMood" }] : []));
|
|
1828
1829
|
this.isConversationActive = signal(false, ...(ngDevMode ? [{ debugName: "isConversationActive" }] : []));
|
|
1830
|
+
// Background
|
|
1831
|
+
this.backgroundUrl = signal(undefined, ...(ngDevMode ? [{ debugName: "backgroundUrl" }] : []));
|
|
1829
1832
|
console.log(`%c ChatMonitorService instantiated: ${Math.random()}`, 'color: #00ff00; font-weight: bold; padding: 2px 4px; border: 1px solid #00ff00;');
|
|
1830
1833
|
}
|
|
1831
1834
|
logMessageAudioWillPlay(message) {
|
|
@@ -1840,6 +1843,14 @@ class ChatMonitorService {
|
|
|
1840
1843
|
this.messageAudioWillPlay.set(null);
|
|
1841
1844
|
this.isConversationActive.set(false);
|
|
1842
1845
|
}
|
|
1846
|
+
setBackground(imageUrl) {
|
|
1847
|
+
if (imageUrl) {
|
|
1848
|
+
this.backgroundUrl.set(imageUrl);
|
|
1849
|
+
}
|
|
1850
|
+
else {
|
|
1851
|
+
this.backgroundUrl.set(undefined);
|
|
1852
|
+
}
|
|
1853
|
+
}
|
|
1843
1854
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.6", ngImport: i0, type: ChatMonitorService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1844
1855
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.6", ngImport: i0, type: ChatMonitorService, providedIn: 'root' }); }
|
|
1845
1856
|
}
|
|
@@ -2915,6 +2926,137 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.6", ngImpor
|
|
|
2915
2926
|
const VIDEO_PLAYER_SERVICE_TOKEN = new InjectionToken('VIDEO_PLAYER_SERVICE_TOKEN');
|
|
2916
2927
|
const BACKGROUND_SERVICE_TOKEN = new InjectionToken('BACKGROUND_SERVICE_TOKEN');
|
|
2917
2928
|
|
|
2929
|
+
class VideoPlayerService {
|
|
2930
|
+
constructor() {
|
|
2931
|
+
this.isRewinding = false;
|
|
2932
|
+
this.videoQueue = [];
|
|
2933
|
+
this.defaultVideoUrl = null;
|
|
2934
|
+
this.playAndRewindedSource = new Subject();
|
|
2935
|
+
this.playAndRewinded$ = this.playAndRewindedSource.asObservable();
|
|
2936
|
+
this.playAndRewindedSubscription = this.playAndRewinded$.subscribe(() => {
|
|
2937
|
+
this.playNextInQueue();
|
|
2938
|
+
});
|
|
2939
|
+
}
|
|
2940
|
+
initializePlayer(videoPlayer) {
|
|
2941
|
+
this.player = new Plyr.default(videoPlayer.nativeElement, {
|
|
2942
|
+
controls: [],
|
|
2943
|
+
});
|
|
2944
|
+
this.player.on('ready', (event) => {
|
|
2945
|
+
const instance = event.detail.plyr;
|
|
2946
|
+
console.log('El video esta redyinstance', instance);
|
|
2947
|
+
});
|
|
2948
|
+
}
|
|
2949
|
+
setVideoSource(videoUrl) {
|
|
2950
|
+
if (this.player) {
|
|
2951
|
+
this.player.source = {
|
|
2952
|
+
type: 'video',
|
|
2953
|
+
sources: [
|
|
2954
|
+
{
|
|
2955
|
+
src: videoUrl,
|
|
2956
|
+
type: 'video/mp4',
|
|
2957
|
+
},
|
|
2958
|
+
],
|
|
2959
|
+
};
|
|
2960
|
+
}
|
|
2961
|
+
}
|
|
2962
|
+
startConversation(defaultVideo) {
|
|
2963
|
+
if (defaultVideo) {
|
|
2964
|
+
this.defaultVideoUrl = defaultVideo;
|
|
2965
|
+
// this.setVideoSource(defaultVideo);
|
|
2966
|
+
}
|
|
2967
|
+
}
|
|
2968
|
+
playVideo() {
|
|
2969
|
+
if (this.player) {
|
|
2970
|
+
this.player.play();
|
|
2971
|
+
}
|
|
2972
|
+
}
|
|
2973
|
+
rewindVideo() {
|
|
2974
|
+
if (this.player) {
|
|
2975
|
+
if (this.isRewinding) {
|
|
2976
|
+
this.isRewinding = false;
|
|
2977
|
+
clearInterval(this.rewindInterval);
|
|
2978
|
+
this.rewindInterval = null;
|
|
2979
|
+
this.player.play();
|
|
2980
|
+
}
|
|
2981
|
+
else {
|
|
2982
|
+
this.isRewinding = true;
|
|
2983
|
+
this.player.pause();
|
|
2984
|
+
this.rewindInterval = setInterval(() => {
|
|
2985
|
+
if (this.player.currentTime > 0) {
|
|
2986
|
+
this.player.rewind(0.1);
|
|
2987
|
+
}
|
|
2988
|
+
else {
|
|
2989
|
+
this.player.currentTime = 0;
|
|
2990
|
+
this.isRewinding = false;
|
|
2991
|
+
clearInterval(this.rewindInterval);
|
|
2992
|
+
this.rewindInterval = null;
|
|
2993
|
+
this.playAndRewindedSource.next();
|
|
2994
|
+
}
|
|
2995
|
+
}, 100);
|
|
2996
|
+
}
|
|
2997
|
+
}
|
|
2998
|
+
}
|
|
2999
|
+
changeVideoSource(videoUrl) {
|
|
3000
|
+
if (this.player) {
|
|
3001
|
+
this.setVideoSource(videoUrl);
|
|
3002
|
+
}
|
|
3003
|
+
}
|
|
3004
|
+
addVideosToQueue(videoUrls) {
|
|
3005
|
+
this.videoQueue.push(...videoUrls);
|
|
3006
|
+
}
|
|
3007
|
+
destroyPlayer() {
|
|
3008
|
+
if (this.player) {
|
|
3009
|
+
this.player.destroy();
|
|
3010
|
+
}
|
|
3011
|
+
}
|
|
3012
|
+
playAndRewind() {
|
|
3013
|
+
if (this.player && !this.player.playing) {
|
|
3014
|
+
this.playNextInQueue();
|
|
3015
|
+
}
|
|
3016
|
+
}
|
|
3017
|
+
cleanUp() {
|
|
3018
|
+
this.destroyPlayer();
|
|
3019
|
+
if (this.rewindInterval) {
|
|
3020
|
+
clearInterval(this.rewindInterval);
|
|
3021
|
+
}
|
|
3022
|
+
this.isRewinding = false;
|
|
3023
|
+
this.videoQueue = [];
|
|
3024
|
+
this.defaultVideoUrl = null;
|
|
3025
|
+
}
|
|
3026
|
+
ngOnDestroy() {
|
|
3027
|
+
if (this.playAndRewindedSubscription) {
|
|
3028
|
+
this.playAndRewindedSubscription.unsubscribe();
|
|
3029
|
+
}
|
|
3030
|
+
}
|
|
3031
|
+
playNextInQueue() {
|
|
3032
|
+
if (this.videoQueue.length > 0) {
|
|
3033
|
+
const videoUrl = this.videoQueue.shift();
|
|
3034
|
+
if (videoUrl) {
|
|
3035
|
+
this.changeVideoSource(videoUrl);
|
|
3036
|
+
this.player.play();
|
|
3037
|
+
this.player.once('ended', () => {
|
|
3038
|
+
this.rewindVideo();
|
|
3039
|
+
});
|
|
3040
|
+
}
|
|
3041
|
+
}
|
|
3042
|
+
else if (this.defaultVideoUrl) {
|
|
3043
|
+
this.changeVideoSource(this.defaultVideoUrl);
|
|
3044
|
+
this.player.play();
|
|
3045
|
+
this.player.once('ended', () => {
|
|
3046
|
+
this.rewindVideo();
|
|
3047
|
+
});
|
|
3048
|
+
}
|
|
3049
|
+
}
|
|
3050
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.6", ngImport: i0, type: VideoPlayerService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
3051
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.6", ngImport: i0, type: VideoPlayerService, providedIn: 'root' }); }
|
|
3052
|
+
}
|
|
3053
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.6", ngImport: i0, type: VideoPlayerService, decorators: [{
|
|
3054
|
+
type: Injectable,
|
|
3055
|
+
args: [{
|
|
3056
|
+
providedIn: 'root',
|
|
3057
|
+
}]
|
|
3058
|
+
}], ctorParameters: () => [] });
|
|
3059
|
+
|
|
2918
3060
|
class CostDetailsComponent {
|
|
2919
3061
|
constructor() {
|
|
2920
3062
|
this.conversationCostService = inject(ConversationCostService);
|
|
@@ -6394,8 +6536,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.6", ngImpor
|
|
|
6394
6536
|
}]
|
|
6395
6537
|
}] });
|
|
6396
6538
|
|
|
6397
|
-
// I used to import like this, but was outside the library.
|
|
6398
|
-
// import { VideoPlayerService } from 'src/app/services/video-player/video-player.service';
|
|
6399
6539
|
class DcAgentCardDetailsComponent {
|
|
6400
6540
|
constructor() {
|
|
6401
6541
|
this.agentCardService = inject(CONVERSATION_AI_TOKEN);
|
|
@@ -6403,8 +6543,7 @@ class DcAgentCardDetailsComponent {
|
|
|
6403
6543
|
this.toastService = inject(TOAST_ALERTS_TOKEN);
|
|
6404
6544
|
this.chatMonitorService = inject(ChatMonitorService);
|
|
6405
6545
|
this.userService = inject(UserService);
|
|
6406
|
-
this.videoPlayerService = inject(
|
|
6407
|
-
this.backgroundService = inject(BACKGROUND_SERVICE_TOKEN);
|
|
6546
|
+
this.videoPlayerService = inject(VideoPlayerService);
|
|
6408
6547
|
this.agentCardId = '';
|
|
6409
6548
|
this.onStartConversation = output();
|
|
6410
6549
|
this.agentCard = signal(undefined, ...(ngDevMode ? [{ debugName: "agentCard" }] : []));
|
|
@@ -6431,7 +6570,7 @@ class DcAgentCardDetailsComponent {
|
|
|
6431
6570
|
}
|
|
6432
6571
|
ngOnDestroy() {
|
|
6433
6572
|
this.videoPlayerService.cleanUp();
|
|
6434
|
-
this.
|
|
6573
|
+
this.chatMonitorService.setBackground(undefined);
|
|
6435
6574
|
}
|
|
6436
6575
|
ngAfterViewInit() {
|
|
6437
6576
|
if (this.videoPlayer) {
|
|
@@ -6460,7 +6599,7 @@ class DcAgentCardDetailsComponent {
|
|
|
6460
6599
|
this.videoPlayerService.setVideoSource(card.assets.motion.url);
|
|
6461
6600
|
}
|
|
6462
6601
|
if (card.assets.banner?.url) {
|
|
6463
|
-
this.
|
|
6602
|
+
this.chatMonitorService.setBackground(card.assets.banner.url);
|
|
6464
6603
|
}
|
|
6465
6604
|
}
|
|
6466
6605
|
transformToLanguage(agentCard, targetLang) {
|
|
@@ -6468,7 +6607,9 @@ class DcAgentCardDetailsComponent {
|
|
|
6468
6607
|
const cardTranslated = { ...agentCard };
|
|
6469
6608
|
// Set Greetings Communication and Language.
|
|
6470
6609
|
cardTranslated.characterCard.data.greetings = translation?.greetings;
|
|
6471
|
-
cardTranslated.characterCard.data
|
|
6610
|
+
if (cardTranslated.characterCard.data?.persona?.communication) {
|
|
6611
|
+
cardTranslated.characterCard.data.persona.communication = translation?.communication;
|
|
6612
|
+
}
|
|
6472
6613
|
cardTranslated.lang = targetLang;
|
|
6473
6614
|
console.log('cambiando idioma', agentCard.lang);
|
|
6474
6615
|
const locale = LANGUAGES[targetLang].defaultLocale;
|
|
@@ -6689,5 +6830,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.6", ngImpor
|
|
|
6689
6830
|
* Generated bundle index. Do not edit.
|
|
6690
6831
|
*/
|
|
6691
6832
|
|
|
6692
|
-
export { ACCDataGenerationComponent, AGENT_CARDS_STATE_SERVICE, AIGenerationService, AgentCardListComponent, AgentCardUI, AgentCardsGenerationService, AudioService, AudioSpeed, BACKGROUND_SERVICE_TOKEN, CONVERSATION_AI_TOKEN, CardsCreatorComponent, ChatEventType, ChatMessage, ChatMessageOrchestratorComponent, ChatMonitorService, ChatRole, ConditionOperator, ConditionType, ContextEngineService, ContextType, ConversationDTO, ConversationEvents, ConversationMessagesDTO, ConversationPromptBuilderService, ConversationType, ConversationTypeOptions, DCAgentCardFormComponent, DCChatComponent, DCConversationUserChatSettingsComponent, DcAgentCardDetailsComponent, DefaultAgentCardsService, DoActionTypeOptions, DynamicFlowService, DynamicFlowTaskTypeOptions, EAccountsPlatform, EAgentType, EDoActionType, EDynamicFlowTaskType, EntityThen, EntityWhatOptions, EntityWhenOptions, EvalResultStringDefinition, GlobalToolsService, MessageContent, MessageContentDisplayer, MessagesStateService, ModelSelectorComponent, PopupService, SystemPromptType, TextEngineOptions, TextEngines, VIDEO_PLAYER_SERVICE_TOKEN, VoiceTTSOption, VoiceTTSOptions, WordTimestamps, buildObjectTTSRequest, characterCardStringDataDefinition, convertToHTML, createAIModelFormGroup, defaultconvUserSettings, extractAudioAndTranscription, extractJsonFromResponse, getMoodStateLabelsAsString, getMoodStatePrompt, markdownToHtml, matchTranscription, provideAgentCardService, removeEmojis, removeEmojisAndSpecialCharacters, removeSpecialCharacters };
|
|
6833
|
+
export { ACCDataGenerationComponent, AGENT_CARDS_STATE_SERVICE, AIGenerationService, AgentCardListComponent, AgentCardUI, AgentCardsGenerationService, AudioService, AudioSpeed, BACKGROUND_SERVICE_TOKEN, CONVERSATION_AI_TOKEN, CardsCreatorComponent, ChatEventType, ChatMessage, ChatMessageOrchestratorComponent, ChatMonitorService, ChatRole, ConditionOperator, ConditionType, ContextEngineService, ContextType, ConversationDTO, ConversationEvents, ConversationMessagesDTO, ConversationPromptBuilderService, ConversationType, ConversationTypeOptions, DCAgentCardFormComponent, DCChatComponent, DCConversationUserChatSettingsComponent, DcAgentCardDetailsComponent, DefaultAgentCardsService, DoActionTypeOptions, DynamicFlowService, DynamicFlowTaskTypeOptions, EAccountsPlatform, EAgentType, EDoActionType, EDynamicFlowTaskType, EntityThen, EntityWhatOptions, EntityWhenOptions, EvalResultStringDefinition, GlobalToolsService, MessageContent, MessageContentDisplayer, MessagesStateService, ModelSelectorComponent, PopupService, SystemPromptType, TextEngineOptions, TextEngines, VIDEO_PLAYER_SERVICE_TOKEN, VideoPlayerService, VoiceTTSOption, VoiceTTSOptions, WordTimestamps, buildObjectTTSRequest, characterCardStringDataDefinition, convertToHTML, createAIModelFormGroup, defaultconvUserSettings, extractAudioAndTranscription, extractJsonFromResponse, getMoodStateLabelsAsString, getMoodStatePrompt, markdownToHtml, matchTranscription, provideAgentCardService, removeEmojis, removeEmojisAndSpecialCharacters, removeSpecialCharacters };
|
|
6693
6834
|
//# sourceMappingURL=dataclouder-ngx-agent-cards.mjs.map
|