@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.
Files changed (301) hide show
  1. package/build/_collections/atlas-default-db-options.const.d.ts +28 -0
  2. package/build/_collections/atlas-default-db-options.const.d.ts.map +1 -0
  3. package/build/_collections/atlas-default-db-options.const.js +10 -0
  4. package/build/_collections/atlas-default-db-options.const.js.map +1 -0
  5. package/build/_collections/get-environment-settings.util.d.ts +3 -0
  6. package/build/_collections/get-environment-settings.util.d.ts.map +1 -0
  7. package/build/_collections/get-environment-settings.util.js +45 -0
  8. package/build/_collections/get-environment-settings.util.js.map +1 -0
  9. package/build/_collections/global-settings.const.d.ts.map +1 -1
  10. package/build/_collections/global-settings.const.js +9 -4
  11. package/build/_collections/global-settings.const.js.map +1 -1
  12. package/build/_models/control-models/app-params.control-model.d.ts +6 -0
  13. package/build/_models/control-models/app-params.control-model.d.ts.map +1 -1
  14. package/build/_models/control-models/app-params.control-model.js +29 -2
  15. package/build/_models/control-models/app-params.control-model.js.map +1 -1
  16. package/build/_models/control-models/app-params.control-model.spec.js +5 -4
  17. package/build/_models/control-models/app-params.control-model.spec.js.map +1 -1
  18. package/build/_models/control-models/endpoint-params.control-model.js +1 -1
  19. package/build/_models/control-models/endpoint-params.control-model.js.map +1 -1
  20. package/build/_models/interfaces/environment-settings.interface.d.ts +35 -0
  21. package/build/_models/interfaces/environment-settings.interface.d.ts.map +1 -0
  22. package/build/_models/interfaces/environment-settings.interface.js +3 -0
  23. package/build/_models/interfaces/environment-settings.interface.js.map +1 -0
  24. package/build/_models/interfaces/global-settings.interface.d.ts +34 -2
  25. package/build/_models/interfaces/global-settings.interface.d.ts.map +1 -1
  26. package/build/_modules/custom-data/index.d.ts.map +1 -1
  27. package/build/_modules/custom-data/index.js +1 -0
  28. package/build/_modules/custom-data/index.js.map +1 -1
  29. package/build/_modules/discord-assistant/_collections/dias-global-settings.const.d.ts +3 -0
  30. package/build/_modules/discord-assistant/_collections/dias-global-settings.const.d.ts.map +1 -0
  31. package/build/_modules/discord-assistant/_collections/dias-global-settings.const.js +17 -0
  32. package/build/_modules/discord-assistant/_collections/dias-global-settings.const.js.map +1 -0
  33. package/build/_modules/discord-assistant/_models/dias-global-settings.interface.d.ts +18 -0
  34. package/build/_modules/discord-assistant/_models/dias-global-settings.interface.d.ts.map +1 -0
  35. package/build/_modules/discord-assistant/_models/dias-global-settings.interface.js +3 -0
  36. package/build/_modules/discord-assistant/_models/dias-global-settings.interface.js.map +1 -0
  37. package/build/_modules/discord-assistant/_models/dias-knowledge.data-model.d.ts +10 -0
  38. package/build/_modules/discord-assistant/_models/dias-knowledge.data-model.d.ts.map +1 -0
  39. package/build/_modules/discord-assistant/_models/dias-knowledge.data-model.js +41 -0
  40. package/build/_modules/discord-assistant/_models/dias-knowledge.data-model.js.map +1 -0
  41. package/build/_modules/discord-assistant/_services/dias-chunk.data-service.d.ts +14 -0
  42. package/build/_modules/discord-assistant/_services/dias-chunk.data-service.d.ts.map +1 -0
  43. package/build/_modules/discord-assistant/_services/dias-chunk.data-service.js +88 -0
  44. package/build/_modules/discord-assistant/_services/dias-chunk.data-service.js.map +1 -0
  45. package/build/_modules/discord-assistant/_services/dias-io.control-service.d.ts +10 -0
  46. package/build/_modules/discord-assistant/_services/dias-io.control-service.d.ts.map +1 -0
  47. package/build/_modules/discord-assistant/_services/dias-io.control-service.js +39 -0
  48. package/build/_modules/discord-assistant/_services/dias-io.control-service.js.map +1 -0
  49. package/build/_modules/discord-assistant/_services/dias-main.control-service.d.ts +8 -0
  50. package/build/_modules/discord-assistant/_services/dias-main.control-service.d.ts.map +1 -0
  51. package/build/_modules/discord-assistant/_services/dias-main.control-service.js +23 -0
  52. package/build/_modules/discord-assistant/_services/dias-main.control-service.js.map +1 -0
  53. package/build/_modules/discord-assistant/_services/dias.service-base.d.ts +13 -0
  54. package/build/_modules/discord-assistant/_services/dias.service-base.d.ts.map +1 -0
  55. package/build/_modules/discord-assistant/_services/dias.service-base.js +61 -0
  56. package/build/_modules/discord-assistant/_services/dias.service-base.js.map +1 -0
  57. package/build/_modules/discord-assistant/index.d.ts +10 -0
  58. package/build/_modules/discord-assistant/index.d.ts.map +1 -0
  59. package/build/_modules/discord-assistant/index.js +23 -0
  60. package/build/_modules/discord-assistant/index.js.map +1 -0
  61. package/build/_modules/discord-assistant-voiced/_services/dias-discord-bot.control-service.d.ts +4 -0
  62. package/build/_modules/discord-assistant-voiced/_services/dias-discord-bot.control-service.d.ts.map +1 -0
  63. package/build/_modules/discord-assistant-voiced/_services/dias-discord-bot.control-service.js +8 -0
  64. package/build/_modules/discord-assistant-voiced/_services/dias-discord-bot.control-service.js.map +1 -0
  65. package/build/_modules/discord-assistant-voiced/index.d.ts +3 -0
  66. package/build/_modules/discord-assistant-voiced/index.d.ts.map +1 -0
  67. package/build/_modules/discord-assistant-voiced/index.js +26 -0
  68. package/build/_modules/discord-assistant-voiced/index.js.map +1 -0
  69. package/build/_modules/discord-bot/_collections/dibo-default-commands.const.d.ts +3 -0
  70. package/build/_modules/discord-bot/_collections/dibo-default-commands.const.d.ts.map +1 -0
  71. package/build/_modules/discord-bot/_collections/dibo-default-commands.const.js +13 -0
  72. package/build/_modules/discord-bot/_collections/dibo-default-commands.const.js.map +1 -0
  73. package/build/_modules/discord-bot/_collections/dibo-global-settings.conts.d.ts +3 -0
  74. package/build/_modules/discord-bot/_collections/dibo-global-settings.conts.d.ts.map +1 -0
  75. package/build/_modules/discord-bot/_collections/dibo-global-settings.conts.js +44 -0
  76. package/build/_modules/discord-bot/_collections/dibo-global-settings.conts.js.map +1 -0
  77. package/build/_modules/discord-bot/_collections/dibo-operations.util.d.ts +22 -0
  78. package/build/_modules/discord-bot/_collections/dibo-operations.util.d.ts.map +1 -0
  79. package/build/_modules/discord-bot/_collections/dibo-operations.util.js +261 -0
  80. package/build/_modules/discord-bot/_collections/dibo-operations.util.js.map +1 -0
  81. package/build/_modules/discord-bot/_models/dibo-command.interface.d.ts +8 -0
  82. package/build/_modules/discord-bot/_models/dibo-command.interface.d.ts.map +1 -0
  83. package/build/_modules/discord-bot/_models/dibo-command.interface.js +3 -0
  84. package/build/_modules/discord-bot/_models/dibo-command.interface.js.map +1 -0
  85. package/build/_modules/discord-bot/_models/dibo-last-mention-date.inteface.d.ts +7 -0
  86. package/build/_modules/discord-bot/_models/dibo-last-mention-date.inteface.d.ts.map +1 -0
  87. package/build/_modules/discord-bot/_models/dibo-last-mention-date.inteface.js +3 -0
  88. package/build/_modules/discord-bot/_models/dibo-last-mention-date.inteface.js.map +1 -0
  89. package/build/_modules/discord-bot/_models/dibo-last-message-date.interface.d.ts +6 -0
  90. package/build/_modules/discord-bot/_models/dibo-last-message-date.interface.d.ts.map +1 -0
  91. package/build/_modules/discord-bot/_models/dibo-last-message-date.interface.js +3 -0
  92. package/build/_modules/discord-bot/_models/dibo-last-message-date.interface.js.map +1 -0
  93. package/build/_modules/discord-bot/_models/global-bot-log-settings.interface.d.ts +88 -0
  94. package/build/_modules/discord-bot/_models/global-bot-log-settings.interface.d.ts.map +1 -0
  95. package/build/_modules/discord-bot/_models/global-bot-log-settings.interface.js +3 -0
  96. package/build/_modules/discord-bot/_models/global-bot-log-settings.interface.js.map +1 -0
  97. package/build/_modules/discord-bot/_services/dibo-commands.control-service.d.ts +12 -0
  98. package/build/_modules/discord-bot/_services/dibo-commands.control-service.d.ts.map +1 -0
  99. package/build/_modules/discord-bot/_services/dibo-commands.control-service.js +72 -0
  100. package/build/_modules/discord-bot/_services/dibo-commands.control-service.js.map +1 -0
  101. package/build/_modules/discord-bot/_services/dibo-io.control-service.d.ts +19 -0
  102. package/build/_modules/discord-bot/_services/dibo-io.control-service.d.ts.map +1 -0
  103. package/build/_modules/discord-bot/_services/dibo-io.control-service.js +176 -0
  104. package/build/_modules/discord-bot/_services/dibo-io.control-service.js.map +1 -0
  105. package/build/_modules/discord-bot/_services/dibo-main.control-service.d.ts +85 -0
  106. package/build/_modules/discord-bot/_services/dibo-main.control-service.d.ts.map +1 -0
  107. package/build/_modules/discord-bot/_services/dibo-main.control-service.js +228 -0
  108. package/build/_modules/discord-bot/_services/dibo-main.control-service.js.map +1 -0
  109. package/build/_modules/discord-bot/_services/dibo-routines.control-service.d.ts +13 -0
  110. package/build/_modules/discord-bot/_services/dibo-routines.control-service.d.ts.map +1 -0
  111. package/build/_modules/discord-bot/_services/dibo-routines.control-service.js +38 -0
  112. package/build/_modules/discord-bot/_services/dibo-routines.control-service.js.map +1 -0
  113. package/build/_modules/discord-bot/index.d.ts +12 -0
  114. package/build/_modules/discord-bot/index.d.ts.map +1 -0
  115. package/build/_modules/discord-bot/index.js +30 -0
  116. package/build/_modules/discord-bot/index.js.map +1 -0
  117. package/build/_modules/oauth2/index.d.ts.map +1 -1
  118. package/build/_modules/oauth2/index.js +7 -0
  119. package/build/_modules/oauth2/index.js.map +1 -1
  120. package/build/_modules/open-ai/_collections/oai-chunking.util.d.ts +74 -0
  121. package/build/_modules/open-ai/_collections/oai-chunking.util.d.ts.map +1 -0
  122. package/build/_modules/open-ai/_collections/oai-chunking.util.js +385 -0
  123. package/build/_modules/open-ai/_collections/oai-chunking.util.js.map +1 -0
  124. package/build/_modules/open-ai/_collections/oai-document.util.d.ts +4 -0
  125. package/build/_modules/open-ai/_collections/oai-document.util.d.ts.map +1 -0
  126. package/build/_modules/open-ai/_collections/oai-document.util.js +12 -0
  127. package/build/_modules/open-ai/_collections/oai-document.util.js.map +1 -0
  128. package/build/_modules/open-ai/_collections/oai-global-settings.const.d.ts +3 -0
  129. package/build/_modules/open-ai/_collections/oai-global-settings.const.d.ts.map +1 -0
  130. package/build/_modules/open-ai/_collections/oai-global-settings.const.js +9 -0
  131. package/build/_modules/open-ai/_collections/oai-global-settings.const.js.map +1 -0
  132. package/build/_modules/open-ai/_collections/oai-llm-predefined-requests-hu.conts.d.ts +3 -0
  133. package/build/_modules/open-ai/_collections/oai-llm-predefined-requests-hu.conts.d.ts.map +1 -0
  134. package/build/_modules/open-ai/_collections/oai-llm-predefined-requests-hu.conts.js +75 -0
  135. package/build/_modules/open-ai/_collections/oai-llm-predefined-requests-hu.conts.js.map +1 -0
  136. package/build/_modules/open-ai/_collections/oai-llm-predefined-requests.conts.d.ts +3 -0
  137. package/build/_modules/open-ai/_collections/oai-llm-predefined-requests.conts.d.ts.map +1 -0
  138. package/build/_modules/open-ai/_collections/oai-llm-predefined-requests.conts.js +68 -0
  139. package/build/_modules/open-ai/_collections/oai-llm-predefined-requests.conts.js.map +1 -0
  140. package/build/_modules/open-ai/_enums/oai-compare-result-type.enum.d.ts +6 -0
  141. package/build/_modules/open-ai/_enums/oai-compare-result-type.enum.d.ts.map +1 -0
  142. package/build/_modules/open-ai/_enums/oai-compare-result-type.enum.js +10 -0
  143. package/build/_modules/open-ai/_enums/oai-compare-result-type.enum.js.map +1 -0
  144. package/build/_modules/open-ai/_enums/oai-gpt-message-role.enum.d.ts +18 -0
  145. package/build/_modules/open-ai/_enums/oai-gpt-message-role.enum.d.ts.map +1 -0
  146. package/build/_modules/open-ai/_enums/oai-gpt-message-role.enum.js +40 -0
  147. package/build/_modules/open-ai/_enums/oai-gpt-message-role.enum.js.map +1 -0
  148. package/build/_modules/open-ai/_models/interfaces/oai-chunk-compare-result.interface.d.ts +7 -0
  149. package/build/_modules/open-ai/_models/interfaces/oai-chunk-compare-result.interface.d.ts.map +1 -0
  150. package/build/_modules/open-ai/_models/interfaces/oai-chunk-compare-result.interface.js +3 -0
  151. package/build/_modules/open-ai/_models/interfaces/oai-chunk-compare-result.interface.js.map +1 -0
  152. package/build/_modules/open-ai/_models/interfaces/oai-document-page.interface.d.ts +14 -0
  153. package/build/_modules/open-ai/_models/interfaces/oai-document-page.interface.d.ts.map +1 -0
  154. package/build/_modules/open-ai/_models/interfaces/oai-document-page.interface.js +3 -0
  155. package/build/_modules/open-ai/_models/interfaces/oai-document-page.interface.js.map +1 -0
  156. package/build/_modules/open-ai/_models/interfaces/oai-global-settings.interface.d.ts +6 -0
  157. package/build/_modules/open-ai/_models/interfaces/oai-global-settings.interface.d.ts.map +1 -0
  158. package/build/_modules/open-ai/_models/interfaces/oai-global-settings.interface.js +3 -0
  159. package/build/_modules/open-ai/_models/interfaces/oai-global-settings.interface.js.map +1 -0
  160. package/build/_modules/open-ai/_models/interfaces/oai-gpt-message.interface.d.ts +6 -0
  161. package/build/_modules/open-ai/_models/interfaces/oai-gpt-message.interface.d.ts.map +1 -0
  162. package/build/_modules/open-ai/_models/interfaces/oai-gpt-message.interface.js +3 -0
  163. package/build/_modules/open-ai/_models/interfaces/oai-gpt-message.interface.js.map +1 -0
  164. package/build/_modules/open-ai/_models/interfaces/oai-llm-predefined-requests.interface.d.ts +52 -0
  165. package/build/_modules/open-ai/_models/interfaces/oai-llm-predefined-requests.interface.d.ts.map +1 -0
  166. package/build/_modules/open-ai/_models/interfaces/oai-llm-predefined-requests.interface.js +3 -0
  167. package/build/_modules/open-ai/_models/interfaces/oai-llm-predefined-requests.interface.js.map +1 -0
  168. package/build/_modules/open-ai/_models/interfaces/oai-page-compare-result.interface.d.ts +13 -0
  169. package/build/_modules/open-ai/_models/interfaces/oai-page-compare-result.interface.d.ts.map +1 -0
  170. package/build/_modules/open-ai/_models/interfaces/oai-page-compare-result.interface.js +3 -0
  171. package/build/_modules/open-ai/_models/interfaces/oai-page-compare-result.interface.js.map +1 -0
  172. package/build/_modules/open-ai/_models/oai-doc-chunk.data-model.d.ts +18 -0
  173. package/build/_modules/open-ai/_models/oai-doc-chunk.data-model.d.ts.map +1 -0
  174. package/build/_modules/open-ai/_models/oai-doc-chunk.data-model.js +80 -0
  175. package/build/_modules/open-ai/_models/oai-doc-chunk.data-model.js.map +1 -0
  176. package/build/_modules/open-ai/_services/oai-chunk.service-base.d.ts +13 -0
  177. package/build/_modules/open-ai/_services/oai-chunk.service-base.d.ts.map +1 -0
  178. package/build/_modules/open-ai/_services/oai-chunk.service-base.js +170 -0
  179. package/build/_modules/open-ai/_services/oai-chunk.service-base.js.map +1 -0
  180. package/build/_modules/open-ai/_services/{embedding.control-service.d.ts → oai-embedding.control-service.d.ts} +3 -3
  181. package/build/_modules/open-ai/_services/oai-embedding.control-service.d.ts.map +1 -0
  182. package/build/_modules/open-ai/_services/{embedding.control-service.js → oai-embedding.control-service.js} +5 -5
  183. package/build/_modules/open-ai/_services/oai-embedding.control-service.js.map +1 -0
  184. package/build/_modules/open-ai/_services/oai-llm-chat.service-base.d.ts +161 -0
  185. package/build/_modules/open-ai/_services/oai-llm-chat.service-base.d.ts.map +1 -0
  186. package/build/_modules/open-ai/_services/oai-llm-chat.service-base.js +332 -0
  187. package/build/_modules/open-ai/_services/oai-llm-chat.service-base.js.map +1 -0
  188. package/build/_modules/open-ai/_services/oai-llm.service-base.d.ts +231 -0
  189. package/build/_modules/open-ai/_services/oai-llm.service-base.d.ts.map +1 -0
  190. package/build/_modules/open-ai/_services/oai-llm.service-base.js +438 -0
  191. package/build/_modules/open-ai/_services/oai-llm.service-base.js.map +1 -0
  192. package/build/_modules/open-ai/_services/{vector-data.service.d.ts → oai-vector-data.service.d.ts} +4 -4
  193. package/build/_modules/open-ai/_services/oai-vector-data.service.d.ts.map +1 -0
  194. package/build/_modules/open-ai/_services/{vector-data.service.js → oai-vector-data.service.js} +27 -7
  195. package/build/_modules/open-ai/_services/oai-vector-data.service.js.map +1 -0
  196. package/build/_modules/open-ai/index.d.ts +18 -4
  197. package/build/_modules/open-ai/index.d.ts.map +1 -1
  198. package/build/_modules/open-ai/index.js +35 -4
  199. package/build/_modules/open-ai/index.js.map +1 -1
  200. package/build/_modules/server/index.d.ts +1 -1
  201. package/build/_modules/server/index.d.ts.map +1 -1
  202. package/build/_modules/server/index.js +16 -2
  203. package/build/_modules/server/index.js.map +1 -1
  204. package/build/_modules/server/server-status/server-status.controller.d.ts.map +1 -1
  205. package/build/_modules/server/server-status/server-status.controller.js +10 -0
  206. package/build/_modules/server/server-status/server-status.controller.js.map +1 -1
  207. package/build/_modules/socket/index.d.ts.map +1 -1
  208. package/build/_modules/socket/index.js +18 -0
  209. package/build/_modules/socket/index.js.map +1 -1
  210. package/build/_modules/test/index.d.ts.map +1 -1
  211. package/build/_modules/test/index.js +5 -0
  212. package/build/_modules/test/index.js.map +1 -1
  213. package/build/_modules/usage/index.d.ts.map +1 -1
  214. package/build/_modules/usage/index.js +5 -0
  215. package/build/_modules/usage/index.js.map +1 -1
  216. package/build/_services/server/app.server.js +1 -2
  217. package/build/_services/server/app.server.js.map +1 -1
  218. package/build/index.d.ts +3 -1
  219. package/build/index.d.ts.map +1 -1
  220. package/build/index.js +26 -1
  221. package/build/index.js.map +1 -1
  222. package/package.json +40 -10
  223. package/src/_collections/atlas-default-db-options.const.ts +10 -0
  224. package/src/_collections/get-environment-settings.util.ts +49 -0
  225. package/src/_collections/global-settings.const.ts +15 -4
  226. package/src/_collections/sample.env +21 -0
  227. package/src/_models/control-models/app-params.control-model.spec.ts +5 -4
  228. package/src/_models/control-models/app-params.control-model.ts +31 -2
  229. package/src/_models/control-models/endpoint-params.control-model.ts +1 -1
  230. package/src/_models/interfaces/environment-settings.interface.ts +59 -0
  231. package/src/_models/interfaces/global-settings.interface.ts +41 -1
  232. package/src/_modules/custom-data/index.ts +3 -0
  233. package/src/_modules/discord-assistant/_collections/dias-global-settings.const.ts +19 -0
  234. package/src/_modules/discord-assistant/_models/dias-global-settings.interface.ts +20 -0
  235. package/src/_modules/discord-assistant/_models/dias-knowledge.data-model.ts +46 -0
  236. package/src/_modules/discord-assistant/_services/dias-chunk.data-service.ts +152 -0
  237. package/src/_modules/discord-assistant/_services/dias-io.control-service.ts +59 -0
  238. package/src/_modules/discord-assistant/_services/dias-main.control-service.ts +28 -0
  239. package/src/_modules/discord-assistant/_services/dias.service-base.ts +81 -0
  240. package/src/_modules/discord-assistant/index.ts +36 -0
  241. package/src/_modules/discord-assistant-voiced/_services/dias-discord-bot.control-service.ts +11 -0
  242. package/src/_modules/discord-assistant-voiced/index.ts +36 -0
  243. package/src/_modules/discord-bot/_collections/dibo-default-commands.const.ts +17 -0
  244. package/src/_modules/discord-bot/_collections/dibo-global-settings.conts.ts +56 -0
  245. package/src/_modules/discord-bot/_collections/dibo-operations.util.ts +372 -0
  246. package/src/_modules/discord-bot/_models/dibo-command.interface.ts +12 -0
  247. package/src/_modules/discord-bot/_models/dibo-last-mention-date.inteface.ts +8 -0
  248. package/src/_modules/discord-bot/_models/dibo-last-message-date.interface.ts +6 -0
  249. package/src/_modules/discord-bot/_models/global-bot-log-settings.interface.ts +98 -0
  250. package/src/_modules/discord-bot/_services/dibo-commands.control-service.ts +120 -0
  251. package/src/_modules/discord-bot/_services/dibo-io.control-service.ts +245 -0
  252. package/src/_modules/discord-bot/_services/dibo-main.control-service.ts +304 -0
  253. package/src/_modules/discord-bot/_services/dibo-routines.control-service.ts +60 -0
  254. package/src/_modules/discord-bot/index.ts +36 -0
  255. package/src/_modules/oauth2/index.ts +8 -0
  256. package/src/_modules/open-ai/_collections/oai-chunking.util.ts +496 -0
  257. package/src/_modules/open-ai/_collections/oai-document.util.ts +10 -0
  258. package/src/_modules/open-ai/_collections/oai-global-settings.const.ts +9 -0
  259. package/src/_modules/open-ai/_collections/oai-llm-predefined-requests-hu.conts.ts +83 -0
  260. package/src/_modules/open-ai/_collections/oai-llm-predefined-requests.conts.ts +76 -0
  261. package/src/_modules/open-ai/_enums/oai-compare-result-type.enum.ts +7 -0
  262. package/src/_modules/open-ai/_enums/oai-gpt-message-role.enum.ts +45 -0
  263. package/src/_modules/open-ai/_models/interfaces/oai-chunk-compare-result.interface.ts +10 -0
  264. package/src/_modules/open-ai/_models/interfaces/oai-document-page.interface.ts +20 -0
  265. package/src/_modules/open-ai/_models/interfaces/oai-global-settings.interface.ts +8 -0
  266. package/src/_modules/open-ai/_models/interfaces/oai-gpt-message.interface.ts +7 -0
  267. package/src/_modules/open-ai/_models/interfaces/oai-llm-predefined-requests.interface.ts +57 -0
  268. package/src/_modules/open-ai/_models/interfaces/oai-page-compare-result.interface.ts +18 -0
  269. package/src/_modules/open-ai/_models/oai-doc-chunk.data-model.ts +92 -0
  270. package/src/_modules/open-ai/_services/oai-chunk.service-base.ts +214 -0
  271. package/src/_modules/open-ai/_services/{embedding.control-service.ts → oai-embedding.control-service.ts} +2 -2
  272. package/src/_modules/open-ai/_services/oai-llm-chat.service-base.ts +609 -0
  273. package/src/_modules/open-ai/_services/oai-llm.service-base.ts +648 -0
  274. package/src/_modules/open-ai/_services/{vector-data.service.ts → oai-vector-data.service.ts} +32 -5
  275. package/src/_modules/open-ai/index.ts +42 -4
  276. package/src/_modules/server/index.ts +18 -2
  277. package/src/_modules/server/server-status/server-status.controller.ts +13 -0
  278. package/src/_modules/socket/index.ts +23 -0
  279. package/src/_modules/test/index.ts +8 -0
  280. package/src/_modules/usage/index.ts +8 -0
  281. package/src/_services/server/app.server.ts +1 -1
  282. package/src/index.ts +28 -1
  283. package/build/_modules/open-ai/_services/embedding.control-service.d.ts.map +0 -1
  284. package/build/_modules/open-ai/_services/embedding.control-service.js.map +0 -1
  285. package/build/_modules/open-ai/_services/gpt.service-base.d.ts +0 -98
  286. package/build/_modules/open-ai/_services/gpt.service-base.d.ts.map +0 -1
  287. package/build/_modules/open-ai/_services/gpt.service-base.js +0 -284
  288. package/build/_modules/open-ai/_services/gpt.service-base.js.map +0 -1
  289. package/build/_modules/open-ai/_services/open-ai.service-base.d.ts +0 -21
  290. package/build/_modules/open-ai/_services/open-ai.service-base.d.ts.map +0 -1
  291. package/build/_modules/open-ai/_services/open-ai.service-base.js +0 -50
  292. package/build/_modules/open-ai/_services/open-ai.service-base.js.map +0 -1
  293. package/build/_modules/open-ai/_services/vector-data.service.d.ts.map +0 -1
  294. package/build/_modules/open-ai/_services/vector-data.service.js.map +0 -1
  295. package/build/_services/server/env-set.d.ts +0 -2
  296. package/build/_services/server/env-set.d.ts.map +0 -1
  297. package/build/_services/server/env-set.js +0 -20
  298. package/build/_services/server/env-set.js.map +0 -1
  299. package/src/_modules/open-ai/_services/gpt.service-base.ts +0 -438
  300. package/src/_modules/open-ai/_services/open-ai.service-base.ts +0 -69
  301. package/src/_services/server/env-set.ts +0 -21
