@futdevpro/nts-dynamo 1.14.27 → 1.14.29
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/build/_modules/ai/_modules/open-ai/_enums/oai-gpt-message-role.enum.d.ts +0 -17
- package/build/_modules/ai/_modules/open-ai/_enums/oai-gpt-message-role.enum.d.ts.map +1 -1
- package/build/_modules/ai/_modules/open-ai/_enums/oai-gpt-message-role.enum.js +42 -39
- package/build/_modules/ai/_modules/open-ai/_enums/oai-gpt-message-role.enum.js.map +1 -1
- package/build/_modules/ai/_modules/open-ai/_models/interfaces/oai-gpt-message.interface.d.ts +0 -5
- package/build/_modules/ai/_modules/open-ai/_models/interfaces/oai-gpt-message.interface.d.ts.map +1 -1
- package/build/_modules/ai/_modules/open-ai/_models/interfaces/oai-gpt-message.interface.js +6 -2
- package/build/_modules/ai/_modules/open-ai/_models/interfaces/oai-gpt-message.interface.js.map +1 -1
- package/build/_modules/ai/_modules/open-ai/_services/data-services/oai-doc-chunk-data.service.d.ts +22 -0
- package/build/_modules/ai/_modules/open-ai/_services/data-services/oai-doc-chunk-data.service.d.ts.map +1 -0
- package/build/_modules/ai/_modules/open-ai/_services/data-services/oai-doc-chunk-data.service.js +187 -0
- package/build/_modules/ai/_modules/open-ai/_services/data-services/oai-doc-chunk-data.service.js.map +1 -0
- package/build/_modules/ai/_modules/open-ai/_services/data-services/oai-doc-page.data-service.d.ts +27 -0
- package/build/_modules/ai/_modules/open-ai/_services/data-services/oai-doc-page.data-service.d.ts.map +1 -0
- package/build/_modules/ai/_modules/open-ai/_services/data-services/oai-doc-page.data-service.js +277 -0
- package/build/_modules/ai/_modules/open-ai/_services/data-services/oai-doc-page.data-service.js.map +1 -0
- package/build/_modules/ai/_modules/open-ai/_services/data-services/oai-document.data-service.d.ts +23 -0
- package/build/_modules/ai/_modules/open-ai/_services/data-services/oai-document.data-service.d.ts.map +1 -0
- package/build/_modules/ai/_modules/open-ai/_services/data-services/oai-document.data-service.js +319 -0
- package/build/_modules/ai/_modules/open-ai/_services/data-services/oai-document.data-service.js.map +1 -0
- package/build/_modules/ai/_modules/open-ai/_services/data-services/oai-vector-data.service.d.ts +118 -0
- package/build/_modules/ai/_modules/open-ai/_services/data-services/oai-vector-data.service.d.ts.map +1 -0
- package/build/_modules/ai/_modules/open-ai/_services/data-services/oai-vector-data.service.js +460 -0
- package/build/_modules/ai/_modules/open-ai/_services/data-services/oai-vector-data.service.js.map +1 -0
- package/build/_modules/ai/_modules/open-ai/_services/oai-embedding.control-service.d.ts +9 -1
- package/build/_modules/ai/_modules/open-ai/_services/oai-embedding.control-service.d.ts.map +1 -1
- package/build/_modules/ai/_modules/open-ai/_services/oai-embedding.control-service.js +14 -1
- package/build/_modules/ai/_modules/open-ai/_services/oai-embedding.control-service.js.map +1 -1
- package/build/_modules/ai/_modules/open-ai/_services/oai-llm-chat.service-base.d.ts +73 -130
- package/build/_modules/ai/_modules/open-ai/_services/oai-llm-chat.service-base.d.ts.map +1 -1
- package/build/_modules/ai/_modules/open-ai/_services/oai-llm-chat.service-base.js +97 -12
- package/build/_modules/ai/_modules/open-ai/_services/oai-llm-chat.service-base.js.map +1 -1
- package/build/_modules/ai/_modules/open-ai/_services/oai-llm.service-base.d.ts +65 -7
- package/build/_modules/ai/_modules/open-ai/_services/oai-llm.service-base.d.ts.map +1 -1
- package/build/_modules/ai/_modules/open-ai/_services/oai-llm.service-base.js +192 -6
- package/build/_modules/ai/_modules/open-ai/_services/oai-llm.service-base.js.map +1 -1
- package/build/_modules/ai/_modules/open-ai/index.d.ts +4 -6
- package/build/_modules/ai/_modules/open-ai/index.d.ts.map +1 -1
- package/build/_modules/ai/_modules/open-ai/index.js +8 -7
- package/build/_modules/ai/_modules/open-ai/index.js.map +1 -1
- package/build/_modules/bot/_enums/bot-message-provider.enum.d.ts +1 -1
- package/build/_modules/bot/_enums/bot-message-provider.enum.d.ts.map +1 -1
- package/build/_modules/bot/_enums/bot-message-provider.enum.js +9 -9
- package/build/_modules/bot/_enums/bot-message-provider.enum.js.map +1 -1
- package/build/_modules/bot/_models/bot-message-wrapper.interface.d.ts +2 -2
- package/build/_modules/bot/_models/bot-message-wrapper.interface.d.ts.map +1 -1
- package/build/_modules/bot/_models/bot-messaging-provider.interface.d.ts +2 -2
- package/build/_modules/bot/_models/bot-messaging-provider.interface.d.ts.map +1 -1
- package/build/_modules/bot/_modules/discord-bot/_services/dib-messaging-provider.service.js +1 -1
- package/build/_modules/bot/_modules/discord-bot/_services/dib-messaging-provider.service.js.map +1 -1
- package/build/_modules/bot/_modules/dynamo-bot/_services/dyb-messaging-provider.service.js +1 -1
- package/build/_modules/bot/_modules/dynamo-bot/_services/dyb-messaging-provider.service.js.map +1 -1
- package/build/_modules/bot/_modules/slack-bot/_services/slb-messaging-provider.service.js +1 -1
- package/build/_modules/bot/_modules/slack-bot/_services/slb-messaging-provider.service.js.map +1 -1
- package/build/_modules/bot/_modules/teams-bot/_services/teb-messaging-provider.service.js +1 -1
- package/build/_modules/bot/_modules/teams-bot/_services/teb-messaging-provider.service.js.map +1 -1
- package/build/_modules/bot/_services/bot-messaging-provider-factory.service.js +5 -5
- package/build/_modules/bot/_services/bot-messaging-provider-factory.service.js.map +1 -1
- package/build/_modules/discord-assistant/_collections/dias.util.d.ts +3 -3
- package/build/_modules/discord-assistant/_collections/dias.util.d.ts.map +1 -1
- package/build/_modules/discord-assistant/_collections/dias.util.js +4 -4
- package/build/_modules/discord-assistant/_collections/dias.util.js.map +1 -1
- package/build/_modules/discord-assistant/_services/dias-chunk.data-service.d.ts +5 -5
- package/build/_modules/discord-assistant/_services/dias-chunk.data-service.d.ts.map +1 -1
- package/build/_modules/discord-assistant/_services/dias-chunk.data-service.js +1 -1
- package/build/_modules/discord-assistant/_services/dias-chunk.data-service.js.map +1 -1
- package/build/_modules/discord-assistant/_services/dias.service-base.d.ts +2 -2
- package/build/_modules/discord-assistant/_services/dias.service-base.d.ts.map +1 -1
- package/build/_modules/discord-assistant/_services/dias.service-base.js.map +1 -1
- package/package.json +1 -1
- package/src/_modules/ai/_modules/open-ai/_enums/oai-gpt-message-role.enum.ts +42 -42
- package/src/_modules/ai/_modules/open-ai/_models/interfaces/oai-gpt-message.interface.ts +6 -6
- package/src/_modules/ai/_modules/open-ai/_services/{oai-doc-chunk-data.service.ts → data-services/oai-doc-chunk-data.service.ts} +8 -8
- package/src/_modules/ai/_modules/open-ai/_services/{oai-doc-page.data-service.ts → data-services/oai-doc-page.data-service.ts} +8 -8
- package/src/_modules/ai/_modules/open-ai/_services/{oai-document.data-service.ts → data-services/oai-document.data-service.ts} +7 -7
- package/src/_modules/ai/_modules/open-ai/_services/{oai-vector-data.service.ts → data-services/oai-vector-data.service.ts} +4 -4
- package/src/_modules/ai/_modules/open-ai/_services/oai-embedding.control-service.ts +18 -2
- package/src/_modules/ai/_modules/open-ai/_services/oai-llm-chat.service-base.ts +138 -159
- package/src/_modules/ai/_modules/open-ai/_services/oai-llm.service-base.ts +247 -13
- package/src/_modules/ai/_modules/open-ai/index.ts +8 -7
- package/src/_modules/bot/_enums/bot-message-provider.enum.ts +1 -1
- package/src/_modules/bot/_models/bot-message-wrapper.interface.ts +4 -3
- package/src/_modules/bot/_models/bot-messaging-provider.interface.ts +2 -2
- package/src/_modules/bot/_modules/discord-bot/_services/dib-messaging-provider.service.ts +2 -2
- package/src/_modules/bot/_modules/dynamo-bot/_services/dyb-messaging-provider.service.ts +2 -2
- package/src/_modules/bot/_modules/slack-bot/_services/slb-messaging-provider.service.ts +2 -2
- package/src/_modules/bot/_modules/teams-bot/_services/teb-messaging-provider.service.ts +2 -2
- package/src/_modules/bot/_services/bot-messaging-provider-factory.service.ts +6 -6
- package/src/_modules/discord-assistant/_collections/dias.util.ts +6 -7
- package/src/_modules/discord-assistant/_services/dias-chunk.data-service.ts +6 -6
- package/src/_modules/discord-assistant/_services/dias-io.control-service.ts +2 -2
- package/src/_modules/discord-assistant/_services/dias.service-base.ts +2 -3
- package/build/_modules/ai/_services/oai-to-ai-adapter.service.d.ts +0 -39
- package/build/_modules/ai/_services/oai-to-ai-adapter.service.d.ts.map +0 -1
- package/build/_modules/ai/_services/oai-to-ai-adapter.service.js +0 -218
- package/build/_modules/ai/_services/oai-to-ai-adapter.service.js.map +0 -1
- package/build/_modules/bot/_enums/bot-provider.enum.d.ts +0 -8
- package/build/_modules/bot/_enums/bot-provider.enum.d.ts.map +0 -1
- package/build/_modules/bot/_enums/bot-provider.enum.js +0 -12
- package/build/_modules/bot/_enums/bot-provider.enum.js.map +0 -1
- package/build/_modules/bot/_models/bot-provider.interface.d.ts +0 -65
- package/build/_modules/bot/_models/bot-provider.interface.d.ts.map +0 -1
- package/build/_modules/bot/_models/bot-provider.interface.js +0 -3
- package/build/_modules/bot/_models/bot-provider.interface.js.map +0 -1
- package/build/_modules/bot/_modules/discord-bot/_services/dib-provider.service.d.ts +0 -53
- package/build/_modules/bot/_modules/discord-bot/_services/dib-provider.service.d.ts.map +0 -1
- package/build/_modules/bot/_modules/discord-bot/_services/dib-provider.service.js +0 -369
- package/build/_modules/bot/_modules/discord-bot/_services/dib-provider.service.js.map +0 -1
- package/build/_modules/bot/_modules/dynamo-bot/_services/dyb-provider.service.d.ts +0 -54
- package/build/_modules/bot/_modules/dynamo-bot/_services/dyb-provider.service.d.ts.map +0 -1
- package/build/_modules/bot/_modules/dynamo-bot/_services/dyb-provider.service.js +0 -310
- package/build/_modules/bot/_modules/dynamo-bot/_services/dyb-provider.service.js.map +0 -1
- package/build/_modules/bot/_modules/slack-bot/_services/slb-provider.service.d.ts +0 -40
- package/build/_modules/bot/_modules/slack-bot/_services/slb-provider.service.d.ts.map +0 -1
- package/build/_modules/bot/_modules/slack-bot/_services/slb-provider.service.js +0 -116
- package/build/_modules/bot/_modules/slack-bot/_services/slb-provider.service.js.map +0 -1
- package/build/_modules/bot/_modules/teams-bot/_services/teb-provider.service.d.ts +0 -40
- package/build/_modules/bot/_modules/teams-bot/_services/teb-provider.service.d.ts.map +0 -1
- package/build/_modules/bot/_modules/teams-bot/_services/teb-provider.service.js +0 -116
- package/build/_modules/bot/_modules/teams-bot/_services/teb-provider.service.js.map +0 -1
- package/build/_modules/bot/_services/bot-provider-factory.service.d.ts +0 -5
- package/build/_modules/bot/_services/bot-provider-factory.service.d.ts.map +0 -1
- package/build/_modules/bot/_services/bot-provider-factory.service.js +0 -31
- package/build/_modules/bot/_services/bot-provider-factory.service.js.map +0 -1
|
@@ -2,15 +2,33 @@ import { OpenAI } from 'openai';
|
|
|
2
2
|
|
|
3
3
|
import { DyFM_OAI_Settings, DyFM_OAI_Model, DyFM_OAI_CallSettings } from '@futdevpro/fsm-dynamo/ai/open-ai';
|
|
4
4
|
import { DyFM_AnyError, DyFM_Error, DyFM_Error_Settings, DyFM_Log, DyFM_notNull, DyFM_Object } from '@futdevpro/fsm-dynamo';
|
|
5
|
+
import {
|
|
6
|
+
DyFM_AI_Message,
|
|
7
|
+
DyFM_AI_MessageRole,
|
|
8
|
+
DyFM_AI_Provider,
|
|
9
|
+
DyFM_AI_ProviderCapabilities,
|
|
10
|
+
DyFM_AI_CallSettings,
|
|
11
|
+
DyFM_AI_Config,
|
|
12
|
+
DyFM_AI_LLM_Response
|
|
13
|
+
} from '@futdevpro/fsm-dynamo/ai';
|
|
5
14
|
|
|
6
15
|
import { DyNTS_global_settings } from '../../../../../_collections/global-settings.const';
|
|
7
|
-
import { DyNTS_OAI_GPT_Message } from '../_models/interfaces/oai-gpt-message.interface';
|
|
8
16
|
import { ChatCompletion } from 'openai/resources';
|
|
9
17
|
import { ChatCompletionCreateParamsBase, ChatCompletionMessageParam } from 'openai/resources/chat/completions';
|
|
10
|
-
import { DyNTS_OAI_GPT_Message_Role } from '../_enums/oai-gpt-message-role.enum';
|
|
11
18
|
import { DyNTS_OAI_LLM_Predefined_Requests } from '../_models/interfaces/oai-llm-predefined-requests.interface';
|
|
12
19
|
import { DyNTS_OAI_global_settings } from '../_collections/oai-global-settings.const';
|
|
13
20
|
import { DyNTS_OAI_LLMDefaultPredefined_Requests } from '../_collections/oai-llm-predefined-requests.conts';
|
|
21
|
+
import { DyNTS_AI_LLM_ServiceBase } from '../../../_services/ai-llm.service-base';
|
|
22
|
+
import {
|
|
23
|
+
DyFM_AI_Question_Input,
|
|
24
|
+
DyFM_AI_ListSelect_Input,
|
|
25
|
+
DyFM_AI_GenericSelect_Input,
|
|
26
|
+
DyFM_AI_MultiSelect_Input,
|
|
27
|
+
DyFM_AI_GenericMultiSelect_Input,
|
|
28
|
+
DyFM_AI_JSONKeysDescription_Input,
|
|
29
|
+
DyFM_AI_JSONExactKeys_Input,
|
|
30
|
+
DyFM_AI_SimpleMessage_Input
|
|
31
|
+
} from '../../../_models/ai-input-interfaces';
|
|
14
32
|
|
|
15
33
|
|
|
16
34
|
/**
|
|
@@ -23,18 +41,33 @@ import { DyNTS_OAI_LLMDefaultPredefined_Requests } from '../_collections/oai-llm
|
|
|
23
41
|
|
|
24
42
|
// Di Dictionary DiModel DiEz DiAz
|
|
25
43
|
|
|
26
|
-
export class DyNTS_OAI_LLM_ServiceBase {
|
|
44
|
+
export class DyNTS_OAI_LLM_ServiceBase extends DyNTS_AI_LLM_ServiceBase {
|
|
27
45
|
|
|
28
46
|
readonly defaultErrorUserMsg: string =
|
|
29
47
|
`We encountered an unhandled Control Service Error, ` +
|
|
30
48
|
`\nplease contact the responsible development team.`;
|
|
31
49
|
|
|
32
|
-
|
|
50
|
+
openai: OpenAI;
|
|
33
51
|
|
|
34
|
-
/* readonly defaultSystemPrompt: string;
|
|
35
|
-
readonly defaultModel: DyFM_OAI_Model | string; */
|
|
36
52
|
readonly defaultSettings: DyFM_OAI_CallSettings;
|
|
37
53
|
|
|
54
|
+
// Provider properties from DyNTS_AI_Provider_ServiceBase
|
|
55
|
+
readonly aiProvider: DyFM_AI_Provider = DyFM_AI_Provider.OpenAI;
|
|
56
|
+
|
|
57
|
+
readonly capabilities: DyFM_AI_ProviderCapabilities = {
|
|
58
|
+
chat: true,
|
|
59
|
+
embeddings: true,
|
|
60
|
+
imageGeneration: true,
|
|
61
|
+
vision: true,
|
|
62
|
+
audioGeneration: true,
|
|
63
|
+
audioAnalysis: true,
|
|
64
|
+
functionCalling: true,
|
|
65
|
+
streaming: true,
|
|
66
|
+
batchOperations: true,
|
|
67
|
+
maxContextLength: 128000,
|
|
68
|
+
supportedModelTypes: ['gpt-4o', 'gpt-4o-mini', 'text-embedding-3-large', 'text-embedding-3-small']
|
|
69
|
+
};
|
|
70
|
+
|
|
38
71
|
get debugLog(): boolean {
|
|
39
72
|
return this.defaultSettings.debugLog;
|
|
40
73
|
}
|
|
@@ -53,6 +86,8 @@ export class DyNTS_OAI_LLM_ServiceBase {
|
|
|
53
86
|
constructor(
|
|
54
87
|
set?: DyFM_OAI_Settings
|
|
55
88
|
) {
|
|
89
|
+
super();
|
|
90
|
+
|
|
56
91
|
DyNTS_global_settings.openAi_settings ??= DyNTS_OAI_global_settings;
|
|
57
92
|
|
|
58
93
|
this.openai = new OpenAI(
|
|
@@ -458,7 +493,7 @@ export class DyNTS_OAI_LLM_ServiceBase {
|
|
|
458
493
|
}
|
|
459
494
|
): Promise<string> {
|
|
460
495
|
return this.resolveMessage({
|
|
461
|
-
conversation: [{ role:
|
|
496
|
+
conversation: [{ role: DyFM_AI_MessageRole.user, content: set.message }],
|
|
462
497
|
issuer: set.issuer,
|
|
463
498
|
settings: set.settings,
|
|
464
499
|
getFullResponse: false,
|
|
@@ -476,7 +511,7 @@ export class DyNTS_OAI_LLM_ServiceBase {
|
|
|
476
511
|
*/
|
|
477
512
|
async resolveMessage(
|
|
478
513
|
set: {
|
|
479
|
-
conversation:
|
|
514
|
+
conversation: DyFM_AI_Message[],
|
|
480
515
|
issuer: string,
|
|
481
516
|
settings?: DyFM_OAI_CallSettings,
|
|
482
517
|
getFullResponse?: boolean
|
|
@@ -545,7 +580,7 @@ export class DyNTS_OAI_LLM_ServiceBase {
|
|
|
545
580
|
*/
|
|
546
581
|
protected getMessageCreateInput(
|
|
547
582
|
set: {
|
|
548
|
-
conversation:
|
|
583
|
+
conversation: DyFM_AI_Message[],
|
|
549
584
|
issuer: string,
|
|
550
585
|
settings?: DyFM_OAI_CallSettings
|
|
551
586
|
}
|
|
@@ -591,15 +626,15 @@ export class DyNTS_OAI_LLM_ServiceBase {
|
|
|
591
626
|
}
|
|
592
627
|
}
|
|
593
628
|
|
|
594
|
-
protected getDefaultSystemMessage(settings: DyFM_OAI_CallSettings):
|
|
629
|
+
protected getDefaultSystemMessage(settings: DyFM_OAI_CallSettings): DyFM_AI_Message {
|
|
595
630
|
return {
|
|
596
|
-
role:
|
|
631
|
+
role: DyFM_AI_MessageRole.system,
|
|
597
632
|
content: settings?.systemPrompt || this.defaultSystemPrompt,
|
|
598
633
|
};
|
|
599
634
|
}
|
|
600
635
|
|
|
601
|
-
protected validateConversation(conversation:
|
|
602
|
-
conversation.forEach((message:
|
|
636
|
+
protected validateConversation(conversation: DyFM_AI_Message[]): void {
|
|
637
|
+
conversation.forEach((message: DyFM_AI_Message, index: number) => {
|
|
603
638
|
if (!message.role) {
|
|
604
639
|
throw new DyFM_Error({
|
|
605
640
|
message: `Message has no role at index ${index}`,
|
|
@@ -641,4 +676,203 @@ export class DyNTS_OAI_LLM_ServiceBase {
|
|
|
641
676
|
}
|
|
642
677
|
|
|
643
678
|
//#endregion
|
|
679
|
+
|
|
680
|
+
//#region Provider Methods (from DyNTS_AI_Provider_ServiceBase)
|
|
681
|
+
|
|
682
|
+
/**
|
|
683
|
+
* Inicializálja az OpenAI client-et a megadott config-gal
|
|
684
|
+
*
|
|
685
|
+
* Reinitializes the OpenAI client with the provided config
|
|
686
|
+
*/
|
|
687
|
+
initialize(config: DyFM_AI_Config): void {
|
|
688
|
+
this.openai = new OpenAI(config);
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
/**
|
|
692
|
+
* Teszteli a kapcsolatot az OpenAI API-val
|
|
693
|
+
*
|
|
694
|
+
* Tests the connection to OpenAI API
|
|
695
|
+
*/
|
|
696
|
+
async testConnection(issuer: string): Promise<boolean> {
|
|
697
|
+
try {
|
|
698
|
+
await this.openai.models.list();
|
|
699
|
+
return true;
|
|
700
|
+
} catch (error) {
|
|
701
|
+
DyFM_Log.error('DyNTS_OAI_LLM_ServiceBase', 'testConnection', 'Connection test failed', {
|
|
702
|
+
error,
|
|
703
|
+
issuer
|
|
704
|
+
});
|
|
705
|
+
return false;
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
//#endregion
|
|
710
|
+
|
|
711
|
+
//#region Abstract LLM Methods (from DyNTS_AI_LLM_ServiceBase)
|
|
712
|
+
|
|
713
|
+
/**
|
|
714
|
+
* Meghívja az LLM-et system és user message-szel
|
|
715
|
+
*
|
|
716
|
+
* Calls the LLM with system and user messages
|
|
717
|
+
*/
|
|
718
|
+
async callLLM(
|
|
719
|
+
systemMessage: string,
|
|
720
|
+
userMessage: string,
|
|
721
|
+
settings?: DyFM_AI_CallSettings,
|
|
722
|
+
issuer?: string
|
|
723
|
+
): Promise<string> {
|
|
724
|
+
const result = await this.resolveMessage({
|
|
725
|
+
conversation: [
|
|
726
|
+
{ role: DyFM_AI_MessageRole.system, content: systemMessage },
|
|
727
|
+
{ role: DyFM_AI_MessageRole.user, content: userMessage }
|
|
728
|
+
],
|
|
729
|
+
issuer: issuer ?? 'system',
|
|
730
|
+
settings: this.convertToOAISettings(settings),
|
|
731
|
+
getFullResponse: false
|
|
732
|
+
});
|
|
733
|
+
|
|
734
|
+
if (typeof result === 'string') {
|
|
735
|
+
return result;
|
|
736
|
+
}
|
|
737
|
+
return '';
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
/**
|
|
741
|
+
* Meghívja az LLM-et üzenet history-val
|
|
742
|
+
*
|
|
743
|
+
* Calls the LLM with message history
|
|
744
|
+
*/
|
|
745
|
+
async callLLMWithHistory(
|
|
746
|
+
messages: DyFM_AI_Message[],
|
|
747
|
+
settings?: DyFM_AI_CallSettings,
|
|
748
|
+
issuer?: string
|
|
749
|
+
): Promise<string> {
|
|
750
|
+
const result = await this.resolveMessage({
|
|
751
|
+
conversation: messages,
|
|
752
|
+
issuer: issuer ?? 'system',
|
|
753
|
+
settings: this.convertToOAISettings(settings),
|
|
754
|
+
getFullResponse: false
|
|
755
|
+
});
|
|
756
|
+
|
|
757
|
+
if (typeof result === 'string') {
|
|
758
|
+
return result;
|
|
759
|
+
}
|
|
760
|
+
return '';
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
/**
|
|
764
|
+
* Meghívja az LLM-et és visszaadja a raw response-t
|
|
765
|
+
*
|
|
766
|
+
* Calls the LLM and returns raw response
|
|
767
|
+
*/
|
|
768
|
+
async callLLMRaw(
|
|
769
|
+
messages: DyFM_AI_Message[],
|
|
770
|
+
settings?: DyFM_AI_CallSettings,
|
|
771
|
+
issuer?: string
|
|
772
|
+
): Promise<DyFM_AI_LLM_Response> {
|
|
773
|
+
const result = await this.resolveMessage({
|
|
774
|
+
conversation: messages,
|
|
775
|
+
issuer: issuer ?? 'system',
|
|
776
|
+
settings: this.convertToOAISettings(settings),
|
|
777
|
+
getFullResponse: true
|
|
778
|
+
}) as ChatCompletion;
|
|
779
|
+
|
|
780
|
+
return {
|
|
781
|
+
content: result.choices[0].message.content,
|
|
782
|
+
usage: result.usage ? {
|
|
783
|
+
promptTokens: result.usage.prompt_tokens,
|
|
784
|
+
completionTokens: result.usage.completion_tokens,
|
|
785
|
+
totalTokens: result.usage.total_tokens
|
|
786
|
+
} : undefined,
|
|
787
|
+
model: result.model,
|
|
788
|
+
finishReason: result.choices[0].finish_reason,
|
|
789
|
+
rawResponse: result
|
|
790
|
+
};
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
/**
|
|
794
|
+
* Küld egy egyszerű üzenetet az LLM-nek
|
|
795
|
+
*
|
|
796
|
+
* Sends a simple message to the LLM
|
|
797
|
+
*/
|
|
798
|
+
async sendMessage(set: DyFM_AI_SimpleMessage_Input): Promise<string> {
|
|
799
|
+
return await this.resolveSimpleUserMessage({
|
|
800
|
+
message: set.message,
|
|
801
|
+
issuer: set.issuer,
|
|
802
|
+
settings: set.settings ? this.convertToOAISettings(set.settings) : undefined
|
|
803
|
+
});
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
/**
|
|
807
|
+
* Kérdez egy kérdést és JSON választ vár exact keys-szel
|
|
808
|
+
*
|
|
809
|
+
* Asks a question and expects JSON response with exact keys
|
|
810
|
+
*/
|
|
811
|
+
async requestJSONWithExactKeys<T = any>(
|
|
812
|
+
set: DyFM_AI_JSONExactKeys_Input
|
|
813
|
+
): Promise<T> {
|
|
814
|
+
const answer = await this.askJSONQuestionWithExactKeys({
|
|
815
|
+
question: set.question,
|
|
816
|
+
keys: set.keys,
|
|
817
|
+
issuer: set.issuer,
|
|
818
|
+
settings: set.settings ? this.convertToOAISettings(set.settings) : undefined,
|
|
819
|
+
debugLog: set.debugLog,
|
|
820
|
+
replaceThisInLog: set.replaceThisInLog
|
|
821
|
+
});
|
|
822
|
+
|
|
823
|
+
if ('unparsableResult' in answer) {
|
|
824
|
+
throw new DyFM_Error({
|
|
825
|
+
message: 'Invalid JSON response from AI',
|
|
826
|
+
additionalContent: { answer },
|
|
827
|
+
userMessage: 'Failed to parse AI response'
|
|
828
|
+
});
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
return answer as T;
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
/**
|
|
835
|
+
* Kérdez egy kérdést és több választ vár
|
|
836
|
+
*
|
|
837
|
+
* Asks a question and expects multiple responses
|
|
838
|
+
*/
|
|
839
|
+
async requestMultiselect<T = any>(
|
|
840
|
+
set: DyFM_AI_GenericMultiSelect_Input<T>
|
|
841
|
+
): Promise<T[]> {
|
|
842
|
+
const answer = await this.requestMultipleSelect({
|
|
843
|
+
question: set.question,
|
|
844
|
+
options: set.options,
|
|
845
|
+
issuer: set.issuer,
|
|
846
|
+
settings: set.settings ? this.convertToOAISettings(set.settings) : undefined,
|
|
847
|
+
debugLog: set.debugLog,
|
|
848
|
+
replaceThisInLog: set.replaceThisInLog
|
|
849
|
+
});
|
|
850
|
+
|
|
851
|
+
return answer as T[];
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
/**
|
|
855
|
+
* Konvertálja a generic AI settings-et OpenAI specifikus settings-re
|
|
856
|
+
*
|
|
857
|
+
* Converts generic AI settings to OpenAI-specific settings
|
|
858
|
+
*/
|
|
859
|
+
private convertToOAISettings(settings?: DyFM_AI_CallSettings): DyFM_OAI_CallSettings {
|
|
860
|
+
if (!settings) return undefined;
|
|
861
|
+
|
|
862
|
+
const oaiSettings = new DyFM_OAI_CallSettings();
|
|
863
|
+
|
|
864
|
+
if (settings.systemPrompt) oaiSettings.systemPrompt = settings.systemPrompt;
|
|
865
|
+
if (settings.useModel) oaiSettings.useModel = settings.useModel as DyFM_OAI_Model;
|
|
866
|
+
if (settings.project) oaiSettings.project = settings.project;
|
|
867
|
+
if (settings.debugLog !== undefined) oaiSettings.debugLog = settings.debugLog;
|
|
868
|
+
if (settings.temperature !== undefined) oaiSettings.temperature = settings.temperature;
|
|
869
|
+
if (settings.maxTokens !== undefined) oaiSettings.maxTokens = settings.maxTokens;
|
|
870
|
+
if (settings.topP !== undefined) oaiSettings.topP = settings.topP;
|
|
871
|
+
if (settings.frequencyPenalty !== undefined) oaiSettings.frequencyPenalty = settings.frequencyPenalty;
|
|
872
|
+
if (settings.presencePenalty !== undefined) oaiSettings.presencePenalty = settings.presencePenalty;
|
|
873
|
+
|
|
874
|
+
return oaiSettings;
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
//#endregion
|
|
644
878
|
}
|
|
@@ -39,7 +39,7 @@ export * from './_collections/oai-llm-predefined-requests-hu.conts';
|
|
|
39
39
|
|
|
40
40
|
// ENUMS
|
|
41
41
|
//export * from './_enums/oai-compare-result-type.enum';
|
|
42
|
-
export * from './_enums/oai-gpt-message-role.enum';
|
|
42
|
+
/* export * from './_enums/oai-gpt-message-role.enum'; */
|
|
43
43
|
|
|
44
44
|
|
|
45
45
|
// MODELS
|
|
@@ -50,7 +50,7 @@ export * from './_enums/oai-gpt-message-role.enum';
|
|
|
50
50
|
export * from '../document-ai/_models/interfaces/dai-doc-page-compare-result.interface'; */
|
|
51
51
|
/* export * from '../document-ai/_models/interfaces/oai-document-page.interface'; */
|
|
52
52
|
export * from './_models/interfaces/oai-global-settings.interface';
|
|
53
|
-
export * from './_models/interfaces/oai-gpt-message.interface';
|
|
53
|
+
/* export * from './_models/interfaces/oai-gpt-message.interface'; */
|
|
54
54
|
export * from './_models/interfaces/oai-llm-predefined-requests.interface';
|
|
55
55
|
/* export * from '../document-ai/_models/interfaces/dai-doc-page-compare-result.interface'; */
|
|
56
56
|
|
|
@@ -61,12 +61,13 @@ export * from './_services/oai-llm-chat.service';
|
|
|
61
61
|
export * from './_services/oai-embedding.service'; */
|
|
62
62
|
/* export * from './_services/oai-doc-chunk.service'; */
|
|
63
63
|
|
|
64
|
-
//
|
|
65
|
-
export * from './_services/oai-doc-chunk-data.service';
|
|
66
|
-
export * from './_services/oai-doc-page.data-service';
|
|
67
|
-
export * from './_services/oai-document.data-service';
|
|
64
|
+
// SERVICES
|
|
68
65
|
export * from './_services/oai-embedding.control-service';
|
|
69
66
|
export * from './_services/oai-llm-chat.service-base';
|
|
70
67
|
export * from './_services/oai-llm.service-base';
|
|
71
|
-
|
|
68
|
+
// services/DATA-SERVICES
|
|
69
|
+
export * from './_services/data-services/oai-doc-chunk-data.service';
|
|
70
|
+
export * from './_services/data-services/oai-doc-page.data-service';
|
|
71
|
+
export * from './_services/data-services/oai-document.data-service';
|
|
72
|
+
export * from './_services/data-services/oai-vector-data.service';
|
|
72
73
|
/* export * from './_services/oai-doc-chunk.service-base'; */
|
|
@@ -2,7 +2,7 @@ import { DyNTS_Bot_Message } from './bot-message.interface';
|
|
|
2
2
|
import { DyNTS_Bot_Channel } from './bot-channel.interface';
|
|
3
3
|
import { DyNTS_Bot_User } from './bot-user.interface';
|
|
4
4
|
import { DyNTS_Bot_MessagingProvider } from './bot-messaging-provider.interface';
|
|
5
|
-
import {
|
|
5
|
+
import { DyNTS_Bot_MessagingProvider_Type } from '../_enums/bot-message-provider.enum';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Wraps a bot message with provider context
|
|
@@ -10,7 +10,8 @@ import { DyNTS_Bot_MessageProvider_Type } from '../_enums/bot-message-provider.e
|
|
|
10
10
|
* back through the correct platform
|
|
11
11
|
*/
|
|
12
12
|
export interface DyNTS_Bot_MessageWrapper<
|
|
13
|
-
T_MessagingPlatformMessage extends DyNTS_Bot_Message<any> = DyNTS_Bot_Message<any
|
|
13
|
+
T_MessagingPlatformMessage extends DyNTS_Bot_Message<any> = DyNTS_Bot_Message<any>,
|
|
14
|
+
|
|
14
15
|
> {
|
|
15
16
|
/** The wrapped message */
|
|
16
17
|
message: T_MessagingPlatformMessage;
|
|
@@ -19,7 +20,7 @@ export interface DyNTS_Bot_MessageWrapper<
|
|
|
19
20
|
providerId: string;
|
|
20
21
|
|
|
21
22
|
/** Type of the provider (discord, slack, teams, dynamo) */
|
|
22
|
-
providerType:
|
|
23
|
+
providerType: DyNTS_Bot_MessagingProvider_Type;
|
|
23
24
|
|
|
24
25
|
/** Reference to the provider instance for sending replies */
|
|
25
26
|
provider: DyNTS_Bot_MessagingProvider<
|
|
@@ -3,13 +3,13 @@ import { DyNTS_Bot_Channel } from './bot-channel.interface';
|
|
|
3
3
|
import { DyNTS_Bot_User } from './bot-user.interface';
|
|
4
4
|
import { DyNTS_Bot_LastMessageDate } from './bot-last-message-date.interface';
|
|
5
5
|
import { DyNTS_Bot_LastMentionDate } from './bot-last-mention-date.interface';
|
|
6
|
-
import {
|
|
6
|
+
import { DyNTS_Bot_MessagingProvider_Type } from '../_enums/bot-message-provider.enum';
|
|
7
7
|
import { DyNTS_Bot_Global_Settings } from './bot-global-settings.interface';
|
|
8
8
|
|
|
9
9
|
export interface DyNTS_Bot_MessagingProvider_Config extends DyNTS_Bot_Global_Settings {
|
|
10
10
|
/** Unique identifier for this provider instance (required when using multiple providers) */
|
|
11
11
|
providerId?: string;
|
|
12
|
-
messageProvider:
|
|
12
|
+
messageProvider: DyNTS_Bot_MessagingProvider_Type;
|
|
13
13
|
messageProviderInstance?: DyNTS_Bot_MessagingProvider;
|
|
14
14
|
discord?: {
|
|
15
15
|
token: string;
|
|
@@ -3,7 +3,7 @@ import { DyFM_Error, DyFM_Log } from '@futdevpro/fsm-dynamo';
|
|
|
3
3
|
import { DyNTS_Bot_MessagingProvider, DyNTS_Bot_MessagingProvider_Config } from '../../../_models/bot-messaging-provider.interface';
|
|
4
4
|
import { DyNTS_Bot_LastMessageDate } from '../../../_models/bot-last-message-date.interface';
|
|
5
5
|
import { DyNTS_Bot_LastMentionDate } from '../../../_models/bot-last-mention-date.interface';
|
|
6
|
-
import {
|
|
6
|
+
import { DyNTS_Bot_MessagingProvider_Type } from '../../../_enums/bot-message-provider.enum';
|
|
7
7
|
import { DyNTS_DiB_Message, DyNTS_DiB_Channel, DyNTS_DiB_User } from '../_models/dib-platform.types';
|
|
8
8
|
import { DyNTS_global_settings } from '../../../../../_collections/global-settings.const';
|
|
9
9
|
|
|
@@ -41,7 +41,7 @@ export class DyNTS_DiB_MessagingProvider implements DyNTS_Bot_MessagingProvider<
|
|
|
41
41
|
async initialize(config: DyNTS_Bot_MessagingProvider_Config): Promise<void> {
|
|
42
42
|
this.config = config;
|
|
43
43
|
|
|
44
|
-
if (config.messageProvider !==
|
|
44
|
+
if (config.messageProvider !== DyNTS_Bot_MessagingProvider_Type.discord) {
|
|
45
45
|
throw new Error(`Invalid provider type: ${config.messageProvider}. Expected 'discord'`);
|
|
46
46
|
}
|
|
47
47
|
|
|
@@ -2,7 +2,7 @@ import { DyFM_Error, DyFM_Log, week } from '@futdevpro/fsm-dynamo';
|
|
|
2
2
|
import { DyNTS_Bot_MessagingProvider, DyNTS_Bot_MessagingProvider_Config } from '../../../_models/bot-messaging-provider.interface';
|
|
3
3
|
import { DyNTS_Bot_LastMessageDate } from '../../../_models/bot-last-message-date.interface';
|
|
4
4
|
import { DyNTS_Bot_LastMentionDate } from '../../../_models/bot-last-mention-date.interface';
|
|
5
|
-
import {
|
|
5
|
+
import { DyNTS_Bot_MessagingProvider_Type } from '../../../_enums/bot-message-provider.enum';
|
|
6
6
|
import { DyNTS_DyB_Message, DyNTS_DyB_Channel, DyNTS_DyB_User } from '../_models/dyb-platform.types';
|
|
7
7
|
import { DyNTS_global_settings } from '../../../../../_collections/global-settings.const';
|
|
8
8
|
import { DyNTS_Msg_Main_ControlService } from '../../../../messaging/_services/msg-main.control-service';
|
|
@@ -40,7 +40,7 @@ export class DyNTS_DyB_MessagingProvider implements DyNTS_Bot_MessagingProvider<
|
|
|
40
40
|
async initialize(config: DyNTS_Bot_MessagingProvider_Config): Promise<void> {
|
|
41
41
|
this.config = config;
|
|
42
42
|
|
|
43
|
-
if (config.messageProvider !==
|
|
43
|
+
if (config.messageProvider !== DyNTS_Bot_MessagingProvider_Type.dynamo) {
|
|
44
44
|
throw new Error(`Invalid provider type: ${config.messageProvider}. Expected 'dynamo'`);
|
|
45
45
|
}
|
|
46
46
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DyNTS_Bot_MessagingProvider, DyNTS_Bot_MessagingProvider_Config } from '../../../_models/bot-messaging-provider.interface';
|
|
2
2
|
import { DyNTS_Bot_LastMessageDate } from '../../../_models/bot-last-message-date.interface';
|
|
3
3
|
import { DyNTS_Bot_LastMentionDate } from '../../../_models/bot-last-mention-date.interface';
|
|
4
|
-
import {
|
|
4
|
+
import { DyNTS_Bot_MessagingProvider_Type } from '../../../_enums/bot-message-provider.enum';
|
|
5
5
|
import { DyNTS_SlB_Message, DyNTS_SlB_Channel, DyNTS_SlB_User } from '../_models/slb-platform.types';
|
|
6
6
|
|
|
7
7
|
export class DyNTS_SlB_MessagingProvider implements DyNTS_Bot_MessagingProvider<
|
|
@@ -20,7 +20,7 @@ export class DyNTS_SlB_MessagingProvider implements DyNTS_Bot_MessagingProvider<
|
|
|
20
20
|
async initialize(config: DyNTS_Bot_MessagingProvider_Config): Promise<void> {
|
|
21
21
|
this.config = config;
|
|
22
22
|
|
|
23
|
-
if (config.messageProvider !==
|
|
23
|
+
if (config.messageProvider !== DyNTS_Bot_MessagingProvider_Type.slack) {
|
|
24
24
|
throw new Error(`Invalid provider type: ${config.messageProvider}. Expected 'slack'`);
|
|
25
25
|
}
|
|
26
26
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DyNTS_Bot_MessagingProvider, DyNTS_Bot_MessagingProvider_Config } from '../../../_models/bot-messaging-provider.interface';
|
|
2
2
|
import { DyNTS_Bot_LastMessageDate } from '../../../_models/bot-last-message-date.interface';
|
|
3
3
|
import { DyNTS_Bot_LastMentionDate } from '../../../_models/bot-last-mention-date.interface';
|
|
4
|
-
import {
|
|
4
|
+
import { DyNTS_Bot_MessagingProvider_Type } from '../../../_enums/bot-message-provider.enum';
|
|
5
5
|
import { DyNTS_TeB_Message, DyNTS_TeB_Channel, DyNTS_TeB_User } from '../_models/teb-platform.types';
|
|
6
6
|
|
|
7
7
|
export class DyNTS_TeB_MessagingProvider implements DyNTS_Bot_MessagingProvider<
|
|
@@ -20,7 +20,7 @@ export class DyNTS_TeB_MessagingProvider implements DyNTS_Bot_MessagingProvider<
|
|
|
20
20
|
async initialize(config: DyNTS_Bot_MessagingProvider_Config): Promise<void> {
|
|
21
21
|
this.config = config;
|
|
22
22
|
|
|
23
|
-
if (config.messageProvider !==
|
|
23
|
+
if (config.messageProvider !== DyNTS_Bot_MessagingProvider_Type.teams) {
|
|
24
24
|
throw new Error(`Invalid provider type: ${config.messageProvider}. Expected 'teams'`);
|
|
25
25
|
}
|
|
26
26
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DyNTS_Bot_MessagingProvider, DyNTS_Bot_MessagingProvider_Config } from '../_models/bot-messaging-provider.interface';
|
|
2
|
-
import {
|
|
2
|
+
import { DyNTS_Bot_MessagingProvider_Type } from '../_enums/bot-message-provider.enum';
|
|
3
3
|
import { DyNTS_DiB_MessagingProvider } from '../_modules/discord-bot/_services/dib-messaging-provider.service';
|
|
4
4
|
import { DyNTS_SlB_MessagingProvider } from '../_modules/slack-bot/_services/slb-messaging-provider.service';
|
|
5
5
|
import { DyNTS_TeB_MessagingProvider } from '../_modules/teams-bot/_services/teb-messaging-provider.service';
|
|
@@ -9,19 +9,19 @@ export class DyNTS_Bot_MessagingProvider_Factory {
|
|
|
9
9
|
|
|
10
10
|
static createProvider(config: DyNTS_Bot_MessagingProvider_Config): DyNTS_Bot_MessagingProvider {
|
|
11
11
|
switch (config.messageProvider) {
|
|
12
|
-
case
|
|
12
|
+
case DyNTS_Bot_MessagingProvider_Type.discord:
|
|
13
13
|
return new DyNTS_DiB_MessagingProvider();
|
|
14
14
|
|
|
15
|
-
case
|
|
15
|
+
case DyNTS_Bot_MessagingProvider_Type.slack:
|
|
16
16
|
return new DyNTS_SlB_MessagingProvider();
|
|
17
17
|
|
|
18
|
-
case
|
|
18
|
+
case DyNTS_Bot_MessagingProvider_Type.teams:
|
|
19
19
|
return new DyNTS_TeB_MessagingProvider();
|
|
20
20
|
|
|
21
|
-
case
|
|
21
|
+
case DyNTS_Bot_MessagingProvider_Type.dynamo:
|
|
22
22
|
return new DyNTS_DyB_MessagingProvider();
|
|
23
23
|
|
|
24
|
-
case
|
|
24
|
+
case DyNTS_Bot_MessagingProvider_Type.custom:
|
|
25
25
|
if (!config.messageProviderInstance) {
|
|
26
26
|
throw new Error('Custom provider instance is required when provider type is "custom"');
|
|
27
27
|
}
|
|
@@ -2,9 +2,8 @@ import { Message, TextChannel } from 'discord.js';
|
|
|
2
2
|
|
|
3
3
|
import { DyFM_Error } from '@futdevpro/fsm-dynamo';
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { DyFM_AI_Message, DyFM_AI_MessageRole } from '@futdevpro/fsm-dynamo/ai';
|
|
6
6
|
import { DyNTS_DiAs_global_settings } from './dias-global-settings.const';
|
|
7
|
-
import { DyNTS_OAI_GPT_Message_Role } from '../../ai/_modules/open-ai/_enums/oai-gpt-message-role.enum';
|
|
8
7
|
|
|
9
8
|
|
|
10
9
|
export class DyNTS_DiAs_Util {
|
|
@@ -16,7 +15,7 @@ export class DyNTS_DiAs_Util {
|
|
|
16
15
|
botDisplayName: string,
|
|
17
16
|
issuer: string,
|
|
18
17
|
}
|
|
19
|
-
):
|
|
18
|
+
): DyFM_AI_Message[] {
|
|
20
19
|
|
|
21
20
|
return set.messages.map(message => {
|
|
22
21
|
if (
|
|
@@ -29,18 +28,18 @@ export class DyNTS_DiAs_Util {
|
|
|
29
28
|
flag => message.content.includes(flag)
|
|
30
29
|
)) {
|
|
31
30
|
return {
|
|
32
|
-
role:
|
|
31
|
+
role: DyFM_AI_MessageRole.user,
|
|
33
32
|
content: message.content,
|
|
34
33
|
};
|
|
35
34
|
} else {
|
|
36
35
|
return {
|
|
37
|
-
role:
|
|
36
|
+
role: DyFM_AI_MessageRole.assistant,
|
|
38
37
|
content: message.content,
|
|
39
38
|
};
|
|
40
39
|
}
|
|
41
40
|
} else {
|
|
42
41
|
return {
|
|
43
|
-
role:
|
|
42
|
+
role: DyFM_AI_MessageRole.user,
|
|
44
43
|
content: message.content,
|
|
45
44
|
};
|
|
46
45
|
}
|
|
@@ -55,7 +54,7 @@ export class DyNTS_DiAs_Util {
|
|
|
55
54
|
issuer: string,
|
|
56
55
|
skipFlags?: string[],
|
|
57
56
|
}
|
|
58
|
-
): Promise<
|
|
57
|
+
): Promise<DyFM_AI_Message[]> {
|
|
59
58
|
const messages: Message[] = await this.gatherMessagesForMessage(set/* message, botClientId, issuer, skipFlags */);
|
|
60
59
|
|
|
61
60
|
return DyNTS_DiAs_Util.convertDiscordMessagesToOAIConversation({
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { DyFM_OAI_Model, DyFM_OAI_Settings } from '@futdevpro/fsm-dynamo/ai/open-ai';
|
|
2
2
|
import { DyNTS_OAI_LLMChat_ServiceBase } from './../../ai/_modules/open-ai/_services/oai-llm-chat.service-base';
|
|
3
3
|
import { DyNTS_DAI_DocChunk, DyNTS_DAI_docChunk_dataParams } from '../../ai/_modules/document-ai/_models/data-models/dai-doc-chunk.data-model';
|
|
4
|
-
import { DyNTS_OAI_DocChunkDataService } from '../../ai/_modules/open-ai/_services/oai-doc-chunk-data.service';
|
|
4
|
+
import { DyNTS_OAI_DocChunkDataService } from '../../ai/_modules/open-ai/_services/data-services/oai-doc-chunk-data.service';
|
|
5
5
|
import { DyFM_DataModel_Params, DyFM_Error, DyFM_Log } from '@futdevpro/fsm-dynamo';
|
|
6
6
|
// TODO: Fix imports when FSM package exports are updated
|
|
7
7
|
// import { DyFM_OAI_Settings } from '@futdevpro/fsm-dynamo';
|
|
8
8
|
// import { DyFM_OAI_Model } from '@futdevpro/fsm-dynamo';
|
|
9
9
|
import { DyNTS_DiAs_Main_ControlService } from './dias-main.control-service';
|
|
10
10
|
import { DyNTS_AI_LLMChat_ServiceBase } from '../../ai/_services/ai-llm-chat.service-base';
|
|
11
|
-
import {
|
|
11
|
+
import { DyFM_AI_Message } from '@futdevpro/fsm-dynamo/ai';
|
|
12
12
|
import { DyNTS_OAI_LLMDefaultPredefined_Requests } from '../../ai/_modules/open-ai/_collections/oai-llm-predefined-requests.conts';
|
|
13
13
|
import { DyNTS_DAI_Document_Util } from '../../ai/_modules/document-ai/_collections/dai-document.util';
|
|
14
14
|
import { DyNTS_DAI_DocPage } from '../../ai/_modules/document-ai/_models/data-models/dai-doc-page.data-model';
|
|
@@ -54,7 +54,7 @@ export abstract class DyNTS_DiAs_Chunk_DataService<
|
|
|
54
54
|
/* abstract getPageLink(page: T_Page): string; */
|
|
55
55
|
|
|
56
56
|
async resolveConversation(
|
|
57
|
-
conversation:
|
|
57
|
+
conversation: DyFM_AI_Message[],
|
|
58
58
|
limit: number = 10,
|
|
59
59
|
numberOfCandidates: number = 200,
|
|
60
60
|
): Promise<string> {
|
|
@@ -96,7 +96,7 @@ export abstract class DyNTS_DiAs_Chunk_DataService<
|
|
|
96
96
|
// add code overview by coding policies
|
|
97
97
|
// (Milyen jellegű coding policies lehet releváns az adott kérdésben)
|
|
98
98
|
async vectorSearchAndResolveConversation(
|
|
99
|
-
conversation:
|
|
99
|
+
conversation: DyFM_AI_Message[],
|
|
100
100
|
limit: number = 3,
|
|
101
101
|
numberOfCandidates: number = 100,
|
|
102
102
|
): Promise<string> {
|
|
@@ -139,12 +139,12 @@ export abstract class DyNTS_DiAs_Chunk_DataService<
|
|
|
139
139
|
|
|
140
140
|
// TODO: EZT KELL HÍVNI PARANCSRA
|
|
141
141
|
async vectorSearchUsingConversation(
|
|
142
|
-
conversation:
|
|
142
|
+
conversation: DyFM_AI_Message[],
|
|
143
143
|
limit: number = 3,
|
|
144
144
|
numberOfCandidates: number = 100,
|
|
145
145
|
): Promise<T_Chunk[]> {
|
|
146
146
|
try {
|
|
147
|
-
const lastMessage:
|
|
147
|
+
const lastMessage: DyFM_AI_Message = conversation[conversation.length - 1];
|
|
148
148
|
|
|
149
149
|
const searchQuestion: string = await this.llmChat_CS.getAnswerInConversation({
|
|
150
150
|
conversation: conversation,
|
|
@@ -8,7 +8,7 @@ import { DyNTS_DiBo_IO_ControlService } from '../../discord-bot/_services/dibo-i
|
|
|
8
8
|
import { DyNTS_DiAs_Main_ControlService } from './dias-main.control-service'
|
|
9
9
|
import { DyNTS_DiBo_global_settings } from '../../discord-bot/_collections/dibo-global-settings.conts'
|
|
10
10
|
import { DyNTS_OAI_LLMChat_ServiceBase } from '../../ai/_modules/open-ai/_services/oai-llm-chat.service-base'
|
|
11
|
-
import {
|
|
11
|
+
import { DyFM_AI_Message } from '@futdevpro/fsm-dynamo/ai';
|
|
12
12
|
import { DyNTS_DiAs_Util } from '../_collections/dias.util'
|
|
13
13
|
|
|
14
14
|
export abstract class DyNTS_DiAs_IO_ControlService extends DyNTS_DiBo_IO_ControlService {
|
|
@@ -31,7 +31,7 @@ export abstract class DyNTS_DiAs_IO_ControlService extends DyNTS_DiBo_IO_Control
|
|
|
31
31
|
override async handleMessage(message: Message, issuer: string): Promise<Message> {
|
|
32
32
|
try {
|
|
33
33
|
const messages: Message[] = await this.mainDiscordBot_CS.gatherDiscordMessagesForMessage(message);
|
|
34
|
-
const oaiMessages:
|
|
34
|
+
const oaiMessages: DyFM_AI_Message[] =
|
|
35
35
|
DyNTS_DiAs_Util.convertDiscordMessagesToOAIConversation({
|
|
36
36
|
messages: messages,
|
|
37
37
|
botClientId: this.mainDiscordBot_CS.botClientId,
|