@futdevpro/nts-dynamo 1.10.77 → 1.11.1
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/_collections/atlas-default-db-options.const.d.ts +28 -0
- package/build/_collections/atlas-default-db-options.const.d.ts.map +1 -0
- package/build/_collections/atlas-default-db-options.const.js +10 -0
- package/build/_collections/atlas-default-db-options.const.js.map +1 -0
- package/build/_collections/get-environment-settings.util.d.ts +3 -0
- package/build/_collections/get-environment-settings.util.d.ts.map +1 -0
- package/build/_collections/get-environment-settings.util.js +45 -0
- package/build/_collections/get-environment-settings.util.js.map +1 -0
- package/build/_collections/global-settings.const.d.ts.map +1 -1
- package/build/_collections/global-settings.const.js +9 -4
- package/build/_collections/global-settings.const.js.map +1 -1
- package/build/_models/control-models/app-params.control-model.d.ts +6 -0
- package/build/_models/control-models/app-params.control-model.d.ts.map +1 -1
- package/build/_models/control-models/app-params.control-model.js +29 -2
- package/build/_models/control-models/app-params.control-model.js.map +1 -1
- package/build/_models/control-models/app-params.control-model.spec.js +5 -4
- package/build/_models/control-models/app-params.control-model.spec.js.map +1 -1
- package/build/_models/control-models/endpoint-params.control-model.js +1 -1
- package/build/_models/control-models/endpoint-params.control-model.js.map +1 -1
- package/build/_models/interfaces/environment-settings.interface.d.ts +35 -0
- package/build/_models/interfaces/environment-settings.interface.d.ts.map +1 -0
- package/build/_models/interfaces/environment-settings.interface.js +3 -0
- package/build/_models/interfaces/environment-settings.interface.js.map +1 -0
- package/build/_models/interfaces/global-settings.interface.d.ts +34 -2
- package/build/_models/interfaces/global-settings.interface.d.ts.map +1 -1
- package/build/_modules/custom-data/index.d.ts.map +1 -1
- package/build/_modules/custom-data/index.js +1 -0
- package/build/_modules/custom-data/index.js.map +1 -1
- package/build/_modules/discord-assistant/_collections/dias-global-settings.const.d.ts +3 -0
- package/build/_modules/discord-assistant/_collections/dias-global-settings.const.d.ts.map +1 -0
- package/build/_modules/discord-assistant/_collections/dias-global-settings.const.js +17 -0
- package/build/_modules/discord-assistant/_collections/dias-global-settings.const.js.map +1 -0
- package/build/_modules/discord-assistant/_models/dias-global-settings.interface.d.ts +18 -0
- package/build/_modules/discord-assistant/_models/dias-global-settings.interface.d.ts.map +1 -0
- package/build/_modules/discord-assistant/_models/dias-global-settings.interface.js +3 -0
- package/build/_modules/discord-assistant/_models/dias-global-settings.interface.js.map +1 -0
- package/build/_modules/discord-assistant/_models/dias-knowledge.data-model.d.ts +10 -0
- package/build/_modules/discord-assistant/_models/dias-knowledge.data-model.d.ts.map +1 -0
- package/build/_modules/discord-assistant/_models/dias-knowledge.data-model.js +41 -0
- package/build/_modules/discord-assistant/_models/dias-knowledge.data-model.js.map +1 -0
- package/build/_modules/discord-assistant/_services/dias-chunk.data-service.d.ts +14 -0
- package/build/_modules/discord-assistant/_services/dias-chunk.data-service.d.ts.map +1 -0
- package/build/_modules/discord-assistant/_services/dias-chunk.data-service.js +88 -0
- package/build/_modules/discord-assistant/_services/dias-chunk.data-service.js.map +1 -0
- package/build/_modules/discord-assistant/_services/dias-io.control-service.d.ts +10 -0
- package/build/_modules/discord-assistant/_services/dias-io.control-service.d.ts.map +1 -0
- package/build/_modules/discord-assistant/_services/dias-io.control-service.js +39 -0
- package/build/_modules/discord-assistant/_services/dias-io.control-service.js.map +1 -0
- package/build/_modules/discord-assistant/_services/dias-main.control-service.d.ts +8 -0
- package/build/_modules/discord-assistant/_services/dias-main.control-service.d.ts.map +1 -0
- package/build/_modules/discord-assistant/_services/dias-main.control-service.js +23 -0
- package/build/_modules/discord-assistant/_services/dias-main.control-service.js.map +1 -0
- package/build/_modules/discord-assistant/_services/dias.service-base.d.ts +13 -0
- package/build/_modules/discord-assistant/_services/dias.service-base.d.ts.map +1 -0
- package/build/_modules/discord-assistant/_services/dias.service-base.js +61 -0
- package/build/_modules/discord-assistant/_services/dias.service-base.js.map +1 -0
- package/build/_modules/discord-assistant/index.d.ts +10 -0
- package/build/_modules/discord-assistant/index.d.ts.map +1 -0
- package/build/_modules/discord-assistant/index.js +23 -0
- package/build/_modules/discord-assistant/index.js.map +1 -0
- package/build/_modules/discord-assistant-voiced/_services/dias-discord-bot.control-service.d.ts +4 -0
- package/build/_modules/discord-assistant-voiced/_services/dias-discord-bot.control-service.d.ts.map +1 -0
- package/build/_modules/discord-assistant-voiced/_services/dias-discord-bot.control-service.js +8 -0
- package/build/_modules/discord-assistant-voiced/_services/dias-discord-bot.control-service.js.map +1 -0
- package/build/_modules/discord-assistant-voiced/index.d.ts +3 -0
- package/build/_modules/discord-assistant-voiced/index.d.ts.map +1 -0
- package/build/_modules/discord-assistant-voiced/index.js +26 -0
- package/build/_modules/discord-assistant-voiced/index.js.map +1 -0
- package/build/_modules/discord-bot/_collections/dibo-default-commands.const.d.ts +3 -0
- package/build/_modules/discord-bot/_collections/dibo-default-commands.const.d.ts.map +1 -0
- package/build/_modules/discord-bot/_collections/dibo-default-commands.const.js +13 -0
- package/build/_modules/discord-bot/_collections/dibo-default-commands.const.js.map +1 -0
- package/build/_modules/discord-bot/_collections/dibo-global-settings.conts.d.ts +3 -0
- package/build/_modules/discord-bot/_collections/dibo-global-settings.conts.d.ts.map +1 -0
- package/build/_modules/discord-bot/_collections/dibo-global-settings.conts.js +44 -0
- package/build/_modules/discord-bot/_collections/dibo-global-settings.conts.js.map +1 -0
- package/build/_modules/discord-bot/_collections/dibo-operations.util.d.ts +22 -0
- package/build/_modules/discord-bot/_collections/dibo-operations.util.d.ts.map +1 -0
- package/build/_modules/discord-bot/_collections/dibo-operations.util.js +261 -0
- package/build/_modules/discord-bot/_collections/dibo-operations.util.js.map +1 -0
- package/build/_modules/discord-bot/_models/dibo-command.interface.d.ts +8 -0
- package/build/_modules/discord-bot/_models/dibo-command.interface.d.ts.map +1 -0
- package/build/_modules/discord-bot/_models/dibo-command.interface.js +3 -0
- package/build/_modules/discord-bot/_models/dibo-command.interface.js.map +1 -0
- package/build/_modules/discord-bot/_models/dibo-last-mention-date.inteface.d.ts +7 -0
- package/build/_modules/discord-bot/_models/dibo-last-mention-date.inteface.d.ts.map +1 -0
- package/build/_modules/discord-bot/_models/dibo-last-mention-date.inteface.js +3 -0
- package/build/_modules/discord-bot/_models/dibo-last-mention-date.inteface.js.map +1 -0
- package/build/_modules/discord-bot/_models/dibo-last-message-date.interface.d.ts +6 -0
- package/build/_modules/discord-bot/_models/dibo-last-message-date.interface.d.ts.map +1 -0
- package/build/_modules/discord-bot/_models/dibo-last-message-date.interface.js +3 -0
- package/build/_modules/discord-bot/_models/dibo-last-message-date.interface.js.map +1 -0
- package/build/_modules/discord-bot/_models/global-bot-log-settings.interface.d.ts +88 -0
- package/build/_modules/discord-bot/_models/global-bot-log-settings.interface.d.ts.map +1 -0
- package/build/_modules/discord-bot/_models/global-bot-log-settings.interface.js +3 -0
- package/build/_modules/discord-bot/_models/global-bot-log-settings.interface.js.map +1 -0
- package/build/_modules/discord-bot/_services/dibo-commands.control-service.d.ts +12 -0
- package/build/_modules/discord-bot/_services/dibo-commands.control-service.d.ts.map +1 -0
- package/build/_modules/discord-bot/_services/dibo-commands.control-service.js +72 -0
- package/build/_modules/discord-bot/_services/dibo-commands.control-service.js.map +1 -0
- package/build/_modules/discord-bot/_services/dibo-io.control-service.d.ts +19 -0
- package/build/_modules/discord-bot/_services/dibo-io.control-service.d.ts.map +1 -0
- package/build/_modules/discord-bot/_services/dibo-io.control-service.js +176 -0
- package/build/_modules/discord-bot/_services/dibo-io.control-service.js.map +1 -0
- package/build/_modules/discord-bot/_services/dibo-main.control-service.d.ts +85 -0
- package/build/_modules/discord-bot/_services/dibo-main.control-service.d.ts.map +1 -0
- package/build/_modules/discord-bot/_services/dibo-main.control-service.js +228 -0
- package/build/_modules/discord-bot/_services/dibo-main.control-service.js.map +1 -0
- package/build/_modules/discord-bot/_services/dibo-routines.control-service.d.ts +13 -0
- package/build/_modules/discord-bot/_services/dibo-routines.control-service.d.ts.map +1 -0
- package/build/_modules/discord-bot/_services/dibo-routines.control-service.js +38 -0
- package/build/_modules/discord-bot/_services/dibo-routines.control-service.js.map +1 -0
- package/build/_modules/discord-bot/index.d.ts +12 -0
- package/build/_modules/discord-bot/index.d.ts.map +1 -0
- package/build/_modules/discord-bot/index.js +30 -0
- package/build/_modules/discord-bot/index.js.map +1 -0
- package/build/_modules/oauth2/index.d.ts.map +1 -1
- package/build/_modules/oauth2/index.js +7 -0
- package/build/_modules/oauth2/index.js.map +1 -1
- package/build/_modules/open-ai/_collections/oai-chunking.util.d.ts +74 -0
- package/build/_modules/open-ai/_collections/oai-chunking.util.d.ts.map +1 -0
- package/build/_modules/open-ai/_collections/oai-chunking.util.js +385 -0
- package/build/_modules/open-ai/_collections/oai-chunking.util.js.map +1 -0
- package/build/_modules/open-ai/_collections/oai-document.util.d.ts +4 -0
- package/build/_modules/open-ai/_collections/oai-document.util.d.ts.map +1 -0
- package/build/_modules/open-ai/_collections/oai-document.util.js +12 -0
- package/build/_modules/open-ai/_collections/oai-document.util.js.map +1 -0
- package/build/_modules/open-ai/_collections/oai-global-settings.const.d.ts +3 -0
- package/build/_modules/open-ai/_collections/oai-global-settings.const.d.ts.map +1 -0
- package/build/_modules/open-ai/_collections/oai-global-settings.const.js +9 -0
- package/build/_modules/open-ai/_collections/oai-global-settings.const.js.map +1 -0
- package/build/_modules/open-ai/_collections/oai-llm-predefined-requests-hu.conts.d.ts +3 -0
- package/build/_modules/open-ai/_collections/oai-llm-predefined-requests-hu.conts.d.ts.map +1 -0
- package/build/_modules/open-ai/_collections/oai-llm-predefined-requests-hu.conts.js +75 -0
- package/build/_modules/open-ai/_collections/oai-llm-predefined-requests-hu.conts.js.map +1 -0
- package/build/_modules/open-ai/_collections/oai-llm-predefined-requests.conts.d.ts +3 -0
- package/build/_modules/open-ai/_collections/oai-llm-predefined-requests.conts.d.ts.map +1 -0
- package/build/_modules/open-ai/_collections/oai-llm-predefined-requests.conts.js +68 -0
- package/build/_modules/open-ai/_collections/oai-llm-predefined-requests.conts.js.map +1 -0
- package/build/_modules/open-ai/_enums/oai-compare-result-type.enum.d.ts +6 -0
- package/build/_modules/open-ai/_enums/oai-compare-result-type.enum.d.ts.map +1 -0
- package/build/_modules/open-ai/_enums/oai-compare-result-type.enum.js +10 -0
- package/build/_modules/open-ai/_enums/oai-compare-result-type.enum.js.map +1 -0
- package/build/_modules/open-ai/_enums/oai-gpt-message-role.enum.d.ts +18 -0
- package/build/_modules/open-ai/_enums/oai-gpt-message-role.enum.d.ts.map +1 -0
- package/build/_modules/open-ai/_enums/oai-gpt-message-role.enum.js +40 -0
- package/build/_modules/open-ai/_enums/oai-gpt-message-role.enum.js.map +1 -0
- package/build/_modules/open-ai/_models/interfaces/oai-chunk-compare-result.interface.d.ts +7 -0
- package/build/_modules/open-ai/_models/interfaces/oai-chunk-compare-result.interface.d.ts.map +1 -0
- package/build/_modules/open-ai/_models/interfaces/oai-chunk-compare-result.interface.js +3 -0
- package/build/_modules/open-ai/_models/interfaces/oai-chunk-compare-result.interface.js.map +1 -0
- package/build/_modules/open-ai/_models/interfaces/oai-document-page.interface.d.ts +14 -0
- package/build/_modules/open-ai/_models/interfaces/oai-document-page.interface.d.ts.map +1 -0
- package/build/_modules/open-ai/_models/interfaces/oai-document-page.interface.js +3 -0
- package/build/_modules/open-ai/_models/interfaces/oai-document-page.interface.js.map +1 -0
- package/build/_modules/open-ai/_models/interfaces/oai-global-settings.interface.d.ts +6 -0
- package/build/_modules/open-ai/_models/interfaces/oai-global-settings.interface.d.ts.map +1 -0
- package/build/_modules/open-ai/_models/interfaces/oai-global-settings.interface.js +3 -0
- package/build/_modules/open-ai/_models/interfaces/oai-global-settings.interface.js.map +1 -0
- package/build/_modules/open-ai/_models/interfaces/oai-gpt-message.interface.d.ts +6 -0
- package/build/_modules/open-ai/_models/interfaces/oai-gpt-message.interface.d.ts.map +1 -0
- package/build/_modules/open-ai/_models/interfaces/oai-gpt-message.interface.js +3 -0
- package/build/_modules/open-ai/_models/interfaces/oai-gpt-message.interface.js.map +1 -0
- package/build/_modules/open-ai/_models/interfaces/oai-llm-predefined-requests.interface.d.ts +52 -0
- package/build/_modules/open-ai/_models/interfaces/oai-llm-predefined-requests.interface.d.ts.map +1 -0
- package/build/_modules/open-ai/_models/interfaces/oai-llm-predefined-requests.interface.js +3 -0
- package/build/_modules/open-ai/_models/interfaces/oai-llm-predefined-requests.interface.js.map +1 -0
- package/build/_modules/open-ai/_models/interfaces/oai-page-compare-result.interface.d.ts +13 -0
- package/build/_modules/open-ai/_models/interfaces/oai-page-compare-result.interface.d.ts.map +1 -0
- package/build/_modules/open-ai/_models/interfaces/oai-page-compare-result.interface.js +3 -0
- package/build/_modules/open-ai/_models/interfaces/oai-page-compare-result.interface.js.map +1 -0
- package/build/_modules/open-ai/_models/oai-doc-chunk.data-model.d.ts +18 -0
- package/build/_modules/open-ai/_models/oai-doc-chunk.data-model.d.ts.map +1 -0
- package/build/_modules/open-ai/_models/oai-doc-chunk.data-model.js +80 -0
- package/build/_modules/open-ai/_models/oai-doc-chunk.data-model.js.map +1 -0
- package/build/_modules/open-ai/_services/oai-chunk.service-base.d.ts +13 -0
- package/build/_modules/open-ai/_services/oai-chunk.service-base.d.ts.map +1 -0
- package/build/_modules/open-ai/_services/oai-chunk.service-base.js +170 -0
- package/build/_modules/open-ai/_services/oai-chunk.service-base.js.map +1 -0
- package/build/_modules/open-ai/_services/{embedding.control-service.d.ts → oai-embedding.control-service.d.ts} +3 -3
- package/build/_modules/open-ai/_services/oai-embedding.control-service.d.ts.map +1 -0
- package/build/_modules/open-ai/_services/{embedding.control-service.js → oai-embedding.control-service.js} +5 -5
- package/build/_modules/open-ai/_services/oai-embedding.control-service.js.map +1 -0
- package/build/_modules/open-ai/_services/oai-llm-chat.service-base.d.ts +161 -0
- package/build/_modules/open-ai/_services/oai-llm-chat.service-base.d.ts.map +1 -0
- package/build/_modules/open-ai/_services/oai-llm-chat.service-base.js +332 -0
- package/build/_modules/open-ai/_services/oai-llm-chat.service-base.js.map +1 -0
- package/build/_modules/open-ai/_services/oai-llm.service-base.d.ts +231 -0
- package/build/_modules/open-ai/_services/oai-llm.service-base.d.ts.map +1 -0
- package/build/_modules/open-ai/_services/oai-llm.service-base.js +438 -0
- package/build/_modules/open-ai/_services/oai-llm.service-base.js.map +1 -0
- package/build/_modules/open-ai/_services/{vector-data.service.d.ts → oai-vector-data.service.d.ts} +4 -4
- package/build/_modules/open-ai/_services/oai-vector-data.service.d.ts.map +1 -0
- package/build/_modules/open-ai/_services/{vector-data.service.js → oai-vector-data.service.js} +27 -7
- package/build/_modules/open-ai/_services/oai-vector-data.service.js.map +1 -0
- package/build/_modules/open-ai/index.d.ts +18 -4
- package/build/_modules/open-ai/index.d.ts.map +1 -1
- package/build/_modules/open-ai/index.js +35 -4
- package/build/_modules/open-ai/index.js.map +1 -1
- package/build/_modules/server/index.d.ts +1 -1
- package/build/_modules/server/index.d.ts.map +1 -1
- package/build/_modules/server/index.js +16 -2
- package/build/_modules/server/index.js.map +1 -1
- package/build/_modules/server/server-status/server-status.controller.d.ts.map +1 -1
- package/build/_modules/server/server-status/server-status.controller.js +10 -0
- package/build/_modules/server/server-status/server-status.controller.js.map +1 -1
- package/build/_modules/socket/index.d.ts.map +1 -1
- package/build/_modules/socket/index.js +18 -0
- package/build/_modules/socket/index.js.map +1 -1
- package/build/_modules/test/index.d.ts.map +1 -1
- package/build/_modules/test/index.js +5 -0
- package/build/_modules/test/index.js.map +1 -1
- package/build/_modules/usage/index.d.ts.map +1 -1
- package/build/_modules/usage/index.js +5 -0
- package/build/_modules/usage/index.js.map +1 -1
- package/build/_services/server/app.server.js +1 -2
- package/build/_services/server/app.server.js.map +1 -1
- package/build/index.d.ts +3 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js +26 -1
- package/build/index.js.map +1 -1
- package/package.json +40 -10
- package/src/_collections/atlas-default-db-options.const.ts +10 -0
- package/src/_collections/get-environment-settings.util.ts +49 -0
- package/src/_collections/global-settings.const.ts +15 -4
- package/src/_collections/sample.env +21 -0
- package/src/_models/control-models/app-params.control-model.spec.ts +5 -4
- package/src/_models/control-models/app-params.control-model.ts +31 -2
- package/src/_models/control-models/endpoint-params.control-model.ts +1 -1
- package/src/_models/interfaces/environment-settings.interface.ts +59 -0
- package/src/_models/interfaces/global-settings.interface.ts +41 -1
- package/src/_modules/custom-data/index.ts +3 -0
- package/src/_modules/discord-assistant/_collections/dias-global-settings.const.ts +19 -0
- package/src/_modules/discord-assistant/_models/dias-global-settings.interface.ts +20 -0
- package/src/_modules/discord-assistant/_models/dias-knowledge.data-model.ts +46 -0
- package/src/_modules/discord-assistant/_services/dias-chunk.data-service.ts +152 -0
- package/src/_modules/discord-assistant/_services/dias-io.control-service.ts +59 -0
- package/src/_modules/discord-assistant/_services/dias-main.control-service.ts +28 -0
- package/src/_modules/discord-assistant/_services/dias.service-base.ts +81 -0
- package/src/_modules/discord-assistant/index.ts +36 -0
- package/src/_modules/discord-assistant-voiced/_services/dias-discord-bot.control-service.ts +11 -0
- package/src/_modules/discord-assistant-voiced/index.ts +36 -0
- package/src/_modules/discord-bot/_collections/dibo-default-commands.const.ts +17 -0
- package/src/_modules/discord-bot/_collections/dibo-global-settings.conts.ts +56 -0
- package/src/_modules/discord-bot/_collections/dibo-operations.util.ts +372 -0
- package/src/_modules/discord-bot/_models/dibo-command.interface.ts +12 -0
- package/src/_modules/discord-bot/_models/dibo-last-mention-date.inteface.ts +8 -0
- package/src/_modules/discord-bot/_models/dibo-last-message-date.interface.ts +6 -0
- package/src/_modules/discord-bot/_models/global-bot-log-settings.interface.ts +98 -0
- package/src/_modules/discord-bot/_services/dibo-commands.control-service.ts +120 -0
- package/src/_modules/discord-bot/_services/dibo-io.control-service.ts +245 -0
- package/src/_modules/discord-bot/_services/dibo-main.control-service.ts +304 -0
- package/src/_modules/discord-bot/_services/dibo-routines.control-service.ts +60 -0
- package/src/_modules/discord-bot/index.ts +36 -0
- package/src/_modules/oauth2/index.ts +8 -0
- package/src/_modules/open-ai/_collections/oai-chunking.util.ts +496 -0
- package/src/_modules/open-ai/_collections/oai-document.util.ts +10 -0
- package/src/_modules/open-ai/_collections/oai-global-settings.const.ts +9 -0
- package/src/_modules/open-ai/_collections/oai-llm-predefined-requests-hu.conts.ts +83 -0
- package/src/_modules/open-ai/_collections/oai-llm-predefined-requests.conts.ts +76 -0
- package/src/_modules/open-ai/_enums/oai-compare-result-type.enum.ts +7 -0
- package/src/_modules/open-ai/_enums/oai-gpt-message-role.enum.ts +45 -0
- package/src/_modules/open-ai/_models/interfaces/oai-chunk-compare-result.interface.ts +10 -0
- package/src/_modules/open-ai/_models/interfaces/oai-document-page.interface.ts +20 -0
- package/src/_modules/open-ai/_models/interfaces/oai-global-settings.interface.ts +8 -0
- package/src/_modules/open-ai/_models/interfaces/oai-gpt-message.interface.ts +7 -0
- package/src/_modules/open-ai/_models/interfaces/oai-llm-predefined-requests.interface.ts +57 -0
- package/src/_modules/open-ai/_models/interfaces/oai-page-compare-result.interface.ts +18 -0
- package/src/_modules/open-ai/_models/oai-doc-chunk.data-model.ts +92 -0
- package/src/_modules/open-ai/_services/oai-chunk.service-base.ts +214 -0
- package/src/_modules/open-ai/_services/{embedding.control-service.ts → oai-embedding.control-service.ts} +2 -2
- package/src/_modules/open-ai/_services/oai-llm-chat.service-base.ts +609 -0
- package/src/_modules/open-ai/_services/oai-llm.service-base.ts +648 -0
- package/src/_modules/open-ai/_services/{vector-data.service.ts → oai-vector-data.service.ts} +32 -5
- package/src/_modules/open-ai/index.ts +42 -4
- package/src/_modules/server/index.ts +18 -2
- package/src/_modules/server/server-status/server-status.controller.ts +13 -0
- package/src/_modules/socket/index.ts +23 -0
- package/src/_modules/test/index.ts +8 -0
- package/src/_modules/usage/index.ts +8 -0
- package/src/_services/server/app.server.ts +1 -1
- package/src/index.ts +28 -1
- package/build/_modules/open-ai/_services/embedding.control-service.d.ts.map +0 -1
- package/build/_modules/open-ai/_services/embedding.control-service.js.map +0 -1
- package/build/_modules/open-ai/_services/gpt.service-base.d.ts +0 -98
- package/build/_modules/open-ai/_services/gpt.service-base.d.ts.map +0 -1
- package/build/_modules/open-ai/_services/gpt.service-base.js +0 -284
- package/build/_modules/open-ai/_services/gpt.service-base.js.map +0 -1
- package/build/_modules/open-ai/_services/open-ai.service-base.d.ts +0 -21
- package/build/_modules/open-ai/_services/open-ai.service-base.d.ts.map +0 -1
- package/build/_modules/open-ai/_services/open-ai.service-base.js +0 -50
- package/build/_modules/open-ai/_services/open-ai.service-base.js.map +0 -1
- package/build/_modules/open-ai/_services/vector-data.service.d.ts.map +0 -1
- package/build/_modules/open-ai/_services/vector-data.service.js.map +0 -1
- package/build/_services/server/env-set.d.ts +0 -2
- package/build/_services/server/env-set.d.ts.map +0 -1
- package/build/_services/server/env-set.js +0 -20
- package/build/_services/server/env-set.js.map +0 -1
- package/src/_modules/open-ai/_services/gpt.service-base.ts +0 -438
- package/src/_modules/open-ai/_services/open-ai.service-base.ts +0 -69
- package/src/_services/server/env-set.ts +0 -21
|
@@ -0,0 +1,496 @@
|
|
|
1
|
+
import { DyFM_AnyError, DyFM_Error, DyFM_Error_Settings, DyFM_Log } from '@futdevpro/fsm-dynamo';
|
|
2
|
+
import { DyNTS_OAI_DocChunk } from '../_models/oai-doc-chunk.data-model';
|
|
3
|
+
import { DyNTS_OAI_DocumentPage } from '../_models/interfaces/oai-document-page.interface';
|
|
4
|
+
import { DyNTS_global_settings } from '../../../_collections/global-settings.const';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* ClickUp dokumentum chunking szolgáltatás
|
|
8
|
+
* @author AI
|
|
9
|
+
* @description ClickUp dokumentumok intelligens chunking-ja a leghosszabb lehetséges chunk-ok létrehozásához
|
|
10
|
+
*/
|
|
11
|
+
export class DyNTS_OAI_Chunking_Util {
|
|
12
|
+
|
|
13
|
+
protected static readonly defaultErrorUserMsg: string =
|
|
14
|
+
`We encountered an unhandled Control Service Error, ` +
|
|
15
|
+
`\nplease contact the responsible development team.`;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Markdown tartalom chunking-ja a leghosszabb lehetséges chunk-ok létrehozásához
|
|
19
|
+
* @param page - ClickUp dokumentum oldal
|
|
20
|
+
* @param issuer - Kérés kezdeményezője
|
|
21
|
+
* @returns Promise<CU_DocChunk[]> - Létrehozott chunk-ok listája
|
|
22
|
+
*/
|
|
23
|
+
static async chunkMdContent(
|
|
24
|
+
page: DyNTS_OAI_DocumentPage,
|
|
25
|
+
issuer: string
|
|
26
|
+
): Promise<DyNTS_OAI_DocChunk[]> {
|
|
27
|
+
try {
|
|
28
|
+
if (page.content.includes('#####')) {
|
|
29
|
+
DyFM_Log.warn('lvl5+ headers are not supported yet for page: ' + page.name);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/* DyFM_Log.log(`Chunking page: ${page.name}\n\n`, JSON.stringify(page.content, null, 2)); */
|
|
33
|
+
|
|
34
|
+
let leftovers = page.content;
|
|
35
|
+
const maxChunkSize = DyNTS_global_settings.docChunking.maxChunkSize;
|
|
36
|
+
const maxChunkCount = DyNTS_global_settings.docChunking.maxChunkCount;
|
|
37
|
+
const chunks: DyNTS_OAI_DocChunk[] = [];
|
|
38
|
+
let chunkIndex = 0;
|
|
39
|
+
let currentPosition = 0; // Track current position in original content
|
|
40
|
+
|
|
41
|
+
// Parse all headers to build hierarchy
|
|
42
|
+
const headerHierarchy = this.parseHeaderHierarchy(leftovers);
|
|
43
|
+
|
|
44
|
+
// Debug: Log parsed headers
|
|
45
|
+
/* console.log('\n=== Parsed Header Hierarchy ===');
|
|
46
|
+
headerHierarchy.forEach((header, index) => {
|
|
47
|
+
console.log(`${index}: Level ${header.level} at position ${header.index}: "${header.header}"`);
|
|
48
|
+
});
|
|
49
|
+
console.log('=== End Header Hierarchy ===\n'); */
|
|
50
|
+
|
|
51
|
+
// Track the last headers of each level as we progress
|
|
52
|
+
const lastHeaders: Map<number, string> = new Map();
|
|
53
|
+
|
|
54
|
+
while (leftovers.length > 0 && chunkIndex < maxChunkCount) {
|
|
55
|
+
// Ha a teljes tartalom belefér egy chunk-ba, adjuk vissza az egészet
|
|
56
|
+
if (leftovers.length <= maxChunkSize) {
|
|
57
|
+
const chunkContent = leftovers.trim();
|
|
58
|
+
if (chunkContent.length > 0) {
|
|
59
|
+
const chunkWithHierarchy = this.addHeaderHierarchy(chunkContent, headerHierarchy, currentPosition, currentPosition + leftovers.length, lastHeaders);
|
|
60
|
+
const chunkPath = this.buildChunkPath(page.name, headerHierarchy, currentPosition, currentPosition + leftovers.length, lastHeaders);
|
|
61
|
+
|
|
62
|
+
const chunk = new DyNTS_OAI_DocChunk({
|
|
63
|
+
workspaceId: page.workspaceId,
|
|
64
|
+
documentId: page.docId,
|
|
65
|
+
documentPageId: page._id,
|
|
66
|
+
|
|
67
|
+
documentName: page.name,
|
|
68
|
+
documentPath: page.path,
|
|
69
|
+
|
|
70
|
+
chunkIndex: chunkIndex,
|
|
71
|
+
chunkPath: chunkPath,
|
|
72
|
+
|
|
73
|
+
chunkOriginalContent: chunkContent,
|
|
74
|
+
});
|
|
75
|
+
chunk.chunkParentedContent = this.assembleChunkWithHeaders(chunk, issuer);
|
|
76
|
+
chunks.push(chunk);
|
|
77
|
+
}
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Keressük meg a legjobb break point-ot a maxChunkSize-n belül
|
|
82
|
+
const breakPoint = this.findBestBreakPoint(leftovers, maxChunkSize);
|
|
83
|
+
|
|
84
|
+
if (breakPoint.index > 0) {
|
|
85
|
+
// Ha találtunk break point-ot, vágjunk a marker előtt
|
|
86
|
+
const chunkContent = leftovers.substring(0, breakPoint.index).trim();
|
|
87
|
+
|
|
88
|
+
// Debug: Log current state
|
|
89
|
+
/* console.log(`\n--- Creating chunk ${chunkIndex} ---`);
|
|
90
|
+
console.log(`Current position: ${currentPosition}`);
|
|
91
|
+
console.log(`Last headers:`, Object.fromEntries(lastHeaders));
|
|
92
|
+
console.log(`Chunk content preview:`, chunkContent.substring(0, 100) + '...'); */
|
|
93
|
+
|
|
94
|
+
// Check if chunk has headers
|
|
95
|
+
const hasHeaders = headerHierarchy.some(header =>
|
|
96
|
+
header.index >= currentPosition && header.index < currentPosition + breakPoint.index
|
|
97
|
+
);
|
|
98
|
+
/* console.log(`Chunk has headers: ${hasHeaders}`); */
|
|
99
|
+
|
|
100
|
+
const chunkWithHierarchy = this.addHeaderHierarchy(chunkContent, headerHierarchy, currentPosition, currentPosition + breakPoint.index, lastHeaders);
|
|
101
|
+
const chunkPath = this.buildChunkPath(page.name, headerHierarchy, currentPosition, currentPosition + breakPoint.index, lastHeaders);
|
|
102
|
+
|
|
103
|
+
/* console.log(`Chunk path:`, chunkPath);
|
|
104
|
+
console.log(`Chunk with hierarchy preview:`, chunkWithHierarchy.substring(0, 100) + '...'); */
|
|
105
|
+
|
|
106
|
+
const chunk = new DyNTS_OAI_DocChunk({
|
|
107
|
+
workspaceId: page.workspaceId,
|
|
108
|
+
documentId: page.docId,
|
|
109
|
+
documentPageId: page._id,
|
|
110
|
+
|
|
111
|
+
documentName: page.name,
|
|
112
|
+
documentPath: page.path,
|
|
113
|
+
|
|
114
|
+
chunkIndex: chunkIndex,
|
|
115
|
+
chunkPath: chunkPath,
|
|
116
|
+
|
|
117
|
+
chunkOriginalContent: chunkContent,
|
|
118
|
+
});
|
|
119
|
+
chunk.chunkParentedContent = this.assembleChunkWithHeaders(chunk, issuer);
|
|
120
|
+
chunks.push(chunk);
|
|
121
|
+
chunkIndex++;
|
|
122
|
+
currentPosition += breakPoint.index;
|
|
123
|
+
leftovers = leftovers.substring(breakPoint.index);
|
|
124
|
+
|
|
125
|
+
// Update last headers after creating the chunk
|
|
126
|
+
this.updateLastHeaders(headerHierarchy, currentPosition, lastHeaders);
|
|
127
|
+
|
|
128
|
+
/* console.log(`Updated last headers:`, Object.fromEntries(lastHeaders));
|
|
129
|
+
console.log(`--- End chunk ${chunkIndex - 1} ---\n`); */
|
|
130
|
+
} else {
|
|
131
|
+
// Ha nem találtunk break point-ot, használjuk a maxChunkSize-t
|
|
132
|
+
const chunkContent = leftovers.substring(0, maxChunkSize).trim();
|
|
133
|
+
const chunkWithHierarchy = this.addHeaderHierarchy(chunkContent, headerHierarchy, currentPosition, currentPosition + maxChunkSize, lastHeaders);
|
|
134
|
+
const chunkPath = this.buildChunkPath(page.name, headerHierarchy, currentPosition, currentPosition + maxChunkSize, lastHeaders);
|
|
135
|
+
|
|
136
|
+
const chunk = new DyNTS_OAI_DocChunk({
|
|
137
|
+
workspaceId: page.workspaceId,
|
|
138
|
+
documentId: page.docId,
|
|
139
|
+
documentPageId: page._id,
|
|
140
|
+
|
|
141
|
+
documentName: page.name,
|
|
142
|
+
documentPath: page.path,
|
|
143
|
+
|
|
144
|
+
chunkIndex: chunkIndex,
|
|
145
|
+
chunkPath: chunkPath,
|
|
146
|
+
|
|
147
|
+
chunkOriginalContent: chunkContent,
|
|
148
|
+
});
|
|
149
|
+
chunk.chunkParentedContent = this.assembleChunkWithHeaders(chunk, issuer);
|
|
150
|
+
chunks.push(chunk);
|
|
151
|
+
chunkIndex++;
|
|
152
|
+
currentPosition += maxChunkSize;
|
|
153
|
+
leftovers = leftovers.substring(maxChunkSize);
|
|
154
|
+
|
|
155
|
+
// Update last headers after creating the chunk
|
|
156
|
+
this.updateLastHeaders(headerHierarchy, currentPosition, lastHeaders);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// Safety check to prevent infinite loops
|
|
160
|
+
if (leftovers.length > 0 && leftovers.length >= page.content.length) {
|
|
161
|
+
throw new DyFM_Error({
|
|
162
|
+
...this.getDefaultErrorSettings(
|
|
163
|
+
'chunkMdContent',
|
|
164
|
+
new Error('Infinite loop detected in chunking'),
|
|
165
|
+
issuer
|
|
166
|
+
),
|
|
167
|
+
errorCode: 'CCAP-CUC-CC1',
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// Log warning if we hit the chunk count limit
|
|
173
|
+
if (chunkIndex >= maxChunkCount && leftovers.length > 0) {
|
|
174
|
+
DyFM_Log.warn(
|
|
175
|
+
`⚠️ Reached maximum chunk count (${maxChunkCount}). Remaining content: ${leftovers.length} characters`,
|
|
176
|
+
{
|
|
177
|
+
pageName: page.name,
|
|
178
|
+
pageSize: page.content.length,
|
|
179
|
+
}
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/* DyFM_Log.info(`✅ Created ${chunks.length} chunks`); */
|
|
184
|
+
return chunks;
|
|
185
|
+
} catch (error) {
|
|
186
|
+
throw new DyFM_Error({
|
|
187
|
+
...this.getDefaultErrorSettings('chunkMdContent', error, issuer),
|
|
188
|
+
errorCode: 'CCAP-CUC-CP0',
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
private static assembleChunkWithHeaders(chunk: DyNTS_OAI_DocChunk, issuer: string): string {
|
|
194
|
+
try {
|
|
195
|
+
const fileHeaders = chunk.documentPath.map(
|
|
196
|
+
(header, index) => `${'>'.repeat(index + 1)} **${header}**`
|
|
197
|
+
).join('\n');
|
|
198
|
+
const headers = chunk.chunkPath.filter(
|
|
199
|
+
path => !chunk.chunkOriginalContent.includes(path)
|
|
200
|
+
).join('\n');
|
|
201
|
+
return `${fileHeaders}\n\n${headers}\n\n${chunk.chunkOriginalContent}`;
|
|
202
|
+
} catch (error) {
|
|
203
|
+
throw new DyFM_Error({
|
|
204
|
+
...this.getDefaultErrorSettings('assembleChunkWithHeaders', error, issuer),
|
|
205
|
+
errorCode: 'CCAP-CUC-ACH0',
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
static reassembleChunksToContent(
|
|
211
|
+
chunks: DyNTS_OAI_DocChunk[],
|
|
212
|
+
issuer: string
|
|
213
|
+
): string {
|
|
214
|
+
try {
|
|
215
|
+
let pageContent = '';
|
|
216
|
+
|
|
217
|
+
for (const chunk of chunks) {
|
|
218
|
+
if (!chunk) {
|
|
219
|
+
throw new DyFM_Error({
|
|
220
|
+
...this.getDefaultErrorSettings(
|
|
221
|
+
'reassembleChunksToContent',
|
|
222
|
+
new Error('Chunk is null, you`ve passing null chunks to the function'),
|
|
223
|
+
issuer
|
|
224
|
+
),
|
|
225
|
+
errorCode: 'CCAP-CUC-RCTC0',
|
|
226
|
+
|
|
227
|
+
additionalContent: {
|
|
228
|
+
chunks: chunks,
|
|
229
|
+
},
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
pageContent += chunk.chunkOriginalContent;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
return pageContent;
|
|
237
|
+
} catch (error) {
|
|
238
|
+
throw new DyFM_Error({
|
|
239
|
+
...this.getDefaultErrorSettings('reassembleChunks', error, issuer),
|
|
240
|
+
errorCode: 'CCAP-CUC-RC0',
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Unified break points configuration
|
|
247
|
+
*/
|
|
248
|
+
private static readonly breakPoints = [
|
|
249
|
+
{ pattern: '\n# ', level: 1, includeLength: 0 }, // Header 1 - cut before marker
|
|
250
|
+
{ pattern: '\n## ', level: 2, includeLength: 0 }, // Header 2 - cut before marker
|
|
251
|
+
{ pattern: '\n### ', level: 3, includeLength: 0 }, // Header 3 - cut before marker
|
|
252
|
+
{ pattern: '\n#### ', level: 4, includeLength: 0 }, // Header 4 - cut before marker
|
|
253
|
+
{ pattern: '\n\n', level: 0, includeLength: 2 }, // Double line break - include
|
|
254
|
+
{ pattern: '\n', level: 0, includeLength: 1 }, // Single line break - include
|
|
255
|
+
{ pattern: '. ', level: 0, includeLength: 2 }, // Sentence end - include
|
|
256
|
+
{ pattern: ' ', level: 0, includeLength: 1 }, // Word break - include
|
|
257
|
+
];
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Find the best break point within the chunk size
|
|
261
|
+
* @param text - The text to search in
|
|
262
|
+
* @param maxIndex - Maximum index to search up to
|
|
263
|
+
* @returns The best break point or null if not found
|
|
264
|
+
*/
|
|
265
|
+
private static findBestBreakPoint(text: string, maxIndex: number): { index: number, level: number } | null {
|
|
266
|
+
for (const breakPoint of this.breakPoints) {
|
|
267
|
+
const index = this.findLastOccurrence(text, breakPoint.pattern, maxIndex);
|
|
268
|
+
if (index > 0) {
|
|
269
|
+
return {
|
|
270
|
+
index: index + breakPoint.includeLength,
|
|
271
|
+
level: breakPoint.level
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
return null;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* Parse header hierarchy from the content
|
|
280
|
+
* @param content - The content to parse
|
|
281
|
+
* @returns Array of header positions and levels
|
|
282
|
+
*/
|
|
283
|
+
private static parseHeaderHierarchy(content: string): Array<{index: number, level: number, header: string}> {
|
|
284
|
+
const headers: Array<{index: number, level: number, header: string}> = [];
|
|
285
|
+
const lines = content.split('\n');
|
|
286
|
+
let currentIndex = 0;
|
|
287
|
+
|
|
288
|
+
for (const line of lines) {
|
|
289
|
+
const trimmedLine = line.trim();
|
|
290
|
+
|
|
291
|
+
// Check if line starts with # and determine the level
|
|
292
|
+
if (trimmedLine.startsWith('#')) {
|
|
293
|
+
const match = trimmedLine.match(/^(#+)\s+(.+)$/);
|
|
294
|
+
if (match) {
|
|
295
|
+
const level = match[1].length; // Count the number of # symbols
|
|
296
|
+
const headerText = trimmedLine;
|
|
297
|
+
|
|
298
|
+
if (level >= 1 && level <= 4) { // Only support levels 1-4
|
|
299
|
+
headers.push({
|
|
300
|
+
index: currentIndex,
|
|
301
|
+
level: level,
|
|
302
|
+
header: headerText
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
currentIndex += line.length + 1; // +1 for the newline
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
return headers;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* Update the last headers map based on current position
|
|
316
|
+
* @param headerHierarchy - The parsed header hierarchy
|
|
317
|
+
* @param currentPosition - Current position in content
|
|
318
|
+
* @param lastHeaders - Map to store last headers of each level
|
|
319
|
+
*/
|
|
320
|
+
private static updateLastHeaders(
|
|
321
|
+
headerHierarchy: Array<{index: number, level: number, header: string}>,
|
|
322
|
+
currentPosition: number,
|
|
323
|
+
lastHeaders: Map<number, string>
|
|
324
|
+
): void {
|
|
325
|
+
// Find all headers that come before current position (not including current position)
|
|
326
|
+
for (const header of headerHierarchy) {
|
|
327
|
+
if (header.index < currentPosition) {
|
|
328
|
+
// Set this header as the last header for its level
|
|
329
|
+
lastHeaders.set(header.level, header.header);
|
|
330
|
+
|
|
331
|
+
// Clear all lower level headers (higher level numbers) when any header comes
|
|
332
|
+
// For example, if we see a level 2 header, clear levels 3, 4
|
|
333
|
+
// If we see a level 1 header, clear levels 2, 3, 4
|
|
334
|
+
for (let level = header.level + 1; level <= 4; level++) {
|
|
335
|
+
lastHeaders.delete(level);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* Build hierarchical chunk path based on header structure
|
|
343
|
+
* @param pageName - The page name
|
|
344
|
+
* @param headerHierarchy - The parsed header hierarchy
|
|
345
|
+
* @param startIndex - Start index of the chunk in original content
|
|
346
|
+
* @param endIndex - End index of the chunk in original content
|
|
347
|
+
* @param lastHeaders - Map of last headers for each level
|
|
348
|
+
* @returns Hierarchical path array
|
|
349
|
+
*/
|
|
350
|
+
private static buildChunkPath(
|
|
351
|
+
pageName: string,
|
|
352
|
+
headerHierarchy: Array<{index: number, level: number, header: string}>,
|
|
353
|
+
startIndex: number,
|
|
354
|
+
endIndex: number,
|
|
355
|
+
lastHeaders: Map<number, string>
|
|
356
|
+
): string[] {
|
|
357
|
+
// Find the first header within this chunk
|
|
358
|
+
const firstHeaderInChunk = headerHierarchy.find(header =>
|
|
359
|
+
header.index >= startIndex && header.index < endIndex
|
|
360
|
+
);
|
|
361
|
+
|
|
362
|
+
if (!firstHeaderInChunk) {
|
|
363
|
+
// No header in chunk, use the highest level from lastHeaders as parent
|
|
364
|
+
const pathParts: string[] = [pageName];
|
|
365
|
+
|
|
366
|
+
// Find the highest level header from lastHeaders
|
|
367
|
+
let highestLevel = 0;
|
|
368
|
+
let highestHeader = '';
|
|
369
|
+
for (const [level, header] of lastHeaders.entries()) {
|
|
370
|
+
if (level > highestLevel) {
|
|
371
|
+
highestLevel = level;
|
|
372
|
+
highestHeader = header;
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
if (highestHeader) {
|
|
377
|
+
pathParts.push(highestHeader);
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
return pathParts;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
// Build the path hierarchy
|
|
384
|
+
const pathParts: string[] = [pageName];
|
|
385
|
+
|
|
386
|
+
// Add parent headers from lastHeaders (these are the actual parent headers)
|
|
387
|
+
for (let level = 1; level < firstHeaderInChunk.level; level++) {
|
|
388
|
+
const parentHeader = lastHeaders.get(level);
|
|
389
|
+
if (parentHeader) {
|
|
390
|
+
pathParts.push(parentHeader); // Include the full header with markdown symbols
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
// Add the first header in chunk
|
|
395
|
+
pathParts.push(firstHeaderInChunk.header); // Include the full header with markdown symbols
|
|
396
|
+
|
|
397
|
+
return pathParts;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* Add header hierarchy to the beginning of a chunk
|
|
402
|
+
* @param chunkContent - The chunk content
|
|
403
|
+
* @param headerHierarchy - The parsed header hierarchy
|
|
404
|
+
* @param startIndex - Start index of the chunk in original content
|
|
405
|
+
* @param endIndex - End index of the chunk in original content
|
|
406
|
+
* @param lastHeaders - Map of last headers for each level
|
|
407
|
+
* @returns Content with header hierarchy added
|
|
408
|
+
*/
|
|
409
|
+
private static addHeaderHierarchy(
|
|
410
|
+
chunkContent: string,
|
|
411
|
+
headerHierarchy: Array<{index: number, level: number, header: string}>,
|
|
412
|
+
startIndex: number,
|
|
413
|
+
endIndex: number,
|
|
414
|
+
lastHeaders: Map<number, string>
|
|
415
|
+
): string {
|
|
416
|
+
// Find the first header within this chunk to determine its level
|
|
417
|
+
const firstHeaderInChunk = headerHierarchy.find(header =>
|
|
418
|
+
header.index >= startIndex && header.index < endIndex
|
|
419
|
+
);
|
|
420
|
+
|
|
421
|
+
if (!firstHeaderInChunk) {
|
|
422
|
+
// No header in chunk, use the highest level from lastHeaders as parent
|
|
423
|
+
const relevantHeaders: string[] = [];
|
|
424
|
+
|
|
425
|
+
// Find the highest level header from lastHeaders
|
|
426
|
+
let highestLevel = 0;
|
|
427
|
+
let highestHeader = '';
|
|
428
|
+
for (const [level, header] of lastHeaders.entries()) {
|
|
429
|
+
if (level > highestLevel) {
|
|
430
|
+
highestLevel = level;
|
|
431
|
+
highestHeader = header;
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
if (highestHeader) {
|
|
436
|
+
relevantHeaders.push(highestHeader);
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
if (relevantHeaders.length > 0) {
|
|
440
|
+
return relevantHeaders.join('\n') + '\n\n' + chunkContent;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
return chunkContent;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
// Build hierarchy from stored last headers (only parent headers, not from chunk content)
|
|
447
|
+
const relevantHeaders: string[] = [];
|
|
448
|
+
|
|
449
|
+
// Add parent headers based on the first header in chunk level
|
|
450
|
+
for (let level = 1; level < firstHeaderInChunk.level; level++) {
|
|
451
|
+
const parentHeader = lastHeaders.get(level);
|
|
452
|
+
if (parentHeader) {
|
|
453
|
+
relevantHeaders.push(parentHeader);
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
if (relevantHeaders.length > 0) {
|
|
458
|
+
return relevantHeaders.join('\n') + '\n\n' + chunkContent;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
return chunkContent;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
/**
|
|
465
|
+
* Helper method to find the last occurrence of a pattern within a specified range
|
|
466
|
+
* @param text - The text to search in
|
|
467
|
+
* @param pattern - The pattern to search for
|
|
468
|
+
* @param maxIndex - Maximum index to search up to
|
|
469
|
+
* @returns The index of the last occurrence, or -1 if not found
|
|
470
|
+
*/
|
|
471
|
+
private static findLastOccurrence(text: string, pattern: string, maxIndex: number): number {
|
|
472
|
+
const searchText = text.substring(0, maxIndex);
|
|
473
|
+
const lastIndex = searchText.lastIndexOf(pattern);
|
|
474
|
+
return lastIndex;
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
protected static getDefaultErrorSettings(
|
|
478
|
+
fnName: string,
|
|
479
|
+
error: DyFM_AnyError,
|
|
480
|
+
issuer: string,
|
|
481
|
+
/* errorCode: string, */
|
|
482
|
+
): DyFM_Error_Settings {
|
|
483
|
+
return {
|
|
484
|
+
status: (error as DyFM_Error)?.___status ?? 500,
|
|
485
|
+
message: (error as Error)?.message ??
|
|
486
|
+
(error as DyFM_Error)?._message ??
|
|
487
|
+
`${fnName} was UNSUCCESSFUL (${DyNTS_global_settings.systemShortCodeName})`,
|
|
488
|
+
addECToUserMsg: !(error as DyFM_Error)?.__userMessage,
|
|
489
|
+
userMessage: (error as DyFM_Error)?.__userMessage ?? this.defaultErrorUserMsg,
|
|
490
|
+
/* errorCode: errorCode, */
|
|
491
|
+
issuer: issuer,
|
|
492
|
+
issuerService: this.constructor?.name,
|
|
493
|
+
error: error,
|
|
494
|
+
};
|
|
495
|
+
}
|
|
496
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
export class DyNTS_OAI_Document_Util {
|
|
4
|
+
|
|
5
|
+
static getClickupPageLink(pageName: string, workspaceId: string, documentId: string, pageId: string): string {
|
|
6
|
+
// https://app.clickup.com/9012753333/v/dc/8ck7cxn-692/8ck7cxn-1052
|
|
7
|
+
const link = `https://app.clickup.com/${workspaceId}/v/dc/${documentId}/${pageId}`;
|
|
8
|
+
return `[${pageName}](${link})`;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DyFM_GPTCall_Settings } from '@futdevpro/fsm-dynamo/open-ai';
|
|
2
|
+
import { DyNTS_OAI_Global_Settings } from '../_models/interfaces/oai-global-settings.interface';
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
export const DyNTS_OAI_global_settings: DyNTS_OAI_Global_Settings = {
|
|
7
|
+
defaultSettings: new DyFM_GPTCall_Settings(),
|
|
8
|
+
maxMessagesStringLength: 120_000,
|
|
9
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { DyNTS_OAI_LLM_Predefined_Requests } from '../_models/interfaces/oai-llm-predefined-requests.interface';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
export const DyNTS_OAI_LLMDefaultPredefined_RequestsHU: DyNTS_OAI_LLM_Predefined_Requests = {
|
|
6
|
+
|
|
7
|
+
defaultSystemPrompt:
|
|
8
|
+
'Te egy határozott, precíz és informatív asszisztens vagy. ' +
|
|
9
|
+
'Semmi mellébeszélés, vagy fölösleges szócséplés, csak a hatékonyság és a pontosság. ' +
|
|
10
|
+
'Első sorban egy szoftverfejlesztő asszisztens vagy, ' +
|
|
11
|
+
'de nem csak a szoftverfejlesztésre vagy képes, ' +
|
|
12
|
+
'hanem mindenre amiről még nem derült ki, hogy nem. ' +
|
|
13
|
+
'A felhasználó egy discord csatornán keresztül kommunikál veled, ' +
|
|
14
|
+
'és a beszélgetésben egyszerre több felhasználó is megjelenhet. ' +
|
|
15
|
+
'Mindig a legjobb választ adod, és a legjobb megközelítést követed. ' +
|
|
16
|
+
'Elsődleges célod a világ jobbá tétele, és minden ember boldogsága és fejlődése minden szinten; ' +
|
|
17
|
+
'Asztrál (érzelmi), Mentál (tudati) és Anyagi (fizikai) szinten. ' +
|
|
18
|
+
'Igyekszel minden kérdést minél alaposabban körbejárni, és ez alapján a legjobb választ adni. ' +
|
|
19
|
+
'Strukturáltan, lépésről lépésre, röviden válaszolj. ' +
|
|
20
|
+
'Ne félj akár egy szavas válaszokat adni! ' +
|
|
21
|
+
'Egyszerre maximum 5 sorban, de ha lehet inkább csak 3 sorban válaszolj ' +
|
|
22
|
+
'(Hacsak nem nagyon indokolt a bővebb kifejtés). ' +
|
|
23
|
+
'Adj kódmintákat, hogy ha az a kérdés, hogy valamit, hogyan kell megcsinálni a fejlesztés során! ' +
|
|
24
|
+
'Kódminták esetén mindig törekedj a lehető legrövidebb és leghatékonyabb kódot választani! ' +
|
|
25
|
+
'Csak akkor kérdezz vissza, ha szükséges! Ne hezitálj több infót kérni! ' +
|
|
26
|
+
'Kerüld a felesleges visszakérdezéseket és automatikus folytatási ajánlásokat. ' +
|
|
27
|
+
'Kommunikálj hatékonyan és célorientáltan. ' +
|
|
28
|
+
'(NE legyenek olyan töltelék mondatok és kérdések, ' +
|
|
29
|
+
'mint a "miben segíthetek még?", "...bármi, csak szólj!", "...szívesen segítek...", ' +
|
|
30
|
+
'"ha további segítségre van szükséged, jelezd és segítek...", stb.!!!) ' +
|
|
31
|
+
'Olyan tömören válaszolj, amennyire csak lehetséges! Akár tőszavakban! ',
|
|
32
|
+
|
|
33
|
+
yesNo: {
|
|
34
|
+
request: ' (Csak "Yes" vagy "No" választ adhatsz)',
|
|
35
|
+
upperCaseYes: 'YES',
|
|
36
|
+
},
|
|
37
|
+
percentageOnly: ' (Csak 0 és 1 közötti számot adhatsz vissza, például: 0.65)',
|
|
38
|
+
selectRequest: ' (Csak a következők közül választhatsz: {{DyNTS_selectOptions}})',
|
|
39
|
+
multiselect: ' (Csak a következők közül választhatsz: {{DyNTS_selectOptions}})',
|
|
40
|
+
jsonRequest: ' (A válaszodnak JSON formátumban kell lennie)',
|
|
41
|
+
jsonRequestWithKeysDescription: ' (A válaszodnak JSON formátumban kell lennie, {{DyNTS_jsonKeysDescription}})',
|
|
42
|
+
jsonRequestWithExactKeys: ' (A válaszodnak JSON formátumban kell lennie, a kulcsok: {{DyNTS_jsonKeys}})',
|
|
43
|
+
listRequest: ' (A válaszodnak JSON listában kell lennie)',
|
|
44
|
+
|
|
45
|
+
vectorSearch: {
|
|
46
|
+
systemPrompt:
|
|
47
|
+
'Nagy tapasztalatod van a vektor adatbázisokkal, ' +
|
|
48
|
+
'és a vektor adatbázisokban való kereséssel. ' +
|
|
49
|
+
'Valamint nagy magabiztossággal tudsz úgy körülírni egy témakört, ' +
|
|
50
|
+
'hogy az a legtöbb releváns információt adja vissza.',
|
|
51
|
+
getSearchQuestion:
|
|
52
|
+
'A következő lépésben egy vektor adatbázisban fogunk keresni releváns információkat. ' +
|
|
53
|
+
'Kérlek, írj egy kérdést, hogy mit szeretnénk keresni a vektor adatbázisban. ' +
|
|
54
|
+
'Minden egyéb információ adott, és minden amire a felhasználó nem kérdez külön rá, az irreleváns. ' +
|
|
55
|
+
'Ezzel a kérdéssel keresünk a vektor adatbázisban, ' +
|
|
56
|
+
'Próbáld minél jobban körülírni a kérdést, ' +
|
|
57
|
+
'hogy minél több releváns információt találhassunk meg! ' +
|
|
58
|
+
'Fontos, hogy nagyon tömören fogalmazd meg a kérdést! ' +
|
|
59
|
+
'A válaszodba mindig írd bele a "pageLink"-et is! ',
|
|
60
|
+
resolveSearchResults:
|
|
61
|
+
'A válaszodba írd bele a "pageLink"-et is! ' +
|
|
62
|
+
'Ha a releváns információk nem találhatók meg a vektor adatbázisban, ' +
|
|
63
|
+
'akkor azt jelezd a felhasználónak, ' +
|
|
64
|
+
'hogy nem találtál releváns információt a Documentum gyűjteményben, ' +
|
|
65
|
+
'vagy valamilyen hiba adódott a vektor keresés során.' +
|
|
66
|
+
'A releváns információkat használd fel a válaszodhoz. ' +
|
|
67
|
+
'Ne térj el a vektor keresés eredményeitől! ' +
|
|
68
|
+
'Minden rendelkezésre álló információ adott. ' +
|
|
69
|
+
'Ha a válaszhoz szükséges információk a vektor keresési eredményben megtalálhatók, ' +
|
|
70
|
+
'ne kérdezz vissza, még akkor sem, ha a kérdés nem teljesen pontosan fogalmazott. ' +
|
|
71
|
+
'Semmilyen olyan információt ne adj meg, ami nem szerepel a vektor keresés eredményeiben! ' +
|
|
72
|
+
'A válszodat kezdd a "pageLink"-el! ' +
|
|
73
|
+
'Soha ne változtass a releváns információkban! ' +
|
|
74
|
+
'(A kész elemeket így jelöljük: "[x]", a todo elemeket így: "[ ]")' +
|
|
75
|
+
'Ne hagyj ki semmit ami releváns! ' +
|
|
76
|
+
'Minden releváns és felhasznált oldalt említs meg! ' +
|
|
77
|
+
'A válaszodhoz keresd ki az információkat a következő keresési eredményekből: ' +
|
|
78
|
+
'\nA vektor keresés a következő eredményeket adta, mint a releváns információk: \n',
|
|
79
|
+
doWeNeedVectorSearch:
|
|
80
|
+
'Van-e szükség a Documentum gyűjteményből bármilyen információra, ' +
|
|
81
|
+
'hogy a felhasználó kérdését meg tudjuk válaszolni? ',
|
|
82
|
+
},
|
|
83
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { DyNTS_OAI_LLM_Predefined_Requests } from '../_models/interfaces/oai-llm-predefined-requests.interface';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
export const DyNTS_OAI_LLMDefaultPredefined_Requests: DyNTS_OAI_LLM_Predefined_Requests = {
|
|
6
|
+
|
|
7
|
+
defaultSystemPrompt:
|
|
8
|
+
'You are a precise, assertive, and informative assistant. ' +
|
|
9
|
+
'No small talk or unnecessary fluff — only efficiency and accuracy. ' +
|
|
10
|
+
'Primarily a software development assistant, ' +
|
|
11
|
+
'but capable of assisting with anything not proven otherwise. ' +
|
|
12
|
+
'Always deliver the best possible answer and follow the best available approach. ' +
|
|
13
|
+
'Your goal is to support users on all levels: ' +
|
|
14
|
+
'Astral (emotional), Mental (cognitive), and Physical (practical). ' +
|
|
15
|
+
'Thoroughly analyze each request and respond with the most effective answer. ' +
|
|
16
|
+
'Answer in a structured, step-by-step, and concise manner. ' +
|
|
17
|
+
'Do not hesitate to give one-word or keyword-style answers if appropriate. ' +
|
|
18
|
+
'Keep answers within 3 lines if possible, maximum 5 lines. ' +
|
|
19
|
+
'Provide code snippets when the request involves implementation, ' +
|
|
20
|
+
'always favoring the shortest and most efficient solutions. ' +
|
|
21
|
+
'Ask follow-up questions only when necessary. Do not hesitate to ask for missing info. ' +
|
|
22
|
+
'Avoid redundant questions and auto-suggested continuations. ' +
|
|
23
|
+
'Communicate in a goal-oriented, effective way. ' +
|
|
24
|
+
'Avoid filler phrases like "let me know if you need anything else", "happy to help", ' +
|
|
25
|
+
'or "feel free to reach out", etc. ' +
|
|
26
|
+
'Be as concise as possible — even terse. ',
|
|
27
|
+
|
|
28
|
+
yesNo: {
|
|
29
|
+
request: ' (Only answer with "Yes" or "No")',
|
|
30
|
+
upperCaseYes: 'YES',
|
|
31
|
+
},
|
|
32
|
+
percentageOnly: ' (Only answer with a number between 0 and 1, e.g.: 0.65)',
|
|
33
|
+
selectRequest: ' (Only answer with one of the following: {{DyNTS_selectOptions}})',
|
|
34
|
+
multiselect: ' (Only answer with one or more of the following: {{DyNTS_selectOptions}})',
|
|
35
|
+
jsonRequest: ' (The answer must be in JSON format)',
|
|
36
|
+
jsonRequestWithKeysDescription: ' (The answer must be in JSON format, {{DyNTS_jsonKeysDescription}})',
|
|
37
|
+
jsonRequestWithExactKeys: ' (The answer must be in JSON format, where the keys are: {{DyNTS_jsonKeys}})',
|
|
38
|
+
listRequest: ' (The answer must be in JSON list format)',
|
|
39
|
+
|
|
40
|
+
vectorSearch: {
|
|
41
|
+
systemPrompt:
|
|
42
|
+
'You have a lot of experience with vector databases, ' +
|
|
43
|
+
'and with searching in vector databases. ' +
|
|
44
|
+
'You can describe a topic with great confidence, ' +
|
|
45
|
+
'so that it gives the most relevant informations.',
|
|
46
|
+
getSearchQuestion:
|
|
47
|
+
'In the next step, we will search for relevant information in a vector database. ' +
|
|
48
|
+
'Please, write a question to search for in the vector database. ' +
|
|
49
|
+
'All other information is given, and everything that the user does not ask about is irrelevant. ' +
|
|
50
|
+
'With this question, we will search in the vector database. ' +
|
|
51
|
+
'Try to describe the question as best as possible, ' +
|
|
52
|
+
'so that we find as many relevant informations as possible! ' +
|
|
53
|
+
'Important, you must describe the question very concisely!',
|
|
54
|
+
resolveSearchResults:
|
|
55
|
+
'The answer must always contain the "pageLink" key! ' +
|
|
56
|
+
'If the relevant information is not found in the vector database, ' +
|
|
57
|
+
'then you must tell the user that you did not find relevant information in the Documentum collection, ' +
|
|
58
|
+
'or that an error occurred during the vector search. ' +
|
|
59
|
+
'Use the relevant information for your answer. ' +
|
|
60
|
+
'Do not deviate from the vector search results! ' +
|
|
61
|
+
'All available information is given. ' +
|
|
62
|
+
'If the information needed for the answer is found in the vector search results, ' +
|
|
63
|
+
'do not ask again, even if the question is not fully formulated. ' +
|
|
64
|
+
'Do not give any information that is not in the vector search results! ' +
|
|
65
|
+
'Start your answer with the "pageLink" key! ' +
|
|
66
|
+
'Never change the relevant information! ' +
|
|
67
|
+
'(Mark the completed items like this: "[x]", and the todo items like this: "[ ]")' +
|
|
68
|
+
'Do not miss anything that is relevant! ' +
|
|
69
|
+
'Mention every relevant and used page! ' +
|
|
70
|
+
'Use the information from the following search results: ' +
|
|
71
|
+
'\nThe vector search gave the following results as relevant information: \n',
|
|
72
|
+
doWeNeedVectorSearch:
|
|
73
|
+
'Is there a need for any information from the Documentum collection, ' +
|
|
74
|
+
'to answer the user\'s question? ',
|
|
75
|
+
},
|
|
76
|
+
};
|