@@ -0,0 +1,609 @@
1
+ import { OpenAI } from 'openai';
2
+
3
+ import { DyFM_OpenAI_Settings, DyFM_OpenAIModel, DyFM_GPTCall_Settings } from '@futdevpro/fsm-dynamo/open-ai';
4
+ import { DyFM_AnyError, DyFM_clone, DyFM_Error, DyFM_Error_Settings, DyFM_Log, DyFM_notNull } from '@futdevpro/fsm-dynamo';
5
+
6
+ import { DyNTS_global_settings } from '../../../_collections/global-settings.const';
7
+ import { DyNTS_OAI_GPT_Message } from '../_models/interfaces/oai-gpt-message.interface';
8
+ import { ChatCompletion } from 'openai/resources';
9
+ import { ChatCompletionCreateParamsBase, ChatCompletionMessageParam } from 'openai/resources/chat/completions';
10
+ import { DyNTS_OAI_GPT_Message_Role } from '../_enums/oai-gpt-message-role.enum';
11
+ import { DyNTS_OAI_LLM_Predefined_Requests } from '../_models/interfaces/oai-llm-predefined-requests.interface';
12
+ import { DyFM_safeParseJSON, DyFM_safeParseList, DyNTS_OAI_LLM_ServiceBase } from './oai-llm.service-base';
13
+ import { DyNTS_OAI_global_settings } from '../_collections/oai-global-settings.const';
14
+
15
+
16
+ /**
17
+ * {
18
+ * organization: 'org-XY',
19
+ * apiKey: 'sk-XY',
20
+ * project: 'proj_XY',
21
+ * }
22
+ */
23
+
24
+ // Di Dictionary DiModel DiEz DiAz
25
+
26
+ export class DyNTS_OAI_LLMChat_ServiceBase extends DyNTS_OAI_LLM_ServiceBase {
27
+
28
+ /**
29
+ * Asks the AI to answer a yes/no question
30
+ *
31
+ * Uses the {@link DyNTS_OAI_LLM_Predefined_Requests.yesNo.request} to ask the question,
32
+ * and the {@link DyNTS_OAI_LLM_Predefined_Requests.yesNo.upperCaseYes} to check the answer
33
+ */
34
+ async yesNoQuestionInConversation(
35
+ conversation: DyNTS_OAI_GPT_Message[],
36
+ question: string,
37
+ issuer: string,
38
+ debugLog?: boolean,
39
+ settings?: DyFM_GPTCall_Settings,
40
+ /** this is used to readably replace too long contents to eg '...' in logs */
41
+ replaceThisInLog?: string
42
+ ): Promise<boolean> {
43
+ question += this.predefinedRequests.yesNo.request;
44
+
45
+ this.logQuestion(question, replaceThisInLog, debugLog);
46
+
47
+ const answer = await this.getAnswerInConversation(
48
+ conversation,
49
+ question,
50
+ issuer,
51
+ settings,
52
+ debugLog,
53
+ replaceThisInLog
54
+ );
55
+
56
+ return answer.toUpperCase().includes(this.predefinedRequests.yesNo.upperCaseYes);
57
+ }
58
+
59
+ /**
60
+ * Asks the AI to answer a simple question
61
+ *
62
+ * Uses the {@link DyNTS_OAI_LLM_Predefined_Requests.simpleQuestion} to ask the question
63
+ */
64
+ async simpleQuestionInConversation(
65
+ conversation: DyNTS_OAI_GPT_Message[],
66
+ question: string,
67
+ issuer: string,
68
+ settings?: DyFM_GPTCall_Settings,
69
+ debugLog?: boolean,
70
+ /** this is used to readably replace too long contents to eg '...' in logs */
71
+ replaceThisInLog?: string
72
+ ): Promise<string> {
73
+ this.logQuestion(question, replaceThisInLog, debugLog);
74
+
75
+ return await this.getAnswerInConversation(
76
+ conversation,
77
+ question,
78
+ issuer,
79
+ settings,
80
+ debugLog,
81
+ replaceThisInLog
82
+ );
83
+ }
84
+
85
+ /**
86
+ * Asks the AI to answer a percentage question
87
+ *
88
+ * Uses the {@link DyNTS_OAI_LLM_Predefined_Requests.percentageOnly} to ask the question
89
+ */
90
+ async percentageQuestionInConversation(
91
+ conversation: DyNTS_OAI_GPT_Message[],
92
+ question: string,
93
+ issuer: string,
94
+ settings?: DyFM_GPTCall_Settings,
95
+ debugLog?: boolean,
96
+ /** this is used to readably replace too long contents to eg '...' in logs */
97
+ replaceThisInLog?: string
98
+ ): Promise<number> {
99
+ question += this.predefinedRequests.percentageOnly;
100
+
101
+ this.logQuestion(question, replaceThisInLog, debugLog);
102
+
103
+ const answer = await this.getAnswerInConversation(
104
+ conversation,
105
+ question,
106
+ issuer,
107
+ settings,
108
+ debugLog,
109
+ replaceThisInLog
110
+ );
111
+
112
+ if (isNaN(+answer)) {
113
+ DyFM_Log.error('GPT_ServiceBase', 'asykPercentageQuestion', 'Invalid answer', {
114
+ question,
115
+ answer,
116
+ });
117
+
118
+ return null;
119
+ }
120
+
121
+ return +answer;
122
+ }
123
+
124
+
125
+ /**
126
+ * Asks the AI to select one of the options from the list
127
+ *
128
+ * Uses the {@link DyNTS_OAI_LLM_Predefined_Requests.selectRequest} to ask the question
129
+ */
130
+ async selectQuestionInConversation(
131
+ conversation: DyNTS_OAI_GPT_Message[],
132
+ question: string,
133
+ selectFrom: string[],
134
+ issuer: string,
135
+ settings?: DyFM_GPTCall_Settings,
136
+ debugLog?: boolean,
137
+ /** this is used to readably replace too long contents to eg '...' in logs */
138
+ replaceThisInLog?: string
139
+ ): Promise<string> {
140
+ // replace the {{DyNTS_selectOptions}} with the list of options
141
+ const selectQuestionAddition = this.predefinedRequests.selectRequest.replace(
142
+ '{{DyNTS_selectOptions}}',
143
+ this.getTextListAsText(selectFrom)
144
+ );
145
+ question += selectQuestionAddition;
146
+
147
+ this.logQuestion(question, replaceThisInLog, debugLog);
148
+
149
+ let answer = await this.getAnswerInConversation(
150
+ conversation,
151
+ question,
152
+ issuer,
153
+ settings,
154
+ debugLog,
155
+ replaceThisInLog
156
+ );
157
+
158
+ answer = answer.toLocaleUpperCase();
159
+
160
+ for (const item of selectFrom) {
161
+ if (answer.includes(item.toLocaleUpperCase())) return item;
162
+ }
163
+
164
+ return null;
165
+ }
166
+
167
+ /**
168
+ * Asks the AI to select one of the options from the list
169
+ * Similar to {@link askSelectQuestion},
170
+ * but with a more generic approach that can be used for objects
171
+ *
172
+ * Uses the {@link DyNTS_OAI_LLM_Predefined_Requests.selectRequest} to ask the question
173
+ */
174
+ async requestSelectInConversation<T>(
175
+ conversation: DyNTS_OAI_GPT_Message[],
176
+ question: string,
177
+ selectFrom: T[],
178
+ issuer: string,
179
+ settings?: DyFM_GPTCall_Settings,
180
+ debugLog?: boolean,
181
+ /** this is used to readably replace too long contents to eg '...' in logs */
182
+ replaceThisInLog?: string,
183
+ ): Promise<T | { unparsableResult: string }> {
184
+ const selectQuestionAddition = this.predefinedRequests.selectRequest.replace(
185
+ '{{DyNTS_selectOptions}}',
186
+ this.getTextListAsText(selectFrom.map(item => `"${JSON.stringify(item)}"`))
187
+ );
188
+ question += selectQuestionAddition;
189
+
190
+ this.logQuestion(question, null, debugLog);
191
+
192
+ const answer = await this.getAnswerInConversation(
193
+ conversation,
194
+ question,
195
+ issuer,
196
+ settings,
197
+ debugLog,
198
+ replaceThisInLog
199
+ );
200
+
201
+ return DyFM_safeParseJSON<T>(answer);
202
+ }
203
+
204
+ /**
205
+ * Asks the AI to select one or more of the options from the list
206
+ *
207
+ * Uses the {@link DyNTS_OAI_LLM_Predefined_Requests.multiselect} to ask the question
208
+ */
209
+ async multipleSelectQuestionWithOptionsInConversation(
210
+ conversation: DyNTS_OAI_GPT_Message[],
211
+ question: string,
212
+ options: string[],
213
+ issuer: string,
214
+ settings?: DyFM_GPTCall_Settings,
215
+ debugLog?: boolean,
216
+ /** this is used to readably replace too long contents to eg '...' in logs */
217
+ replaceThisInLog?: string
218
+ ): Promise<string[]> {
219
+ const selectQuestionAddition = this.predefinedRequests.multiselect.replace(
220
+ '{{DyNTS_selectOptions}}',
221
+ this.getTextListAsText(options)
222
+ );
223
+ question += selectQuestionAddition;
224
+
225
+ let answer = await this.getAnswerInConversation(
226
+ conversation,
227
+ question,
228
+ issuer,
229
+ settings,
230
+ debugLog,
231
+ replaceThisInLog
232
+ );
233
+
234
+ answer = answer.toLocaleUpperCase();
235
+
236
+ const result: string[] = [];
237
+
238
+ for (const item of options) {
239
+ if (answer.includes(item.toLocaleUpperCase())) {
240
+ result.push(item);
241
+ }
242
+ }
243
+
244
+ return result;
245
+ }
246
+
247
+ /**
248
+ * Asks the AI to select one or more of the options from the list
249
+ * Similar to {@link askMultipleSelectQuestionWithOptions},
250
+ * but with a more generic approach that can be used for objects
251
+ *
252
+ * Uses the {@link DyNTS_OAI_LLM_Predefined_Requests.multiselect} to ask the question
253
+ */
254
+ async requestMultipleSelectInConversation<T>(
255
+ conversation: DyNTS_OAI_GPT_Message[],
256
+ question: string,
257
+ options: T[],
258
+ issuer: string,
259
+ settings?: DyFM_GPTCall_Settings,
260
+ debugLog?: boolean,
261
+ /** this is used to readably replace too long contents to eg '...' in logs */
262
+ replaceThisInLog?: string,
263
+ ): Promise<T[]> {
264
+ const selectQuestionAddition = this.predefinedRequests.multiselect.replace(
265
+ '{{DyNTS_selectOptions}}',
266
+ this.getTextListAsText(options.map(item => `"${JSON.stringify(item)}"`))
267
+ );
268
+ question += selectQuestionAddition;
269
+
270
+ this.logQuestion(question, null, debugLog);
271
+
272
+ const answer = await this.getAnswerInConversation(
273
+ conversation,
274
+ question,
275
+ issuer,
276
+ settings,
277
+ debugLog,
278
+ replaceThisInLog
279
+ );
280
+
281
+ return DyFM_safeParseList<T[]>(answer);
282
+ }
283
+
284
+ /**
285
+ * Asks the AI to answer a question that must result a JSON object
286
+ *
287
+ * If the answer is not a valid JSON object, it will return { unparsableResult: answer }
288
+ *
289
+ * Uses the {@link DyNTS_OAI_LLM_Predefined_Requests.jsonRequest} to ask the question
290
+ *
291
+ * (uses {@link DyFM_safeParseJSON})
292
+ */
293
+ async jsonQuestionInConversation<T = any>(
294
+ conversation: DyNTS_OAI_GPT_Message[],
295
+ question: string,
296
+ issuer: string,
297
+ settings?: DyFM_GPTCall_Settings,
298
+ debugLog?: boolean,
299
+ /** this is used to readably replace too long contents to eg '...' in logs */
300
+ replaceThisInLog?: string
301
+ ): Promise<T | { unparsableResult: string }> {
302
+ question += this.predefinedRequests.jsonRequest;
303
+
304
+ this.logQuestion(question, replaceThisInLog, debugLog);
305
+
306
+ const answer = await this.getAnswerInConversation(
307
+ conversation,
308
+ question,
309
+ issuer,
310
+ settings,
311
+ debugLog,
312
+ replaceThisInLog
313
+ );
314
+
315
+ return DyFM_safeParseJSON<T>(answer);
316
+ }
317
+
318
+ /**
319
+ * Asks the AI to answer a question that must result a JSON object with specific key descriptions
320
+ *
321
+ * If the answer is not a valid JSON object, it will return { unparsableResult: answer }
322
+ *
323
+ * Uses the {@link DyNTS_OAI_LLM_Predefined_Requests.jsonRequestWithKeysDescription} to ask the question
324
+ *
325
+ * (uses {@link DyFM_safeParseJSON})
326
+ */
327
+ async jsonQuestionWithKeysDescriptionInConversation<T = any>(
328
+ conversation: DyNTS_OAI_GPT_Message[],
329
+ question: string,
330
+ keysDescription: string,
331
+ issuer: string,
332
+ settings?: DyFM_GPTCall_Settings,
333
+ debugLog?: boolean,
334
+ /** this is used to readably replace too long contents to eg '...' in logs */
335
+ replaceThisInLog?: string
336
+ ): Promise<T | { unparsableResult: string }> {
337
+ const jsonRequestWithKeysDescription = this.predefinedRequests.jsonRequestWithKeysDescription.replace(
338
+ '{{DyNTS_jsonKeysDescription}}',
339
+ keysDescription
340
+ );
341
+ question += jsonRequestWithKeysDescription;
342
+
343
+ this.logQuestion(question, replaceThisInLog, debugLog);
344
+
345
+ const answer = await this.getAnswerInConversation(
346
+ conversation,
347
+ question,
348
+ issuer,
349
+ settings,
350
+ debugLog,
351
+ replaceThisInLog
352
+ );
353
+
354
+ return DyFM_safeParseJSON<T>(answer);
355
+ }
356
+
357
+ /**
358
+ * Asks the AI to answer a question that must result a JSON object with specific keys
359
+ *
360
+ * If the answer is not a valid JSON object, it will return { unparsableResult: answer }
361
+ *
362
+ * Uses the {@link DyNTS_OAI_LLM_Predefined_Requests.jsonRequestWithExactKeys} to ask the question
363
+ *
364
+ * (uses {@link DyFM_safeParseJSON})
365
+ */
366
+ async jsonQuestionWithExactKeysInConversation<T = any>(
367
+ conversation: DyNTS_OAI_GPT_Message[],
368
+ question: string,
369
+ keys: string[],
370
+ issuer: string,
371
+ settings?: DyFM_GPTCall_Settings,
372
+ debugLog?: boolean,
373
+ /** this is used to readably replace too long contents to eg '...' in logs */
374
+ replaceThisInLog?: string
375
+ ): Promise<T | { unparsableResult: string }> {
376
+ const jsonRequestWithExactKeys = this.predefinedRequests.jsonRequestWithExactKeys.replace(
377
+ '{{DyNTS_jsonKeys}}',
378
+ this.getTextListAsText(keys)
379
+ );
380
+ question += jsonRequestWithExactKeys;
381
+
382
+ this.logQuestion(question, replaceThisInLog, debugLog);
383
+
384
+ const answer = await this.getAnswerInConversation(
385
+ conversation,
386
+ question,
387
+ issuer,
388
+ settings,
389
+ debugLog,
390
+ replaceThisInLog
391
+ );
392
+
393
+ return DyFM_safeParseJSON<T>(answer);
394
+ }
395
+
396
+ /**
397
+ * Asks the AI to answer a question that must result a list of strings
398
+ *
399
+ * If the answer is not a valid JSON list, it will return the answer as a single item in an array
400
+ *
401
+ * Uses the {@link DyNTS_OAI_LLM_Predefined_Requests.listRequest} to ask the question
402
+ *
403
+ * (uses {@link DyFM_safeParseList})
404
+ */
405
+ async listQuestionInConversation(
406
+ conversation: DyNTS_OAI_GPT_Message[],
407
+ question: string,
408
+ issuer: string,
409
+ settings?: DyFM_GPTCall_Settings,
410
+ debugLog?: boolean,
411
+ /** this is used to readably replace too long contents to eg '...' in logs */
412
+ replaceThisInLog?: string,
413
+ ): Promise<string[]> {
414
+ question += this.predefinedRequests.listRequest;
415
+
416
+ this.logQuestion(question, replaceThisInLog, debugLog);
417
+
418
+ const answer = await this.getAnswerInConversation(
419
+ conversation,
420
+ question,
421
+ issuer,
422
+ settings,
423
+ debugLog,
424
+ replaceThisInLog
425
+ );
426
+
427
+ return DyFM_safeParseList(answer);
428
+ }
429
+
430
+ /**
431
+ * Asks the AI to answer a question
432
+ *
433
+ * Uses the {@link resolveSimpleUserMessage}
434
+ */
435
+ /* async getQuestionAnswerInConversation(
436
+ conversation: DyNTS_OAI_GPT_Message[],
437
+ question: string,
438
+ issuer: string,
439
+ debugLog?: boolean,
440
+ messageSettings: DyFM_GPTCall_Settings = this.defaultSettings
441
+ ): Promise<string> {
442
+ const answer = await this.resolveSimpleUserMessageInConversation(
443
+ conversation,
444
+ question,
445
+ issuer,
446
+ messageSettings,
447
+ ) as Promise<string>;
448
+
449
+ if (debugLog) {
450
+ console.log(' - ', answer);
451
+ }
452
+
453
+ return answer;
454
+ } */
455
+
456
+ /**
457
+ * Asks the AI to answer a question using the whole conversation
458
+ * (If you want to use only the conversation, without adding a new message,
459
+ * use directly the {@link resolveConversation})
460
+ *
461
+ * Uses the {@link resolveConversation}
462
+ */
463
+ async getAnswerInConversation(
464
+ conversation: DyNTS_OAI_GPT_Message[],
465
+ newMessage: string,
466
+ issuer: string,
467
+ settings?: DyFM_GPTCall_Settings,
468
+ debugLog?: boolean,
469
+ /** this is used to readably replace too long contents to eg '...' in logs */
470
+ replaceThisInLog?: string,
471
+ ): Promise<string> {
472
+ conversation.push({
473
+ role: DyNTS_OAI_GPT_Message_Role.user,
474
+ content: newMessage,
475
+ });
476
+
477
+ const answer: string = (await this.resolveConversation(
478
+ conversation,
479
+ issuer,
480
+ settings,
481
+ false,
482
+ debugLog,
483
+ replaceThisInLog,
484
+ )) as string;
485
+
486
+ if (debugLog || this.debugLog) {
487
+ console.log(' - answer: ', answer);
488
+ }
489
+
490
+ return answer;
491
+ }
492
+ getQuestionAnswerInConversation = this.getAnswerInConversation;
493
+ getQuestionInConversation = this.getAnswerInConversation;
494
+
495
+ /**
496
+ * Resolves a conversation
497
+ *
498
+ * Uses the {@link getMessageCreateInput}
499
+ */
500
+ async resolveConversation(
501
+ conversation: DyNTS_OAI_GPT_Message[],
502
+ issuer: string,
503
+ settings?: DyFM_GPTCall_Settings,
504
+ getFullResponse?: boolean,
505
+ debugLog?: boolean,
506
+ /** this is used to readably replace too long contents to eg '...' in logs */
507
+ replaceThisInLog?: string,
508
+ ): Promise<string | ChatCompletion> {
509
+ try {
510
+ conversation.unshift(this.getDefaultSystemMessage(settings));
511
+
512
+ // conversation shortening
513
+ const shortenedConversation = this.shortenConversation(conversation, issuer, debugLog);
514
+
515
+ this.logConversation(shortenedConversation, debugLog, replaceThisInLog);
516
+
517
+ const result: ChatCompletion = await this.openai.chat.completions.create(
518
+ this.getMessageCreateInput(shortenedConversation, issuer, settings)
519
+ ) as ChatCompletion;
520
+
521
+ if (getFullResponse) {
522
+ return result;
523
+ }
524
+
525
+ return result.choices[0].message.content;
526
+ } catch (error) {
527
+ throw new DyFM_Error({
528
+ ...this.getDefaultErrorSettings('resolveConversation', error, issuer),
529
+
530
+ errorCode: `${DyNTS_global_settings.systemShortCodeName}|DyNTS-OAB-RC0`,
531
+ });
532
+ }
533
+ }
534
+ resolveSimpleUserMessageInConversation = this.resolveConversation;
535
+
536
+ protected shortenConversation(
537
+ conversation: DyNTS_OAI_GPT_Message[],
538
+ issuer: string,
539
+ debugLog?: boolean,
540
+ ): DyNTS_OAI_GPT_Message[] {
541
+ try {
542
+ const clonedConversation = DyFM_clone(conversation);
543
+ const systemMessages = clonedConversation.filter(
544
+ message => message.role === DyNTS_OAI_GPT_Message_Role.system
545
+ );
546
+ const systemMessagesStringLength = JSON.stringify(systemMessages).length;
547
+ const msgs: string[] = clonedConversation.filter(
548
+ message => message.role !== DyNTS_OAI_GPT_Message_Role.system
549
+ ).map(message => message.content);
550
+ let stringifiedMessages = JSON.stringify(msgs);
551
+
552
+ if (this.debugLog || debugLog) {
553
+ console.log('stringifiedMessagesCount before removing', stringifiedMessages.length);
554
+ }
555
+
556
+ let removedMessagesCount = 0;
557
+ let lastStringifiedMessagesLength = stringifiedMessages.length;
558
+
559
+ while (
560
+ (stringifiedMessages.length + systemMessagesStringLength) > DyNTS_OAI_global_settings.maxMessagesStringLength &&
561
+ clonedConversation.length > 1
562
+ ) {
563
+ clonedConversation.splice(0, 1);
564
+ msgs.splice(0, 1);
565
+ removedMessagesCount++;
566
+ stringifiedMessages = JSON.stringify(msgs);
567
+ lastStringifiedMessagesLength = stringifiedMessages.length;
568
+ }
569
+
570
+ if (this.debugLog || debugLog) {
571
+ console.log('removedMessagesCount', removedMessagesCount);
572
+ console.log('lastStringifiedMessagesLength', lastStringifiedMessagesLength);
573
+ }
574
+
575
+ if (!clonedConversation.length) {
576
+ DyFM_Log.error('No conversation messages (left)', {
577
+ /* conversation: DyFM_clone(conversation), */
578
+ conversationLength: conversation.length,
579
+ clonedConversation: DyFM_clone(clonedConversation),
580
+ });
581
+ throw new Error('No conversation messages (left)');
582
+ }
583
+
584
+ return [ ...systemMessages, ...clonedConversation ];
585
+ } catch (error) {
586
+ console.error('❌❌ Error shortening conversation:', error);
587
+ throw new DyFM_Error({
588
+ ...this.getDefaultErrorSettings('shortenConversation', error, issuer),
589
+
590
+ errorCode: `${DyNTS_global_settings.systemShortCodeName}|DyNTS-OAB-SC0`,
591
+ });
592
+ }
593
+ }
594
+
595
+ protected logConversation(
596
+ conversation: DyNTS_OAI_GPT_Message[],
597
+ debugLog?: boolean,
598
+ /** this is used to readably replace too long contents to eg '...' in logs */
599
+ replaceThisInLog?: string,
600
+ ) {
601
+ if (debugLog || this.debugLog) {
602
+ conversation.forEach(message => {
603
+ console.log(
604
+ ` - ${message.role}: ${message.content.replace(replaceThisInLog, this.defaultLogReplacer)}`
605
+ );
606
+ });
607
+ }
608
+ }
609
+ }