@futdevpro/nts-dynamo 1.14.27 → 1.14.28
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/oai-llm-chat.service-base.d.ts +26 -129
- 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 +25 -10
- 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 +5 -5
- 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 +3 -3
- 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 +0 -2
- package/build/_modules/ai/_modules/open-ai/index.d.ts.map +1 -1
- package/build/_modules/ai/_modules/open-ai/index.js +2 -2
- 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 +4 -4
- 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.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-llm-chat.service-base.ts +56 -158
- package/src/_modules/ai/_modules/open-ai/_services/oai-llm.service-base.ts +8 -9
- package/src/_modules/ai/_modules/open-ai/index.ts +2 -2
- 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 +5 -5
- 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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dias-chunk.data-service.js","sourceRoot":"","sources":["../../../../src/_modules/discord-assistant/_services/dias-chunk.data-service.ts"],"names":[],"mappings":";;;AAAA,8DAAqF;AAErF,yHAA+I;AAC/I,+GAA+G;AAC/G,sDAAoF;AAOpF,gIAAmI;AAGnI,uFAAoF;AAIpF,MAAsB,4BAKpB,SAAQ,0DAAgF;IAIxF,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,iBAAiB,CAAC,UAAU,CAAC;IAC3C,CAAC;IAED,YACE,MAAc,EACd,UAA2C,EAC3C,cAAkC;QAElC,KAAK,CACH,MAAM,EACN,cAAc;YACZ,IAAI,2BAAiB,CAAC;gBACpB,MAAM,EAAE;oBACN,MAAM,EAAE,6CAAqB,CAAC,YAAY,CAAC,MAAM,CAAC,MAAM;oBACxD,YAAY,EAAE,6CAAqB,CAAC,YAAY,CAAC,MAAM,CAAC,YAAY;oBACpE,OAAO,EAAE,6CAAqB,CAAC,YAAY,CAAC,MAAM,CAAC,OAAO;iBAC3D;gBACD,eAAe,EAAE;oBACf,QAAQ,EAAE,wBAAc,CAAC,oBAAoB;iBAC9C;aACF,CAAC,EACJ,UAAU,IAAI,wDAA+D,CAC9E,CAAC;IACJ,CAAC;IAED,iDAAiD;IAEjD,KAAK,CAAC,mBAAmB,CACvB,
|
|
1
|
+
{"version":3,"file":"dias-chunk.data-service.js","sourceRoot":"","sources":["../../../../src/_modules/discord-assistant/_services/dias-chunk.data-service.ts"],"names":[],"mappings":";;;AAAA,8DAAqF;AAErF,yHAA+I;AAC/I,+GAA+G;AAC/G,sDAAoF;AAOpF,gIAAmI;AAGnI,uFAAoF;AAIpF,MAAsB,4BAKpB,SAAQ,0DAAgF;IAIxF,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,iBAAiB,CAAC,UAAU,CAAC;IAC3C,CAAC;IAED,YACE,MAAc,EACd,UAA2C,EAC3C,cAAkC;QAElC,KAAK,CACH,MAAM,EACN,cAAc;YACZ,IAAI,2BAAiB,CAAC;gBACpB,MAAM,E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DyNTS_OAI_LLMChat_ServiceBase } from './../../ai/_modules/open-ai/_services/oai-llm-chat.service-base';
|
|
2
2
|
import { Message, TextChannel } from 'discord.js';
|
|
3
3
|
import { DyNTS_DiBo_Main_ControlService } from '../../discord-bot/_services/dibo-main.control-service';
|
|
4
|
-
import {
|
|
4
|
+
import { DyFM_AI_Message } from '@futdevpro/fsm-dynamo/ai';
|
|
5
5
|
import { DyNTS_DiAs_IO_ControlService } from './dias-io.control-service';
|
|
6
6
|
export declare abstract class DyNTS_DiAs_ServiceBase extends DyNTS_DiBo_Main_ControlService {
|
|
7
7
|
getLLMChatControlService(): DyNTS_OAI_LLMChat_ServiceBase;
|
|
@@ -14,6 +14,6 @@ export declare abstract class DyNTS_DiAs_ServiceBase extends DyNTS_DiBo_Main_Con
|
|
|
14
14
|
gatherDiscordMessagesForChannel(channel: TextChannel, userId: string, limit?: number,
|
|
15
15
|
/** If this is true, then we will add the sender's name to each message */
|
|
16
16
|
addSourceInfo?: boolean): Promise<Message[]>;
|
|
17
|
-
gatherMessagesAsOAIConversation(message: Message, issuer: string): Promise<
|
|
17
|
+
gatherMessagesAsOAIConversation(message: Message, issuer: string): Promise<DyFM_AI_Message[]>;
|
|
18
18
|
}
|
|
19
19
|
//# sourceMappingURL=dias.service-base.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dias.service-base.d.ts","sourceRoot":"","sources":["../../../../src/_modules/discord-assistant/_services/dias.service-base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,MAAM,iEAAiE,CAAC;AAEhH,OAAO,EAAiB,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEjE,OAAO,EAAE,8BAA8B,EAAE,MAAM,uDAAuD,CAAC;AAGvG,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"dias.service-base.d.ts","sourceRoot":"","sources":["../../../../src/_modules/discord-assistant/_services/dias.service-base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,MAAM,iEAAiE,CAAC;AAEhH,OAAO,EAAiB,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEjE,OAAO,EAAE,8BAA8B,EAAE,MAAM,uDAAuD,CAAC;AAGvG,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAE3D,OAAO,EAAE,4BAA4B,EAAE,MAAM,2BAA2B,CAAC;AAEzE,8BAAsB,sBAAuB,SAAQ,8BAA8B;IAEjF,wBAAwB,IAAI,6BAA6B;IAGzD,QAAQ,CAAC,UAAU,EAAE,6BAA6B,CAAmC;IAErF,mBAA4B,QAAQ,EAAE,4BAA4B,CAAC;uBACvC,sBAAsB,IAAI,4BAA4B;IAElF,mBAAmB,EAAE,MAAM,CAAkD;IAE7E,SAAS,aACP,kBAAkB,CAAC,EAAE,OAAO;IASxB,+BAA+B,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,GAAE,MAAY,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAI1F,+BAA+B,CACnC,OAAO,EAAE,WAAW,EACpB,MAAM,EAAE,MAAM,EACd,KAAK,GAAE,MAAY;IACnB,0EAA0E;IAC1E,aAAa,CAAC,EAAE,OAAO,GACtB,OAAO,CAAC,OAAO,EAAE,CAAC;IAoBf,+BAA+B,CACnC,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,eAAe,EAAE,CAAC;CAU9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dias.service-base.js","sourceRoot":"","sources":["../../../../src/_modules/discord-assistant/_services/dias.service-base.ts"],"names":[],"mappings":";;;AAAA,+GAAgH;AAIhH,qGAAuG;AACvG,2FAAwF;AACxF,uFAAoF;
|
|
1
|
+
{"version":3,"file":"dias.service-base.js","sourceRoot":"","sources":["../../../../src/_modules/discord-assistant/_services/dias.service-base.ts"],"names":[],"mappings":";;;AAAA,+GAAgH;AAIhH,qGAAuG;AACvG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,IAAI,CAAC,WAAW,EAAE,MAAM,CAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;YACjG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;gBACrB,GAAG,CAAC,OAAO,GAAG,KAAK,GAAG,CAAC,MAAM,CAAC,WAAW,OAAO,GAAG,CAAC,OAAO,EAAE,CAAC;YAChE,CAAC,CAAC,CAAC;QACL,CAAC;QAED,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,gBAAgB,GAAG,CAAC,CAAC,gBAAgB,CAAC,CAAC;QAEjE,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,KAAK,CAAC,+BAA+B,CACnC,OAAgB,EAChB,MAAc;QAEd,MAAM,QAAQ,GAAc,MAAM,IAAI,CAAC,+BAA+B,CAAC,OAAO,CAAC,CAAC;QAEhF,OAAO,2BAAe,CAAC,uCAAuC,CAAC;YAC7D,QAAQ,EAAE,QAAQ;YAClB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,cAAc,EAAE,IAAI,CAAC,cAAc;YACnC,MAAM,EAAE,MAAM;SACf,CAAC,CAAC;IACL,CAAC;CACF;AAjED,wDAiEC"}
|
package/package.json
CHANGED
|
@@ -1,45 +1,45 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
export enum
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Developer-provided instructions that the model should follow, regardless of
|
|
8
|
-
* messages sent by the user. With o1 models and newer, use `developer` messages
|
|
9
|
-
* for this purpose instead.
|
|
10
|
-
*/
|
|
11
|
-
system = 'system',
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Messages sent by an end user, containing prompts or additional context
|
|
15
|
-
* information.
|
|
16
|
-
*/
|
|
17
|
-
user = 'user',
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Messages sent by the model in response to user messages.
|
|
21
|
-
*/
|
|
22
|
-
assistant = 'assistant',
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Developer-provided instructions that the model should follow, regardless of
|
|
26
|
-
* messages sent by the user. With o1 models and newer, `developer` messages
|
|
27
|
-
* replace the previous `system` messages.
|
|
28
|
-
*
|
|
29
|
-
* @deprecated
|
|
30
|
-
*/
|
|
31
|
-
/* developer = 'developer', */
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* ???
|
|
35
|
-
* @deprecated
|
|
36
|
-
*/
|
|
37
|
-
/* tool = 'tool', */
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* ???
|
|
41
|
-
* @deprecated
|
|
42
|
-
*/
|
|
43
|
-
/* function = 'function', */
|
|
44
|
-
}
|
|
45
|
-
|
|
4
|
+
//export enum DyFM_AI_MessageRole {
|
|
5
|
+
//
|
|
6
|
+
// /**
|
|
7
|
+
// * Developer-provided instructions that the model should follow, regardless of
|
|
8
|
+
// * messages sent by the user. With o1 models and newer, use `developer` messages
|
|
9
|
+
// * for this purpose instead.
|
|
10
|
+
// */
|
|
11
|
+
// system = 'system',
|
|
12
|
+
//
|
|
13
|
+
// /**
|
|
14
|
+
// * Messages sent by an end user, containing prompts or additional context
|
|
15
|
+
// * information.
|
|
16
|
+
// */
|
|
17
|
+
// user = 'user',
|
|
18
|
+
//
|
|
19
|
+
// /**
|
|
20
|
+
// * Messages sent by the model in response to user messages.
|
|
21
|
+
// */
|
|
22
|
+
// assistant = 'assistant',
|
|
23
|
+
//
|
|
24
|
+
// /**
|
|
25
|
+
// * Developer-provided instructions that the model should follow, regardless of
|
|
26
|
+
// * messages sent by the user. With o1 models and newer, `developer` messages
|
|
27
|
+
// * replace the previous `system` messages.
|
|
28
|
+
// *
|
|
29
|
+
// * @deprecated
|
|
30
|
+
// */
|
|
31
|
+
// /* developer = 'developer', */
|
|
32
|
+
//
|
|
33
|
+
// /**
|
|
34
|
+
// * ???
|
|
35
|
+
// * @deprecated
|
|
36
|
+
// */
|
|
37
|
+
// /* tool = 'tool', */
|
|
38
|
+
//
|
|
39
|
+
// /**
|
|
40
|
+
// * ???
|
|
41
|
+
// * @deprecated
|
|
42
|
+
// */
|
|
43
|
+
// /* function = 'function', */
|
|
44
|
+
//}
|
|
45
|
+
//
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export interface
|
|
4
|
-
role:
|
|
5
|
-
content: string;
|
|
6
|
-
}
|
|
1
|
+
//import { DyFM_AI_MessageRole } from '../../_enums/oai-gpt-message-role.enum';
|
|
2
|
+
//
|
|
3
|
+
//export interface DyFM_AI_Message {
|
|
4
|
+
// role: DyFM_AI_MessageRole /* | string */;
|
|
5
|
+
// content: string;
|
|
6
|
+
//}
|
|
7
7
|
|
|
@@ -2,16 +2,26 @@ 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_getLocalStackLocation, DyFM_Log, DyFM_notNull, DyFM_Object, DyFM_Array } from '@futdevpro/fsm-dynamo';
|
|
5
|
+
import { DyFM_AI_Message } from '@futdevpro/fsm-dynamo/ai';
|
|
5
6
|
|
|
6
7
|
import { DyNTS_global_settings } from '../../../../../_collections/global-settings.const';
|
|
7
|
-
import { DyNTS_OAI_GPT_Message } from '../_models/interfaces/oai-gpt-message.interface';
|
|
8
8
|
import { ChatCompletion } from 'openai/resources';
|
|
9
9
|
import { ChatCompletionCreateParamsBase, ChatCompletionMessageParam } from 'openai/resources/chat/completions';
|
|
10
|
-
import {
|
|
10
|
+
import { DyFM_AI_MessageRole } from '@futdevpro/fsm-dynamo/ai';
|
|
11
11
|
import { DyNTS_OAI_LLM_Predefined_Requests } from '../_models/interfaces/oai-llm-predefined-requests.interface';
|
|
12
12
|
import { DyNTS_OAI_LLM_ServiceBase } from './oai-llm.service-base';
|
|
13
13
|
import { DyNTS_OAI_global_settings } from '../_collections/oai-global-settings.const';
|
|
14
14
|
import { DyNTS_AI_LLMChat_ServiceBase } from '../../../_services/ai-llm-chat.service-base';
|
|
15
|
+
import {
|
|
16
|
+
DyFM_AI_ConversationQuestion_Input,
|
|
17
|
+
DyFM_AI_ConversationSelect_Input,
|
|
18
|
+
DyFM_AI_ConversationGenericSelect_Input,
|
|
19
|
+
DyFM_AI_ConversationMultiSelect_Input,
|
|
20
|
+
DyFM_AI_ConversationGenericMultiSelect_Input,
|
|
21
|
+
DyFM_AI_ConversationJSONKeysDescription_Input,
|
|
22
|
+
DyFM_AI_ConversationJSONExactKeys_Input,
|
|
23
|
+
DyFM_AI_ConversationGetAnswer_Input
|
|
24
|
+
} from '../../../_models/ai-input-interfaces';
|
|
15
25
|
|
|
16
26
|
|
|
17
27
|
/**
|
|
@@ -24,25 +34,27 @@ import { DyNTS_AI_LLMChat_ServiceBase } from '../../../_services/ai-llm-chat.ser
|
|
|
24
34
|
|
|
25
35
|
// Di Dictionary DiModel DiEz DiAz
|
|
26
36
|
|
|
27
|
-
export class DyNTS_OAI_LLMChat_ServiceBase extends DyNTS_OAI_LLM_ServiceBase
|
|
37
|
+
export class DyNTS_OAI_LLMChat_ServiceBase extends DyNTS_OAI_LLM_ServiceBase {
|
|
28
38
|
|
|
39
|
+
/**
|
|
40
|
+
* Converts generic AI messages to OpenAI-specific format
|
|
41
|
+
*
|
|
42
|
+
* Az generic AI üzeneteket OpenAI-specifikus formátumra alakítja át
|
|
43
|
+
*/
|
|
44
|
+
private convertToOAIMessages(messages: DyFM_AI_Message[]): DyFM_AI_Message[] {
|
|
45
|
+
return messages.map(msg => ({
|
|
46
|
+
role: msg.role as unknown as DyFM_AI_MessageRole,
|
|
47
|
+
content: msg.content
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
|
|
29
51
|
/**
|
|
30
52
|
* Asks the AI to answer a yes/no question
|
|
31
53
|
*
|
|
32
54
|
* Uses the {@link DyNTS_OAI_LLM_Predefined_Requests.yesNo.request} to ask the question,
|
|
33
55
|
* and the {@link DyNTS_OAI_LLM_Predefined_Requests.yesNo.upperCaseYes} to check the answer
|
|
34
56
|
*/
|
|
35
|
-
async yesNoQuestionInConversation(
|
|
36
|
-
set: {
|
|
37
|
-
conversation: DyNTS_OAI_GPT_Message[],
|
|
38
|
-
question: string,
|
|
39
|
-
issuer: string,
|
|
40
|
-
settings?: DyFM_OAI_CallSettings,
|
|
41
|
-
debugLog?: boolean,
|
|
42
|
-
/** this is used to readably replace too long contents to eg '...' in logs */
|
|
43
|
-
replaceThisInLog?: string,
|
|
44
|
-
}
|
|
45
|
-
): Promise<boolean> {
|
|
57
|
+
async yesNoQuestionInConversation(set: DyFM_AI_ConversationQuestion_Input): Promise<boolean> {
|
|
46
58
|
set.question += this.predefinedRequests.yesNo.request;
|
|
47
59
|
|
|
48
60
|
this.logQuestion(set);
|
|
@@ -58,17 +70,7 @@ export class DyNTS_OAI_LLMChat_ServiceBase extends DyNTS_OAI_LLM_ServiceBase /*
|
|
|
58
70
|
*
|
|
59
71
|
* Uses the {@link DyNTS_OAI_LLM_Predefined_Requests.simpleQuestion} to ask the question
|
|
60
72
|
*/
|
|
61
|
-
async simpleQuestionInConversation(
|
|
62
|
-
set: {
|
|
63
|
-
conversation: DyNTS_OAI_GPT_Message[],
|
|
64
|
-
question: string,
|
|
65
|
-
issuer: string,
|
|
66
|
-
settings?: DyFM_OAI_CallSettings,
|
|
67
|
-
debugLog?: boolean,
|
|
68
|
-
/** this is used to readably replace too long contents to eg '...' in logs */
|
|
69
|
-
replaceThisInLog?: string,
|
|
70
|
-
}
|
|
71
|
-
): Promise<string> {
|
|
73
|
+
async simpleQuestionInConversation(set: DyFM_AI_ConversationQuestion_Input): Promise<string> {
|
|
72
74
|
this.logQuestion(set);
|
|
73
75
|
|
|
74
76
|
return await this.getQuestionAnswerInConversation(set);
|
|
@@ -80,17 +82,7 @@ export class DyNTS_OAI_LLMChat_ServiceBase extends DyNTS_OAI_LLM_ServiceBase /*
|
|
|
80
82
|
*
|
|
81
83
|
* Uses the {@link DyNTS_OAI_LLM_Predefined_Requests.percentageOnly} to ask the question
|
|
82
84
|
*/
|
|
83
|
-
async percentageQuestionInConversation(
|
|
84
|
-
set: {
|
|
85
|
-
conversation: DyNTS_OAI_GPT_Message[],
|
|
86
|
-
question: string,
|
|
87
|
-
issuer: string,
|
|
88
|
-
settings?: DyFM_OAI_CallSettings,
|
|
89
|
-
debugLog?: boolean,
|
|
90
|
-
/** this is used to readably replace too long contents to eg '...' in logs */
|
|
91
|
-
replaceThisInLog?: string,
|
|
92
|
-
}
|
|
93
|
-
): Promise<number> {
|
|
85
|
+
async percentageQuestionInConversation(set: DyFM_AI_ConversationQuestion_Input): Promise<number> {
|
|
94
86
|
set.question += this.predefinedRequests.percentageOnly;
|
|
95
87
|
|
|
96
88
|
this.logQuestion(set);
|
|
@@ -116,18 +108,7 @@ export class DyNTS_OAI_LLMChat_ServiceBase extends DyNTS_OAI_LLM_ServiceBase /*
|
|
|
116
108
|
*
|
|
117
109
|
* Uses the {@link DyNTS_OAI_LLM_Predefined_Requests.selectRequest} to ask the question
|
|
118
110
|
*/
|
|
119
|
-
async selectQuestionInConversation(
|
|
120
|
-
set: {
|
|
121
|
-
conversation: DyNTS_OAI_GPT_Message[],
|
|
122
|
-
question: string,
|
|
123
|
-
selectFrom: string[],
|
|
124
|
-
issuer: string,
|
|
125
|
-
settings?: DyFM_OAI_CallSettings,
|
|
126
|
-
debugLog?: boolean,
|
|
127
|
-
/** this is used to readably replace too long contents to eg '...' in logs */
|
|
128
|
-
replaceThisInLog?: string,
|
|
129
|
-
}
|
|
130
|
-
): Promise<string> {
|
|
111
|
+
async selectQuestionInConversation(set: DyFM_AI_ConversationSelect_Input): Promise<string> {
|
|
131
112
|
// replace the {{DyNTS_selectOptions}} with the list of options
|
|
132
113
|
const selectQuestionAddition = this.predefinedRequests.selectRequest.replace(
|
|
133
114
|
'{{DyNTS_selectOptions}}',
|
|
@@ -157,16 +138,7 @@ export class DyNTS_OAI_LLMChat_ServiceBase extends DyNTS_OAI_LLM_ServiceBase /*
|
|
|
157
138
|
* Uses the {@link DyNTS_OAI_LLM_Predefined_Requests.selectRequest} to ask the question
|
|
158
139
|
*/
|
|
159
140
|
async requestSelectInConversation<T>(
|
|
160
|
-
set:
|
|
161
|
-
conversation: DyNTS_OAI_GPT_Message[],
|
|
162
|
-
question: string,
|
|
163
|
-
selectFrom: T[],
|
|
164
|
-
issuer: string,
|
|
165
|
-
settings?: DyFM_OAI_CallSettings,
|
|
166
|
-
debugLog?: boolean,
|
|
167
|
-
/** this is used to readably replace too long contents to eg '...' in logs */
|
|
168
|
-
replaceThisInLog?: string,
|
|
169
|
-
}
|
|
141
|
+
set: DyFM_AI_ConversationGenericSelect_Input<T>
|
|
170
142
|
): Promise<T | { unparsableResult: string }> {
|
|
171
143
|
const selectQuestionAddition = this.predefinedRequests.selectRequest.replace(
|
|
172
144
|
'{{DyNTS_selectOptions}}',
|
|
@@ -187,18 +159,7 @@ export class DyNTS_OAI_LLMChat_ServiceBase extends DyNTS_OAI_LLM_ServiceBase /*
|
|
|
187
159
|
*
|
|
188
160
|
* Uses the {@link DyNTS_OAI_LLM_Predefined_Requests.multiselect} to ask the question
|
|
189
161
|
*/
|
|
190
|
-
async multipleSelectQuestionWithOptionsInConversation(
|
|
191
|
-
set: {
|
|
192
|
-
conversation: DyNTS_OAI_GPT_Message[],
|
|
193
|
-
question: string,
|
|
194
|
-
options: string[],
|
|
195
|
-
issuer: string,
|
|
196
|
-
settings?: DyFM_OAI_CallSettings,
|
|
197
|
-
debugLog?: boolean,
|
|
198
|
-
/** this is used to readably replace too long contents to eg '...' in logs */
|
|
199
|
-
replaceThisInLog?: string,
|
|
200
|
-
}
|
|
201
|
-
): Promise<string[]> {
|
|
162
|
+
async multipleSelectQuestionWithOptionsInConversation(set: DyFM_AI_ConversationMultiSelect_Input): Promise<string[]> {
|
|
202
163
|
const selectQuestionAddition = this.predefinedRequests.multiselect.replace(
|
|
203
164
|
'{{DyNTS_selectOptions}}',
|
|
204
165
|
this.getTextListAsText(set.options)
|
|
@@ -229,16 +190,7 @@ export class DyNTS_OAI_LLMChat_ServiceBase extends DyNTS_OAI_LLM_ServiceBase /*
|
|
|
229
190
|
* Uses the {@link DyNTS_OAI_LLM_Predefined_Requests.multiselect} to ask the question
|
|
230
191
|
*/
|
|
231
192
|
async requestMultipleSelectInConversation<T>(
|
|
232
|
-
set:
|
|
233
|
-
conversation: DyNTS_OAI_GPT_Message[],
|
|
234
|
-
question: string,
|
|
235
|
-
options: T[],
|
|
236
|
-
issuer: string,
|
|
237
|
-
settings?: DyFM_OAI_CallSettings,
|
|
238
|
-
debugLog?: boolean,
|
|
239
|
-
/** this is used to readably replace too long contents to eg '...' in logs */
|
|
240
|
-
replaceThisInLog?: string,
|
|
241
|
-
}
|
|
193
|
+
set: DyFM_AI_ConversationGenericMultiSelect_Input<T>
|
|
242
194
|
): Promise<T[]> {
|
|
243
195
|
const selectQuestionAddition = this.predefinedRequests.multiselect.replace(
|
|
244
196
|
'{{DyNTS_selectOptions}}',
|
|
@@ -263,17 +215,7 @@ export class DyNTS_OAI_LLMChat_ServiceBase extends DyNTS_OAI_LLM_ServiceBase /*
|
|
|
263
215
|
*
|
|
264
216
|
* (uses {@link DyFM_safeParseJSON})
|
|
265
217
|
*/
|
|
266
|
-
async jsonQuestionInConversation<T = any>(
|
|
267
|
-
set: {
|
|
268
|
-
conversation: DyNTS_OAI_GPT_Message[],
|
|
269
|
-
question: string,
|
|
270
|
-
issuer: string,
|
|
271
|
-
settings?: DyFM_OAI_CallSettings,
|
|
272
|
-
debugLog?: boolean,
|
|
273
|
-
/** this is used to readably replace too long contents to eg '...' in logs */
|
|
274
|
-
replaceThisInLog?: string,
|
|
275
|
-
}
|
|
276
|
-
): Promise<T | { unparsableResult: string }> {
|
|
218
|
+
async jsonQuestionInConversation<T = any>(set: DyFM_AI_ConversationQuestion_Input): Promise<T | { unparsableResult: string }> {
|
|
277
219
|
set.question += this.predefinedRequests.jsonRequest;
|
|
278
220
|
|
|
279
221
|
this.logQuestion(set);
|
|
@@ -294,16 +236,7 @@ export class DyNTS_OAI_LLMChat_ServiceBase extends DyNTS_OAI_LLM_ServiceBase /*
|
|
|
294
236
|
* (uses {@link DyFM_safeParseJSON})
|
|
295
237
|
*/
|
|
296
238
|
async jsonQuestionWithKeysDescriptionInConversation<T = any>(
|
|
297
|
-
set:
|
|
298
|
-
conversation: DyNTS_OAI_GPT_Message[],
|
|
299
|
-
question: string,
|
|
300
|
-
keysDescription: string,
|
|
301
|
-
issuer: string,
|
|
302
|
-
settings?: DyFM_OAI_CallSettings,
|
|
303
|
-
debugLog?: boolean,
|
|
304
|
-
/** this is used to readably replace too long contents to eg '...' in logs */
|
|
305
|
-
replaceThisInLog?: string,
|
|
306
|
-
}
|
|
239
|
+
set: DyFM_AI_ConversationJSONKeysDescription_Input
|
|
307
240
|
): Promise<T | { unparsableResult: string }> {
|
|
308
241
|
const jsonRequestWithKeysDescription = this.predefinedRequests.jsonRequestWithKeysDescription.replace(
|
|
309
242
|
'{{DyNTS_jsonKeysDescription}}',
|
|
@@ -329,16 +262,7 @@ export class DyNTS_OAI_LLMChat_ServiceBase extends DyNTS_OAI_LLM_ServiceBase /*
|
|
|
329
262
|
* (uses {@link DyFM_safeParseJSON})
|
|
330
263
|
*/
|
|
331
264
|
async jsonQuestionWithExactKeysInConversation<T = any>(
|
|
332
|
-
set:
|
|
333
|
-
conversation: DyNTS_OAI_GPT_Message[],
|
|
334
|
-
question: string,
|
|
335
|
-
keys: string[],
|
|
336
|
-
issuer: string,
|
|
337
|
-
settings?: DyFM_OAI_CallSettings,
|
|
338
|
-
debugLog?: boolean,
|
|
339
|
-
/** this is used to readably replace too long contents to eg '...' in logs */
|
|
340
|
-
replaceThisInLog?: string,
|
|
341
|
-
}
|
|
265
|
+
set: DyFM_AI_ConversationJSONExactKeys_Input
|
|
342
266
|
): Promise<T | { unparsableResult: string }> {
|
|
343
267
|
const jsonRequestWithExactKeys = this.predefinedRequests.jsonRequestWithExactKeys.replace(
|
|
344
268
|
'{{DyNTS_jsonKeys}}',
|
|
@@ -363,17 +287,7 @@ export class DyNTS_OAI_LLMChat_ServiceBase extends DyNTS_OAI_LLM_ServiceBase /*
|
|
|
363
287
|
*
|
|
364
288
|
* (uses {@link DyFM_Object.safeParseList})
|
|
365
289
|
*/
|
|
366
|
-
async listQuestionInConversation(
|
|
367
|
-
set: {
|
|
368
|
-
conversation: DyNTS_OAI_GPT_Message[],
|
|
369
|
-
question: string,
|
|
370
|
-
issuer: string,
|
|
371
|
-
settings?: DyFM_OAI_CallSettings,
|
|
372
|
-
debugLog?: boolean,
|
|
373
|
-
/** this is used to readably replace too long contents to eg '...' in logs */
|
|
374
|
-
replaceThisInLog?: string,
|
|
375
|
-
}
|
|
376
|
-
): Promise<string[]> {
|
|
290
|
+
async listQuestionInConversation(set: DyFM_AI_ConversationQuestion_Input): Promise<string[]> {
|
|
377
291
|
set.question += this.predefinedRequests.listRequest;
|
|
378
292
|
|
|
379
293
|
this.logQuestion(set);
|
|
@@ -390,7 +304,7 @@ export class DyNTS_OAI_LLMChat_ServiceBase extends DyNTS_OAI_LLM_ServiceBase /*
|
|
|
390
304
|
* Uses the {@link resolveSimpleUserMessage}
|
|
391
305
|
*/
|
|
392
306
|
/* async getQuestionAnswerInConversation(
|
|
393
|
-
conversation:
|
|
307
|
+
conversation: DyFM_AI_Message[],
|
|
394
308
|
question: string,
|
|
395
309
|
issuer: string,
|
|
396
310
|
debugLog?: boolean,
|
|
@@ -410,17 +324,7 @@ export class DyNTS_OAI_LLMChat_ServiceBase extends DyNTS_OAI_LLM_ServiceBase /*
|
|
|
410
324
|
return answer;
|
|
411
325
|
} */
|
|
412
326
|
|
|
413
|
-
async getQuestionAnswerInConversation(
|
|
414
|
-
set: {
|
|
415
|
-
conversation: DyNTS_OAI_GPT_Message[],
|
|
416
|
-
question?: string,
|
|
417
|
-
issuer: string,
|
|
418
|
-
settings?: DyFM_OAI_CallSettings,
|
|
419
|
-
debugLog?: boolean,
|
|
420
|
-
/** this is used to readably replace too long contents to eg '...' in logs */
|
|
421
|
-
replaceThisInLog?: string,
|
|
422
|
-
}
|
|
423
|
-
): Promise<string> {
|
|
327
|
+
async getQuestionAnswerInConversation(set: DyFM_AI_ConversationQuestion_Input): Promise<string> {
|
|
424
328
|
return await this.getAnswerInConversation({
|
|
425
329
|
...set,
|
|
426
330
|
newMessage: set.question,
|
|
@@ -438,27 +342,21 @@ export class DyNTS_OAI_LLMChat_ServiceBase extends DyNTS_OAI_LLM_ServiceBase /*
|
|
|
438
342
|
*
|
|
439
343
|
* Uses the {@link resolveConversation}
|
|
440
344
|
*/
|
|
441
|
-
async getAnswerInConversation(
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
newMessage?: string,
|
|
445
|
-
issuer: string,
|
|
446
|
-
settings?: DyFM_OAI_CallSettings,
|
|
447
|
-
debugLog?: boolean,
|
|
448
|
-
/** this is used to readably replace too long contents to eg '...' in logs */
|
|
449
|
-
replaceThisInLog?: string,
|
|
450
|
-
}
|
|
451
|
-
): Promise<string> {
|
|
452
|
-
if (set.newMessage) {
|
|
453
|
-
set.conversation = DyFM_Object.clone(set.conversation);
|
|
345
|
+
async getAnswerInConversation(set: DyFM_AI_ConversationGetAnswer_Input): Promise<string> {
|
|
346
|
+
// Convert generic AI messages to OpenAI-specific format
|
|
347
|
+
const oaiConversation = this.convertToOAIMessages(set.conversation);
|
|
454
348
|
|
|
455
|
-
|
|
456
|
-
|
|
349
|
+
if (set.newMessage) {
|
|
350
|
+
oaiConversation.push({
|
|
351
|
+
role: DyFM_AI_MessageRole.user,
|
|
457
352
|
content: set.newMessage,
|
|
458
353
|
});
|
|
459
354
|
}
|
|
460
355
|
|
|
461
|
-
const answer: string = await this.resolveConversationMessage(
|
|
356
|
+
const answer: string = await this.resolveConversationMessage({
|
|
357
|
+
...set,
|
|
358
|
+
conversation: oaiConversation,
|
|
359
|
+
});
|
|
462
360
|
|
|
463
361
|
if (set.debugLog || this.debugLog) {
|
|
464
362
|
console.log(' - answer: ', answer);
|
|
@@ -469,7 +367,7 @@ export class DyNTS_OAI_LLMChat_ServiceBase extends DyNTS_OAI_LLM_ServiceBase /*
|
|
|
469
367
|
|
|
470
368
|
async resolveConversationMessage(
|
|
471
369
|
set: {
|
|
472
|
-
conversation:
|
|
370
|
+
conversation: DyFM_AI_Message[],
|
|
473
371
|
issuer: string,
|
|
474
372
|
settings?: DyFM_OAI_CallSettings,
|
|
475
373
|
getFullResponse?: boolean,
|
|
@@ -488,7 +386,7 @@ export class DyNTS_OAI_LLMChat_ServiceBase extends DyNTS_OAI_LLM_ServiceBase /*
|
|
|
488
386
|
*/
|
|
489
387
|
async resolveConversation(
|
|
490
388
|
set: {
|
|
491
|
-
conversation:
|
|
389
|
+
conversation: DyFM_AI_Message[],
|
|
492
390
|
issuer: string,
|
|
493
391
|
settings?: DyFM_OAI_CallSettings,
|
|
494
392
|
getFullResponse?: boolean,
|
|
@@ -498,7 +396,7 @@ export class DyNTS_OAI_LLMChat_ServiceBase extends DyNTS_OAI_LLM_ServiceBase /*
|
|
|
498
396
|
}
|
|
499
397
|
): Promise<string | ChatCompletion> {
|
|
500
398
|
try {
|
|
501
|
-
if (set.conversation.find(message => message.role ===
|
|
399
|
+
if (set.conversation.find(message => message.role === DyFM_AI_MessageRole.system)) {
|
|
502
400
|
/* throw new DyFM_Error({
|
|
503
401
|
...this.getDefaultErrorSettings(
|
|
504
402
|
'resolveConversation',
|
|
@@ -548,19 +446,19 @@ export class DyNTS_OAI_LLMChat_ServiceBase extends DyNTS_OAI_LLM_ServiceBase /*
|
|
|
548
446
|
|
|
549
447
|
protected shortenConversation(
|
|
550
448
|
set: {
|
|
551
|
-
conversation:
|
|
449
|
+
conversation: DyFM_AI_Message[],
|
|
552
450
|
issuer: string,
|
|
553
451
|
debugLog?: boolean,
|
|
554
452
|
}
|
|
555
|
-
):
|
|
453
|
+
): DyFM_AI_Message[] {
|
|
556
454
|
try {
|
|
557
455
|
const clonedConversation = DyFM_Object.clone(set.conversation);
|
|
558
456
|
const systemMessages = clonedConversation.filter(
|
|
559
|
-
message => message.role ===
|
|
457
|
+
message => message.role === DyFM_AI_MessageRole.system
|
|
560
458
|
);
|
|
561
459
|
const systemMessagesStringLength = JSON.stringify(systemMessages).length;
|
|
562
460
|
const msgs: string[] = clonedConversation.filter(
|
|
563
|
-
message => message.role !==
|
|
461
|
+
message => message.role !== DyFM_AI_MessageRole.system
|
|
564
462
|
).map(message => message.content);
|
|
565
463
|
let stringifiedMessages = JSON.stringify(msgs);
|
|
566
464
|
|
|
@@ -622,7 +520,7 @@ export class DyNTS_OAI_LLMChat_ServiceBase extends DyNTS_OAI_LLM_ServiceBase /*
|
|
|
622
520
|
|
|
623
521
|
protected logConversation(
|
|
624
522
|
set: {
|
|
625
|
-
conversation:
|
|
523
|
+
conversation: DyFM_AI_Message[],
|
|
626
524
|
debugLog?: boolean,
|
|
627
525
|
/** this is used to readably replace too long contents to eg '...' in logs */
|
|
628
526
|
replaceThisInLog?: string,
|
|
@@ -4,10 +4,9 @@ import { DyFM_OAI_Settings, DyFM_OAI_Model, DyFM_OAI_CallSettings } from '@futde
|
|
|
4
4
|
import { DyFM_AnyError, DyFM_Error, DyFM_Error_Settings, DyFM_Log, DyFM_notNull, DyFM_Object } from '@futdevpro/fsm-dynamo';
|
|
5
5
|
|
|
6
6
|
import { DyNTS_global_settings } from '../../../../../_collections/global-settings.const';
|
|
7
|
-
import {
|
|
7
|
+
import { DyFM_AI_Message, DyFM_AI_MessageRole } from '@futdevpro/fsm-dynamo/ai';
|
|
8
8
|
import { ChatCompletion } from 'openai/resources';
|
|
9
9
|
import { ChatCompletionCreateParamsBase, ChatCompletionMessageParam } from 'openai/resources/chat/completions';
|
|
10
|
-
import { DyNTS_OAI_GPT_Message_Role } from '../_enums/oai-gpt-message-role.enum';
|
|
11
10
|
import { DyNTS_OAI_LLM_Predefined_Requests } from '../_models/interfaces/oai-llm-predefined-requests.interface';
|
|
12
11
|
import { DyNTS_OAI_global_settings } from '../_collections/oai-global-settings.const';
|
|
13
12
|
import { DyNTS_OAI_LLMDefaultPredefined_Requests } from '../_collections/oai-llm-predefined-requests.conts';
|
|
@@ -458,7 +457,7 @@ export class DyNTS_OAI_LLM_ServiceBase {
|
|
|
458
457
|
}
|
|
459
458
|
): Promise<string> {
|
|
460
459
|
return this.resolveMessage({
|
|
461
|
-
conversation: [{ role:
|
|
460
|
+
conversation: [{ role: DyFM_AI_MessageRole.user, content: set.message }],
|
|
462
461
|
issuer: set.issuer,
|
|
463
462
|
settings: set.settings,
|
|
464
463
|
getFullResponse: false,
|
|
@@ -476,7 +475,7 @@ export class DyNTS_OAI_LLM_ServiceBase {
|
|
|
476
475
|
*/
|
|
477
476
|
async resolveMessage(
|
|
478
477
|
set: {
|
|
479
|
-
conversation:
|
|
478
|
+
conversation: DyFM_AI_Message[],
|
|
480
479
|
issuer: string,
|
|
481
480
|
settings?: DyFM_OAI_CallSettings,
|
|
482
481
|
getFullResponse?: boolean
|
|
@@ -545,7 +544,7 @@ export class DyNTS_OAI_LLM_ServiceBase {
|
|
|
545
544
|
*/
|
|
546
545
|
protected getMessageCreateInput(
|
|
547
546
|
set: {
|
|
548
|
-
conversation:
|
|
547
|
+
conversation: DyFM_AI_Message[],
|
|
549
548
|
issuer: string,
|
|
550
549
|
settings?: DyFM_OAI_CallSettings
|
|
551
550
|
}
|
|
@@ -591,15 +590,15 @@ export class DyNTS_OAI_LLM_ServiceBase {
|
|
|
591
590
|
}
|
|
592
591
|
}
|
|
593
592
|
|
|
594
|
-
protected getDefaultSystemMessage(settings: DyFM_OAI_CallSettings):
|
|
593
|
+
protected getDefaultSystemMessage(settings: DyFM_OAI_CallSettings): DyFM_AI_Message {
|
|
595
594
|
return {
|
|
596
|
-
role:
|
|
595
|
+
role: DyFM_AI_MessageRole.system,
|
|
597
596
|
content: settings?.systemPrompt || this.defaultSystemPrompt,
|
|
598
597
|
};
|
|
599
598
|
}
|
|
600
599
|
|
|
601
|
-
protected validateConversation(conversation:
|
|
602
|
-
conversation.forEach((message:
|
|
600
|
+
protected validateConversation(conversation: DyFM_AI_Message[]): void {
|
|
601
|
+
conversation.forEach((message: DyFM_AI_Message, index: number) => {
|
|
603
602
|
if (!message.role) {
|
|
604
603
|
throw new DyFM_Error({
|
|
605
604
|
message: `Message has no role at index ${index}`,
|
|
@@ -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
|
|
|
@@ -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<
|