@futdevpro/nts-dynamo 1.12.15 → 1.14.2

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 (247) hide show
  1. package/build/_modules/ai/_models/ai-input-interfaces.d.ts +61 -0
  2. package/build/_modules/ai/_models/ai-input-interfaces.d.ts.map +1 -0
  3. package/build/_modules/{open-ai/_models/interfaces/oai-document-page.interface.js → ai/_models/ai-input-interfaces.js} +1 -1
  4. package/build/_modules/ai/_models/ai-input-interfaces.js.map +1 -0
  5. package/build/_modules/{open-ai/_collections/oai-chunking.util.d.ts → ai/_modules/document-ai/_collections/dai-chunking.util.d.ts} +10 -10
  6. package/build/_modules/ai/_modules/document-ai/_collections/dai-chunking.util.d.ts.map +1 -0
  7. package/build/_modules/{open-ai/_collections/oai-chunking.util.js → ai/_modules/document-ai/_collections/dai-chunking.util.js} +58 -41
  8. package/build/_modules/ai/_modules/document-ai/_collections/dai-chunking.util.js.map +1 -0
  9. package/build/_modules/ai/_modules/document-ai/_collections/dai-document.util.d.ts +29 -0
  10. package/build/_modules/ai/_modules/document-ai/_collections/dai-document.util.d.ts.map +1 -0
  11. package/build/_modules/ai/_modules/document-ai/_collections/dai-document.util.js +74 -0
  12. package/build/_modules/ai/_modules/document-ai/_collections/dai-document.util.js.map +1 -0
  13. package/build/_modules/ai/_modules/document-ai/_enums/dai-compare-result-type.enum.d.ts +7 -0
  14. package/build/_modules/ai/_modules/document-ai/_enums/dai-compare-result-type.enum.d.ts.map +1 -0
  15. package/build/_modules/ai/_modules/document-ai/_enums/dai-compare-result-type.enum.js +11 -0
  16. package/build/_modules/ai/_modules/document-ai/_enums/dai-compare-result-type.enum.js.map +1 -0
  17. package/build/_modules/{open-ai/_models/oai-doc-chunk.data-model.d.ts → ai/_modules/document-ai/_models/data-models/dai-doc-chunk.data-model.d.ts} +25 -13
  18. package/build/_modules/ai/_modules/document-ai/_models/data-models/dai-doc-chunk.data-model.d.ts.map +1 -0
  19. package/build/_modules/ai/_modules/document-ai/_models/data-models/dai-doc-chunk.data-model.js +132 -0
  20. package/build/_modules/ai/_modules/document-ai/_models/data-models/dai-doc-chunk.data-model.js.map +1 -0
  21. package/build/_modules/ai/_modules/document-ai/_models/data-models/dai-doc-page.data-model.d.ts +29 -0
  22. package/build/_modules/ai/_modules/document-ai/_models/data-models/dai-doc-page.data-model.d.ts.map +1 -0
  23. package/build/_modules/ai/_modules/document-ai/_models/data-models/dai-doc-page.data-model.js +112 -0
  24. package/build/_modules/ai/_modules/document-ai/_models/data-models/dai-doc-page.data-model.js.map +1 -0
  25. package/build/_modules/ai/_modules/document-ai/_models/data-models/dai-document.data-model.d.ts +18 -0
  26. package/build/_modules/ai/_modules/document-ai/_models/data-models/dai-document.data-model.d.ts.map +1 -0
  27. package/build/_modules/ai/_modules/document-ai/_models/data-models/dai-document.data-model.js +71 -0
  28. package/build/_modules/ai/_modules/document-ai/_models/data-models/dai-document.data-model.js.map +1 -0
  29. package/build/_modules/ai/_modules/document-ai/_models/interfaces/dai-doc-chunk-compare-result.interface.d.ts +9 -0
  30. package/build/_modules/ai/_modules/document-ai/_models/interfaces/dai-doc-chunk-compare-result.interface.d.ts.map +1 -0
  31. package/build/_modules/ai/_modules/document-ai/_models/interfaces/dai-doc-chunk-compare-result.interface.js +3 -0
  32. package/build/_modules/ai/_modules/document-ai/_models/interfaces/dai-doc-chunk-compare-result.interface.js.map +1 -0
  33. package/build/_modules/ai/_modules/document-ai/_models/interfaces/dai-doc-page-compare-result.interface.d.ts +12 -0
  34. package/build/_modules/ai/_modules/document-ai/_models/interfaces/dai-doc-page-compare-result.interface.d.ts.map +1 -0
  35. package/build/_modules/{open-ai/_models/interfaces/oai-chunk-compare-result.interface.js → ai/_modules/document-ai/_models/interfaces/dai-doc-page-compare-result.interface.js} +1 -1
  36. package/build/_modules/ai/_modules/document-ai/_models/interfaces/dai-doc-page-compare-result.interface.js.map +1 -0
  37. package/build/_modules/ai/_modules/document-ai/_models/interfaces/dai-document-compare-result.interface.d.ts +13 -0
  38. package/build/_modules/ai/_modules/document-ai/_models/interfaces/dai-document-compare-result.interface.d.ts.map +1 -0
  39. package/build/_modules/ai/_modules/document-ai/_models/interfaces/dai-document-compare-result.interface.js +3 -0
  40. package/build/_modules/ai/_modules/document-ai/_models/interfaces/dai-document-compare-result.interface.js.map +1 -0
  41. package/build/_modules/ai/_modules/document-ai/index.d.ts +11 -0
  42. package/build/_modules/ai/_modules/document-ai/index.d.ts.map +1 -0
  43. package/build/_modules/ai/_modules/document-ai/index.js +26 -0
  44. package/build/_modules/ai/_modules/document-ai/index.js.map +1 -0
  45. package/build/_modules/ai/_modules/open-ai/_collections/oai-global-settings.const.d.ts.map +1 -0
  46. package/build/_modules/{open-ai → ai/_modules/open-ai}/_collections/oai-global-settings.const.js +2 -2
  47. package/build/_modules/ai/_modules/open-ai/_collections/oai-global-settings.const.js.map +1 -0
  48. package/build/_modules/ai/_modules/open-ai/_collections/oai-llm-predefined-requests-hu.conts.d.ts.map +1 -0
  49. package/build/_modules/ai/_modules/open-ai/_collections/oai-llm-predefined-requests-hu.conts.js.map +1 -0
  50. package/build/_modules/ai/_modules/open-ai/_collections/oai-llm-predefined-requests.conts.d.ts.map +1 -0
  51. package/build/_modules/ai/_modules/open-ai/_collections/oai-llm-predefined-requests.conts.js.map +1 -0
  52. package/build/_modules/ai/_modules/open-ai/_enums/oai-gpt-message-role.enum.d.ts.map +1 -0
  53. package/build/_modules/ai/_modules/open-ai/_enums/oai-gpt-message-role.enum.js.map +1 -0
  54. package/build/_modules/ai/_modules/open-ai/_models/interfaces/oai-global-settings.interface.d.ts +6 -0
  55. package/build/_modules/ai/_modules/open-ai/_models/interfaces/oai-global-settings.interface.d.ts.map +1 -0
  56. package/build/_modules/ai/_modules/open-ai/_models/interfaces/oai-global-settings.interface.js.map +1 -0
  57. package/build/_modules/ai/_modules/open-ai/_models/interfaces/oai-gpt-message.interface.d.ts.map +1 -0
  58. package/build/_modules/ai/_modules/open-ai/_models/interfaces/oai-gpt-message.interface.js.map +1 -0
  59. package/build/_modules/ai/_modules/open-ai/_models/interfaces/oai-llm-predefined-requests.interface.d.ts.map +1 -0
  60. package/build/_modules/ai/_modules/open-ai/_models/interfaces/oai-llm-predefined-requests.interface.js.map +1 -0
  61. package/build/_modules/ai/_modules/open-ai/_services/oai-doc-chunk-data.service.d.ts +22 -0
  62. package/build/_modules/ai/_modules/open-ai/_services/oai-doc-chunk-data.service.d.ts.map +1 -0
  63. package/build/_modules/ai/_modules/open-ai/_services/oai-doc-chunk-data.service.js +223 -0
  64. package/build/_modules/ai/_modules/open-ai/_services/oai-doc-chunk-data.service.js.map +1 -0
  65. package/build/_modules/ai/_modules/open-ai/_services/oai-doc-page.data-service.d.ts +26 -0
  66. package/build/_modules/ai/_modules/open-ai/_services/oai-doc-page.data-service.d.ts.map +1 -0
  67. package/build/_modules/ai/_modules/open-ai/_services/oai-doc-page.data-service.js +232 -0
  68. package/build/_modules/ai/_modules/open-ai/_services/oai-doc-page.data-service.js.map +1 -0
  69. package/build/_modules/ai/_modules/open-ai/_services/oai-document.data-service.d.ts +23 -0
  70. package/build/_modules/ai/_modules/open-ai/_services/oai-document.data-service.d.ts.map +1 -0
  71. package/build/_modules/ai/_modules/open-ai/_services/oai-document.data-service.js +284 -0
  72. package/build/_modules/ai/_modules/open-ai/_services/oai-document.data-service.js.map +1 -0
  73. package/build/_modules/ai/_modules/open-ai/_services/oai-embedding.control-service.d.ts +7 -0
  74. package/build/_modules/ai/_modules/open-ai/_services/oai-embedding.control-service.d.ts.map +1 -0
  75. package/build/_modules/{open-ai → ai/_modules/open-ai}/_services/oai-embedding.control-service.js +5 -5
  76. package/build/_modules/ai/_modules/open-ai/_services/oai-embedding.control-service.js.map +1 -0
  77. package/build/_modules/{open-ai → ai/_modules/open-ai}/_services/oai-llm-chat.service-base.d.ts +16 -16
  78. package/build/_modules/ai/_modules/open-ai/_services/oai-llm-chat.service-base.d.ts.map +1 -0
  79. package/build/_modules/{open-ai → ai/_modules/open-ai}/_services/oai-llm-chat.service-base.js +3 -3
  80. package/build/_modules/ai/_modules/open-ai/_services/oai-llm-chat.service-base.js.map +1 -0
  81. package/build/_modules/{open-ai → ai/_modules/open-ai}/_services/oai-llm.service-base.d.ts +19 -19
  82. package/build/_modules/ai/_modules/open-ai/_services/oai-llm.service-base.d.ts.map +1 -0
  83. package/build/_modules/{open-ai → ai/_modules/open-ai}/_services/oai-llm.service-base.js +6 -6
  84. package/build/_modules/ai/_modules/open-ai/_services/oai-llm.service-base.js.map +1 -0
  85. package/build/_modules/{open-ai → ai/_modules/open-ai}/_services/oai-vector-data.service.d.ts +6 -6
  86. package/build/_modules/ai/_modules/open-ai/_services/oai-vector-data.service.d.ts.map +1 -0
  87. package/build/_modules/{open-ai → ai/_modules/open-ai}/_services/oai-vector-data.service.js +138 -6
  88. package/build/_modules/ai/_modules/open-ai/_services/oai-vector-data.service.js.map +1 -0
  89. package/build/_modules/{open-ai → ai/_modules/open-ai}/index.d.ts +4 -10
  90. package/build/_modules/ai/_modules/open-ai/index.d.ts.map +1 -0
  91. package/build/_modules/{open-ai → ai/_modules/open-ai}/index.js +22 -11
  92. package/build/_modules/ai/_modules/open-ai/index.js.map +1 -0
  93. package/build/_modules/ai/_services/ai-embedding.service-base.d.ts +31 -0
  94. package/build/_modules/ai/_services/ai-embedding.service-base.d.ts.map +1 -0
  95. package/build/_modules/ai/_services/ai-embedding.service-base.js +12 -0
  96. package/build/_modules/ai/_services/ai-embedding.service-base.js.map +1 -0
  97. package/build/_modules/ai/_services/ai-llm-chat.service-base.d.ts +36 -0
  98. package/build/_modules/ai/_services/ai-llm-chat.service-base.d.ts.map +1 -0
  99. package/build/_modules/ai/_services/ai-llm-chat.service-base.js +12 -0
  100. package/build/_modules/ai/_services/ai-llm-chat.service-base.js.map +1 -0
  101. package/build/_modules/ai/_services/ai-llm.service-base.d.ts +45 -0
  102. package/build/_modules/ai/_services/ai-llm.service-base.d.ts.map +1 -0
  103. package/build/_modules/ai/_services/ai-llm.service-base.js +12 -0
  104. package/build/_modules/ai/_services/ai-llm.service-base.js.map +1 -0
  105. package/build/_modules/ai/_services/ai-provider.service-base.d.ts +25 -0
  106. package/build/_modules/ai/_services/ai-provider.service-base.d.ts.map +1 -0
  107. package/build/_modules/ai/_services/ai-provider.service-base.js +11 -0
  108. package/build/_modules/ai/_services/ai-provider.service-base.js.map +1 -0
  109. package/build/_modules/ai/index.d.ts +7 -0
  110. package/build/_modules/ai/index.d.ts.map +1 -0
  111. package/build/_modules/ai/index.js +13 -0
  112. package/build/_modules/ai/index.js.map +1 -0
  113. package/build/_modules/discord-assistant/_collections/dias-global-settings.const.js +2 -2
  114. package/build/_modules/discord-assistant/_collections/dias-global-settings.const.js.map +1 -1
  115. package/build/_modules/discord-assistant/_collections/dias.util.d.ts +1 -1
  116. package/build/_modules/discord-assistant/_collections/dias.util.d.ts.map +1 -1
  117. package/build/_modules/discord-assistant/_collections/dias.util.js +5 -5
  118. package/build/_modules/discord-assistant/_collections/dias.util.js.map +1 -1
  119. package/build/_modules/discord-assistant/_services/dias-chunk.data-service.d.ts +9 -9
  120. package/build/_modules/discord-assistant/_services/dias-chunk.data-service.d.ts.map +1 -1
  121. package/build/_modules/discord-assistant/_services/dias-chunk.data-service.js +11 -10
  122. package/build/_modules/discord-assistant/_services/dias-chunk.data-service.js.map +1 -1
  123. package/build/_modules/discord-assistant/_services/dias-io.control-service.d.ts +2 -2
  124. package/build/_modules/discord-assistant/_services/dias-io.control-service.d.ts.map +1 -1
  125. package/build/_modules/discord-assistant/_services/dias-io.control-service.js +2 -2
  126. package/build/_modules/discord-assistant/_services/dias-io.control-service.js.map +1 -1
  127. package/build/_modules/discord-assistant/_services/dias.service-base.d.ts +2 -2
  128. package/build/_modules/discord-assistant/_services/dias.service-base.d.ts.map +1 -1
  129. package/build/_modules/discord-assistant/_services/dias.service-base.js +1 -1
  130. package/build/_modules/discord-assistant/_services/dias.service-base.js.map +1 -1
  131. package/build/_modules/discord-assistant/index.d.ts +2 -1
  132. package/build/_modules/discord-assistant/index.d.ts.map +1 -1
  133. package/build/_modules/discord-assistant/index.js +2 -1
  134. package/build/_modules/discord-assistant/index.js.map +1 -1
  135. package/package.json +32 -12
  136. package/src/_modules/ai/_models/ai-input-interfaces.ts +79 -0
  137. package/src/_modules/{open-ai/_collections/oai-chunking.util.ts → ai/_modules/document-ai/_collections/dai-chunking.util.ts} +139 -90
  138. package/src/_modules/ai/_modules/document-ai/_collections/dai-document.util.ts +85 -0
  139. package/src/_modules/ai/_modules/document-ai/_enums/dai-compare-result-type.enum.ts +8 -0
  140. package/src/_modules/ai/_modules/document-ai/_models/data-models/dai-doc-chunk.data-model.ts +144 -0
  141. package/src/_modules/ai/_modules/document-ai/_models/data-models/dai-doc-page.data-model.ts +136 -0
  142. package/src/_modules/ai/_modules/document-ai/_models/data-models/dai-document.data-model.ts +93 -0
  143. package/src/_modules/ai/_modules/document-ai/_models/interfaces/dai-doc-chunk-compare-result.interface.ts +18 -0
  144. package/src/_modules/ai/_modules/document-ai/_models/interfaces/dai-doc-page-compare-result.interface.ts +19 -0
  145. package/src/_modules/ai/_modules/document-ai/_models/interfaces/dai-document-compare-result.interface.ts +25 -0
  146. package/src/_modules/ai/_modules/document-ai/index.ts +28 -0
  147. package/src/_modules/{open-ai → ai/_modules/open-ai}/_collections/oai-global-settings.const.ts +2 -2
  148. package/src/_modules/ai/_modules/open-ai/_models/interfaces/oai-global-settings.interface.ts +8 -0
  149. package/src/_modules/ai/_modules/open-ai/_services/oai-doc-chunk-data.service.ts +284 -0
  150. package/src/_modules/ai/_modules/open-ai/_services/oai-doc-page.data-service.ts +508 -0
  151. package/src/_modules/ai/_modules/open-ai/_services/oai-document.data-service.ts +377 -0
  152. package/src/_modules/{open-ai → ai/_modules/open-ai}/_services/oai-embedding.control-service.ts +6 -6
  153. package/src/_modules/{open-ai → ai/_modules/open-ai}/_services/oai-llm-chat.service-base.ts +20 -19
  154. package/src/_modules/{open-ai → ai/_modules/open-ai}/_services/oai-llm.service-base.ts +24 -24
  155. package/src/_modules/{open-ai → ai/_modules/open-ai}/_services/oai-vector-data.service.ts +145 -9
  156. package/src/_modules/ai/_modules/open-ai/index.ts +72 -0
  157. package/src/_modules/ai/_services/ai-embedding.service-base.ts +41 -0
  158. package/src/_modules/ai/_services/ai-llm-chat.service-base.ts +48 -0
  159. package/src/_modules/ai/_services/ai-llm.service-base.ts +81 -0
  160. package/src/_modules/ai/_services/ai-provider.service-base.ts +28 -0
  161. package/src/_modules/ai/index.ts +11 -0
  162. package/src/_modules/discord-assistant/_collections/dias-global-settings.const.ts +2 -2
  163. package/src/_modules/discord-assistant/_collections/dias.util.ts +5 -3
  164. package/src/_modules/discord-assistant/_services/dias-chunk.data-service.ts +25 -18
  165. package/src/_modules/discord-assistant/_services/dias-io.control-service.ts +5 -3
  166. package/src/_modules/discord-assistant/_services/dias.service-base.ts +3 -3
  167. package/src/_modules/discord-assistant/index.ts +2 -1
  168. package/src/index.ts +0 -4
  169. package/build/_modules/open-ai/_collections/oai-chunking.util.d.ts.map +0 -1
  170. package/build/_modules/open-ai/_collections/oai-chunking.util.js.map +0 -1
  171. package/build/_modules/open-ai/_collections/oai-document.util.d.ts +0 -4
  172. package/build/_modules/open-ai/_collections/oai-document.util.d.ts.map +0 -1
  173. package/build/_modules/open-ai/_collections/oai-document.util.js +0 -12
  174. package/build/_modules/open-ai/_collections/oai-document.util.js.map +0 -1
  175. package/build/_modules/open-ai/_collections/oai-global-settings.const.d.ts.map +0 -1
  176. package/build/_modules/open-ai/_collections/oai-global-settings.const.js.map +0 -1
  177. package/build/_modules/open-ai/_collections/oai-llm-predefined-requests-hu.conts.d.ts.map +0 -1
  178. package/build/_modules/open-ai/_collections/oai-llm-predefined-requests-hu.conts.js.map +0 -1
  179. package/build/_modules/open-ai/_collections/oai-llm-predefined-requests.conts.d.ts.map +0 -1
  180. package/build/_modules/open-ai/_collections/oai-llm-predefined-requests.conts.js.map +0 -1
  181. package/build/_modules/open-ai/_enums/oai-compare-result-type.enum.d.ts +0 -6
  182. package/build/_modules/open-ai/_enums/oai-compare-result-type.enum.d.ts.map +0 -1
  183. package/build/_modules/open-ai/_enums/oai-compare-result-type.enum.js +0 -10
  184. package/build/_modules/open-ai/_enums/oai-compare-result-type.enum.js.map +0 -1
  185. package/build/_modules/open-ai/_enums/oai-gpt-message-role.enum.d.ts.map +0 -1
  186. package/build/_modules/open-ai/_enums/oai-gpt-message-role.enum.js.map +0 -1
  187. package/build/_modules/open-ai/_models/interfaces/oai-chunk-compare-result.interface.d.ts +0 -7
  188. package/build/_modules/open-ai/_models/interfaces/oai-chunk-compare-result.interface.d.ts.map +0 -1
  189. package/build/_modules/open-ai/_models/interfaces/oai-chunk-compare-result.interface.js.map +0 -1
  190. package/build/_modules/open-ai/_models/interfaces/oai-document-page.interface.d.ts +0 -15
  191. package/build/_modules/open-ai/_models/interfaces/oai-document-page.interface.d.ts.map +0 -1
  192. package/build/_modules/open-ai/_models/interfaces/oai-document-page.interface.js.map +0 -1
  193. package/build/_modules/open-ai/_models/interfaces/oai-global-settings.interface.d.ts +0 -6
  194. package/build/_modules/open-ai/_models/interfaces/oai-global-settings.interface.d.ts.map +0 -1
  195. package/build/_modules/open-ai/_models/interfaces/oai-global-settings.interface.js.map +0 -1
  196. package/build/_modules/open-ai/_models/interfaces/oai-gpt-message.interface.d.ts.map +0 -1
  197. package/build/_modules/open-ai/_models/interfaces/oai-gpt-message.interface.js.map +0 -1
  198. package/build/_modules/open-ai/_models/interfaces/oai-llm-predefined-requests.interface.d.ts.map +0 -1
  199. package/build/_modules/open-ai/_models/interfaces/oai-llm-predefined-requests.interface.js.map +0 -1
  200. package/build/_modules/open-ai/_models/interfaces/oai-page-compare-result.interface.d.ts +0 -13
  201. package/build/_modules/open-ai/_models/interfaces/oai-page-compare-result.interface.d.ts.map +0 -1
  202. package/build/_modules/open-ai/_models/interfaces/oai-page-compare-result.interface.js +0 -3
  203. package/build/_modules/open-ai/_models/interfaces/oai-page-compare-result.interface.js.map +0 -1
  204. package/build/_modules/open-ai/_models/oai-doc-chunk.data-model.d.ts.map +0 -1
  205. package/build/_modules/open-ai/_models/oai-doc-chunk.data-model.js +0 -101
  206. package/build/_modules/open-ai/_models/oai-doc-chunk.data-model.js.map +0 -1
  207. package/build/_modules/open-ai/_services/oai-chunk.service-base.d.ts +0 -16
  208. package/build/_modules/open-ai/_services/oai-chunk.service-base.d.ts.map +0 -1
  209. package/build/_modules/open-ai/_services/oai-chunk.service-base.js +0 -200
  210. package/build/_modules/open-ai/_services/oai-chunk.service-base.js.map +0 -1
  211. package/build/_modules/open-ai/_services/oai-embedding.control-service.d.ts +0 -7
  212. package/build/_modules/open-ai/_services/oai-embedding.control-service.d.ts.map +0 -1
  213. package/build/_modules/open-ai/_services/oai-embedding.control-service.js.map +0 -1
  214. package/build/_modules/open-ai/_services/oai-llm-chat.service-base.d.ts.map +0 -1
  215. package/build/_modules/open-ai/_services/oai-llm-chat.service-base.js.map +0 -1
  216. package/build/_modules/open-ai/_services/oai-llm.service-base.d.ts.map +0 -1
  217. package/build/_modules/open-ai/_services/oai-llm.service-base.js.map +0 -1
  218. package/build/_modules/open-ai/_services/oai-vector-data.service.d.ts.map +0 -1
  219. package/build/_modules/open-ai/_services/oai-vector-data.service.js.map +0 -1
  220. package/build/_modules/open-ai/index.d.ts.map +0 -1
  221. package/build/_modules/open-ai/index.js.map +0 -1
  222. package/src/_modules/open-ai/_collections/oai-document.util.ts +0 -10
  223. package/src/_modules/open-ai/_enums/oai-compare-result-type.enum.ts +0 -7
  224. package/src/_modules/open-ai/_models/interfaces/oai-chunk-compare-result.interface.ts +0 -15
  225. package/src/_modules/open-ai/_models/interfaces/oai-document-page.interface.ts +0 -28
  226. package/src/_modules/open-ai/_models/interfaces/oai-global-settings.interface.ts +0 -8
  227. package/src/_modules/open-ai/_models/interfaces/oai-page-compare-result.interface.ts +0 -17
  228. package/src/_modules/open-ai/_models/oai-doc-chunk.data-model.ts +0 -115
  229. package/src/_modules/open-ai/_services/oai-chunk.service-base.ts +0 -280
  230. package/src/_modules/open-ai/index.ts +0 -55
  231. /package/build/_modules/{open-ai → ai/_modules/open-ai}/_collections/oai-global-settings.const.d.ts +0 -0
  232. /package/build/_modules/{open-ai → ai/_modules/open-ai}/_collections/oai-llm-predefined-requests-hu.conts.d.ts +0 -0
  233. /package/build/_modules/{open-ai → ai/_modules/open-ai}/_collections/oai-llm-predefined-requests-hu.conts.js +0 -0
  234. /package/build/_modules/{open-ai → ai/_modules/open-ai}/_collections/oai-llm-predefined-requests.conts.d.ts +0 -0
  235. /package/build/_modules/{open-ai → ai/_modules/open-ai}/_collections/oai-llm-predefined-requests.conts.js +0 -0
  236. /package/build/_modules/{open-ai → ai/_modules/open-ai}/_enums/oai-gpt-message-role.enum.d.ts +0 -0
  237. /package/build/_modules/{open-ai → ai/_modules/open-ai}/_enums/oai-gpt-message-role.enum.js +0 -0
  238. /package/build/_modules/{open-ai → ai/_modules/open-ai}/_models/interfaces/oai-global-settings.interface.js +0 -0
  239. /package/build/_modules/{open-ai → ai/_modules/open-ai}/_models/interfaces/oai-gpt-message.interface.d.ts +0 -0
  240. /package/build/_modules/{open-ai → ai/_modules/open-ai}/_models/interfaces/oai-gpt-message.interface.js +0 -0
  241. /package/build/_modules/{open-ai → ai/_modules/open-ai}/_models/interfaces/oai-llm-predefined-requests.interface.d.ts +0 -0
  242. /package/build/_modules/{open-ai → ai/_modules/open-ai}/_models/interfaces/oai-llm-predefined-requests.interface.js +0 -0
  243. /package/src/_modules/{open-ai → ai/_modules/open-ai}/_collections/oai-llm-predefined-requests-hu.conts.ts +0 -0
  244. /package/src/_modules/{open-ai → ai/_modules/open-ai}/_collections/oai-llm-predefined-requests.conts.ts +0 -0
  245. /package/src/_modules/{open-ai → ai/_modules/open-ai}/_enums/oai-gpt-message-role.enum.ts +0 -0
  246. /package/src/_modules/{open-ai → ai/_modules/open-ai}/_models/interfaces/oai-gpt-message.interface.ts +0 -0
  247. /package/src/_modules/{open-ai → ai/_modules/open-ai}/_models/interfaces/oai-llm-predefined-requests.interface.ts +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@futdevpro/nts-dynamo",
3
- "version": "01.12.15",
3
+ "version": "01.14.02",
4
4
  "description": "Dynamic NodeTS (NodeJS-Typescript), MongoDB Backend System Framework by Future Development Program Ltd.",
5
5
  "DyBu_settings": {
6
6
  "packageType": "server-package",
@@ -42,6 +42,25 @@
42
42
  "types": "./build/index.d.ts",
43
43
  "typings": "./build/index.d.ts"
44
44
  },
45
+ "./ai": {
46
+ "default": "./build/_modules/ai/index.js",
47
+ "module": "./build/_modules/ai/index.js",
48
+ "types": "./build/_modules/ai/index.d.ts",
49
+ "typings": "./build/_modules/ai/index.d.ts"
50
+ },
51
+ "./ai/document-ai": {
52
+ "default": "./build/_modules/ai/_modules/document-ai/index.js",
53
+ "module": "./build/_modules/ai/_modules/document-ai/index.js",
54
+ "types": "./build/_modules/ai/_modules/document-ai/index.d.ts",
55
+ "typings": "./build/_modules/ai/_modules/document-ai/index.d.ts"
56
+ },
57
+ "./ai/open-ai": {
58
+ "default": "./build/_modules/ai/_modules/open-ai/index.js",
59
+ "module": "./build/_modules/ai/_modules/open-ai/index.js",
60
+ "types": "./build/_modules/ai/_modules/open-ai/index.d.ts",
61
+ "typings": "./build/_modules/ai/_modules/open-ai/index.d.ts"
62
+ },
63
+
45
64
  "./custom-data": {
46
65
  "default": "./build/_modules/custom-data/index.js",
47
66
  "module": "./build/_modules/custom-data/index.js",
@@ -78,12 +97,6 @@
78
97
  "types": "./build/_modules/oauth2/index.d.ts",
79
98
  "typings": "./build/_modules/oauth2/index.d.ts"
80
99
  },
81
- "./open-ai": {
82
- "default": "./build/_modules/open-ai/index.js",
83
- "module": "./build/_modules/open-ai/index.js",
84
- "types": "./build/_modules/open-ai/index.d.ts",
85
- "typings": "./build/_modules/open-ai/index.d.ts"
86
- },
87
100
  "./server": {
88
101
  "default": "./build/_modules/server/index.js",
89
102
  "module": "./build/_modules/server/index.js",
@@ -111,6 +124,16 @@
111
124
  },
112
125
  "typesVersions": {
113
126
  "*": {
127
+ "ai": [
128
+ "build/_modules/ai/index.d.ts"
129
+ ],
130
+ "ai/document-ai": [
131
+ "build/_modules/ai/_modules/document-ai/index.d.ts"
132
+ ],
133
+ "ai/open-ai": [
134
+ "build/_modules/ai/_modules/open-ai/index.d.ts"
135
+ ],
136
+
114
137
  "custom-data": [
115
138
  "build/_modules/custom-data/index.d.ts"
116
139
  ],
@@ -129,9 +152,6 @@
129
152
  "oauth2": [
130
153
  "build/_modules/oauth2/index.d.ts"
131
154
  ],
132
- "open-ai": [
133
- "build/_modules/open-ai/index.d.ts"
134
- ],
135
155
  "server": [
136
156
  "build/_modules/server/index.d.ts"
137
157
  ],
@@ -165,12 +185,12 @@
165
185
  },
166
186
  "homepage": "https:/futdevpro.hu/projects/dynamo",
167
187
  "DISABLED": {
168
- "@futdevpro/fsm-dynamo": "file:../tgz-collection/dynamo-fsm/futdevpro-fsm-dynamo-01.12.17.tgz",
188
+ "@futdevpro/fsm-dynamo": "file:../tgz-collection/dynamo-fsm/futdevpro-fsm-dynamo-01.14.17.tgz",
169
189
 
170
190
  "empty": ""
171
191
  },
172
192
  "peerDependencies": {
173
- "@futdevpro/fsm-dynamo": "1.12.17",
193
+ "@futdevpro/fsm-dynamo": "1.14.2",
174
194
 
175
195
  "@types/express": "4.17.21",
176
196
  "@types/geoip-lite": "~1.4.1",
@@ -0,0 +1,79 @@
1
+ import { DyFM_AI_MessageRole } from '@futdevpro/fsm-dynamo/ai';
2
+ import { DyFM_AI_Message } from '@futdevpro/fsm-dynamo/ai';
3
+ import { DyFM_AI_CallSettings } from '@futdevpro/fsm-dynamo/ai';
4
+
5
+ export interface DyFM_AI_Base_Input {
6
+ issuer: string;
7
+ settings?: DyFM_AI_CallSettings;
8
+ debugLog?: boolean;
9
+ }
10
+
11
+ export interface DyFM_AI_Question_Input extends DyFM_AI_Base_Input {
12
+ question: string;
13
+ replaceThisInLog?: string;
14
+ }
15
+
16
+ export interface DyFM_AI_ListSelect_Input extends DyFM_AI_Question_Input {
17
+ selectFrom: string[];
18
+ }
19
+
20
+ export interface DyFM_AI_GenericSelect_Input<T> extends DyFM_AI_Question_Input {
21
+ selectFrom: T[];
22
+ }
23
+
24
+ export interface DyFM_AI_MultiSelect_Input extends DyFM_AI_Question_Input {
25
+ options: string[];
26
+ }
27
+
28
+ export interface DyFM_AI_GenericMultiSelect_Input<T> extends DyFM_AI_Question_Input {
29
+ options: T[];
30
+ }
31
+
32
+ export interface DyFM_AI_JSONKeysDescription_Input extends DyFM_AI_Question_Input {
33
+ keysDescription: string;
34
+ }
35
+
36
+ export interface DyFM_AI_JSONExactKeys_Input extends DyFM_AI_Question_Input {
37
+ keys: string[];
38
+ }
39
+
40
+ export interface DyFM_AI_SimpleMessage_Input extends DyFM_AI_Base_Input {
41
+ message: string;
42
+ }
43
+
44
+ export interface DyFM_AI_ConversationBase_Input extends DyFM_AI_Base_Input {
45
+ conversation: DyFM_AI_Message[];
46
+ replaceThisInLog?: string;
47
+ }
48
+
49
+ export interface DyFM_AI_ConversationQuestion_Input extends DyFM_AI_ConversationBase_Input {
50
+ question: string;
51
+ }
52
+
53
+ export interface DyFM_AI_ConversationSelect_Input extends DyFM_AI_ConversationQuestion_Input {
54
+ selectFrom: string[];
55
+ }
56
+
57
+ export interface DyFM_AI_ConversationGenericSelect_Input<T> extends DyFM_AI_ConversationQuestion_Input {
58
+ selectFrom: T[];
59
+ }
60
+
61
+ export interface DyFM_AI_ConversationMultiSelect_Input extends DyFM_AI_ConversationQuestion_Input {
62
+ options: string[];
63
+ }
64
+
65
+ export interface DyFM_AI_ConversationGenericMultiSelect_Input<T> extends DyFM_AI_ConversationQuestion_Input {
66
+ options: T[];
67
+ }
68
+
69
+ export interface DyFM_AI_ConversationJSONKeysDescription_Input extends DyFM_AI_ConversationQuestion_Input {
70
+ keysDescription: string;
71
+ }
72
+
73
+ export interface DyFM_AI_ConversationJSONExactKeys_Input extends DyFM_AI_ConversationQuestion_Input {
74
+ keys: string[];
75
+ }
76
+
77
+ export interface DyFM_AI_ConversationGetAnswer_Input extends DyFM_AI_ConversationBase_Input {
78
+ newMessage?: string;
79
+ }
@@ -1,19 +1,45 @@
1
- import { DyFM_AnyError, DyFM_Error, DyFM_Error_Settings, DyFM_Log, DyFM_Async } from '@futdevpro/fsm-dynamo';
2
- import { DyNTS_OAI_Chunk } 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';
1
+ import { DyFM_Log, DyFM_Error, DyFM_AnyError, DyFM_Error_Settings } from '@futdevpro/fsm-dynamo';
2
+ import { DyNTS_global_settings } from '../../../../../_collections/global-settings.const';
3
+ import { DyNTS_DAI_DocChunk } from '../_models/data-models/dai-doc-chunk.data-model';
4
+ import { DyNTS_DAI_DocPage } from '../_models/data-models/dai-doc-page.data-model';
5
+
6
+
7
+ interface DyNTS_DAI_DocChunking_Header {
8
+ level: number;
9
+ header: string;
10
+ index: number;
11
+ }
12
+
13
+ interface DyNTS_DAI_DocChunking_BreakPoint {
14
+ index: number;
15
+ level: number;
16
+ }
5
17
 
6
18
  /**
7
19
  * ClickUp dokumentum chunking szolgáltatás
8
20
  * @author AI
9
21
  * @description ClickUp dokumentumok intelligens chunking-ja a leghosszabb lehetséges chunk-ok létrehozásához
10
22
  */
11
- export class DyNTS_OAI_Chunking_Util {
23
+ export class DyNTS_DAI_DocChunking_Util {
12
24
 
13
25
  protected static readonly defaultErrorUserMsg: string =
14
26
  `We encountered an unhandled Control Service Error, ` +
15
27
  `\nplease contact the responsible development team.`;
16
28
 
29
+ /**
30
+ * Unified break points configuration
31
+ */
32
+ private static readonly breakPoints: { pattern: string, level: number, includeLength: number }[] = [
33
+ { pattern: '\n# ', level: 1, includeLength: 0 }, // Header 1 - cut before marker
34
+ { pattern: '\n## ', level: 2, includeLength: 0 }, // Header 2 - cut before marker
35
+ { pattern: '\n### ', level: 3, includeLength: 0 }, // Header 3 - cut before marker
36
+ { pattern: '\n#### ', level: 4, includeLength: 0 }, // Header 4 - cut before marker
37
+ { pattern: '\n\n', level: 0, includeLength: 2 }, // Double line break - include
38
+ { pattern: '\n', level: 0, includeLength: 1 }, // Single line break - include
39
+ { pattern: '. ', level: 0, includeLength: 2 }, // Sentence end - include
40
+ { pattern: ' ', level: 0, includeLength: 1 }, // Word break - include
41
+ ];
42
+
17
43
  protected static readonly debugLog: boolean = false;
18
44
 
19
45
  /**
@@ -23,8 +49,8 @@ export class DyNTS_OAI_Chunking_Util {
23
49
  * @returns Promise<CU_DocChunk[]> - Létrehozott chunk-ok listája
24
50
  */
25
51
  static async chunkMdContent<
26
- T_Chunk extends DyNTS_OAI_Chunk,
27
- T_Page extends DyNTS_OAI_DocumentPage<T_Chunk>,
52
+ T_Chunk extends DyNTS_DAI_DocChunk,
53
+ T_Page extends DyNTS_DAI_DocPage<T_Chunk>,
28
54
  >(
29
55
  page: T_Page,
30
56
  getPageLink: (page: T_Page, issuer: string) => string,
@@ -40,17 +66,31 @@ export class DyNTS_OAI_Chunking_Util {
40
66
  DyFM_Log.warn('lvl5+ headers are not supported yet for page: ' + page.name);
41
67
  }
42
68
 
69
+ if (!page.documentId) {
70
+ throw new DyFM_Error({
71
+ ...this.getDefaultErrorSettings('chunkMdContent', new Error('Page documentId is not set'), issuer),
72
+ errorCode: 'CCAP-CUC-CC2',
73
+ });
74
+ }
75
+
76
+ if (!page._id) {
77
+ throw new DyFM_Error({
78
+ ...this.getDefaultErrorSettings('chunkMdContent', new Error('Page _id is not set'), issuer),
79
+ errorCode: 'CCAP-CUC-CC3',
80
+ });
81
+ }
82
+
43
83
  /* DyFM_Log.log(`Chunking page: ${page.name}\n\n`, JSON.stringify(page.content, null, 2)); */
44
84
 
45
- let leftovers = page.content;
46
- const maxChunkSize = DyNTS_global_settings.docChunking.maxChunkSize;
47
- const maxChunkCount = DyNTS_global_settings.docChunking.maxChunkCount;
85
+ let leftovers: string = page.content;
86
+ const maxChunkSize: number = DyNTS_global_settings.docChunking.maxChunkSize;
87
+ const maxChunkCount: number = DyNTS_global_settings.docChunking.maxChunkCount;
48
88
  const chunks: T_Chunk[] = [];
49
- let chunkIndex = 0;
50
- let currentPosition = 0; // Track current position in original content
89
+ let chunkIndex: number = 0;
90
+ let currentPosition: number = 0; // Track current position in original content
51
91
 
52
92
  // Parse all headers to build hierarchy
53
- const headerHierarchy = this.parseHeaderHierarchy(leftovers);
93
+ const headerHierarchy: DyNTS_DAI_DocChunking_Header[] = this.parseHeaderHierarchy(leftovers);
54
94
 
55
95
  // Debug: Log parsed headers
56
96
  /* console.log('\n=== Parsed Header Hierarchy ===');
@@ -66,29 +106,34 @@ export class DyNTS_OAI_Chunking_Util {
66
106
  // Ha a teljes tartalom belefér egy chunk-ba, adjuk vissza az egészet
67
107
  if (leftovers.length <= maxChunkSize) {
68
108
  const chunkContent = leftovers.trim();
109
+
69
110
  if (chunkContent.length > 0) {
70
- const chunkWithHierarchy = this.addHeaderHierarchy(chunkContent, headerHierarchy, currentPosition, currentPosition + leftovers.length, lastHeaders);
71
- const chunkPath = this.buildChunkPath(page.name, headerHierarchy, currentPosition, currentPosition + leftovers.length, lastHeaders);
72
- const headParents = this.getRelevantHeaders(headerHierarchy, currentPosition, currentPosition + leftovers.length, lastHeaders); // headerHierarchy.map(header => header.header);
73
- const allFlaggedParents = [ ...page.allFlaggedParents, ...headParents ];
111
+ //const chunkWithHierarchy: string = this.addHeaderHierarchy(chunkContent, headerHierarchy, currentPosition, currentPosition + leftovers.length, lastHeaders);
112
+ //const chunkPath: string[] = this.buildChunkPath(page.name, headerHierarchy, currentPosition, currentPosition + leftovers.length, lastHeaders);
113
+ const headParents: string[] = this.getRelevantHeaders(headerHierarchy, currentPosition, currentPosition + leftovers.length, lastHeaders); // headerHierarchy.map(header => header.header);
114
+ //const allFlaggedParents: string[] = [ ...page.allFlaggedParents, ...headParents ];
74
115
 
75
- const chunk: T_Chunk = new DyNTS_OAI_Chunk({
116
+ const chunk: T_Chunk = new DyNTS_DAI_DocChunk({
117
+ documentId: page.documentId,
118
+ pageId: page._id,
119
+
76
120
  filePathParents: page.parentedPath,
77
121
  chunkHeadParents: headParents,
78
122
 
79
123
  allFlaggedParents: [ ...page.allFlaggedParents, ...headParents ],
80
124
  path: [ ...page.parentedPath, ...headParents ].join('/'),
81
125
 
82
- documentName: page.documentId,
126
+ documentName: page.externalDocumentId,
83
127
  pageName: page.name,
84
128
  pageLink: getPageLink(page, issuer),
85
129
  chunkIndex: chunkIndex,
86
130
 
87
- chunkContent: chunkContent,
88
- /* chunkOriginalContent: chunkContent,
131
+ chunkContent: chunkContent,
132
+ /* chunkOriginalContent: chunkContent,
89
133
 
90
- chunkContent: chunkWithHierarchy, */
134
+ chunkContent: chunkWithHierarchy, */
91
135
  }) as T_Chunk;
136
+
92
137
  if (this.debugLog || debugLog) {
93
138
  DyFM_Log.H_info(
94
139
  'Full content (before assembleChunkWithHeaders)',
@@ -96,6 +141,7 @@ export class DyNTS_OAI_Chunking_Util {
96
141
  { chunk: chunk.chunkContent }
97
142
  );
98
143
  }
144
+
99
145
  /* chunk.chunkContent = this.assembleChunkWithHeaders(chunk, issuer); */
100
146
  if (this.debugLog || debugLog) {
101
147
  DyFM_Log.H_info(
@@ -106,6 +152,7 @@ export class DyNTS_OAI_Chunking_Util {
106
152
  }
107
153
  );
108
154
  }
155
+
109
156
  /* await DyFM_Async.wait(100_000); */
110
157
  chunks.push(chunk);
111
158
  }
@@ -113,11 +160,11 @@ export class DyNTS_OAI_Chunking_Util {
113
160
  }
114
161
 
115
162
  // Keressük meg a legjobb break point-ot a maxChunkSize-n belül
116
- const breakPoint = this.findBestBreakPoint(leftovers, maxChunkSize);
163
+ const breakPoint: DyNTS_DAI_DocChunking_BreakPoint | null = this.findBestBreakPoint(leftovers, maxChunkSize);
117
164
 
118
- if (breakPoint.index > 0) {
165
+ if (breakPoint && breakPoint.index > 0) {
119
166
  // Ha találtunk break point-ot, vágjunk a marker előtt
120
- const chunkContent = leftovers.substring(0, breakPoint.index).trim();
167
+ const chunkContent: string = leftovers.substring(0, breakPoint.index).trim();
121
168
 
122
169
  // Debug: Log current state
123
170
  /* console.log(`\n--- Creating chunk ${chunkIndex} ---`);
@@ -126,27 +173,30 @@ export class DyNTS_OAI_Chunking_Util {
126
173
  console.log(`Chunk content preview:`, chunkContent.substring(0, 100) + '...'); */
127
174
 
128
175
  // Check if chunk has headers
129
- const hasHeaders = headerHierarchy.some(header =>
130
- header.index >= currentPosition && header.index < currentPosition + breakPoint.index
131
- );
176
+ //const hasHeaders: boolean = headerHierarchy.some(header =>
177
+ // header.index >= currentPosition && header.index < currentPosition + breakPoint.index
178
+ //);
132
179
  /* console.log(`Chunk has headers: ${hasHeaders}`); */
133
180
 
134
- const chunkWithHierarchy = this.addHeaderHierarchy(chunkContent, headerHierarchy, currentPosition, currentPosition + breakPoint.index, lastHeaders);
135
- const chunkPath = this.buildChunkPath(page.name, headerHierarchy, currentPosition, currentPosition + breakPoint.index, lastHeaders);
136
- const headParents = this.getRelevantHeaders(headerHierarchy, currentPosition, currentPosition + breakPoint.index, lastHeaders); // headerHierarchy.map(header => header.header);
137
- const allFlaggedParents = [ ...page.allFlaggedParents, ...headParents ];
181
+ //const chunkWithHierarchy: string = this.addHeaderHierarchy(chunkContent, headerHierarchy, currentPosition, currentPosition + breakPoint.index, lastHeaders);
182
+ //const chunkPath: string[] = this.buildChunkPath(page.name, headerHierarchy, currentPosition, currentPosition + breakPoint.index, lastHeaders);
183
+ const headParents: string[] = this.getRelevantHeaders(headerHierarchy, currentPosition, currentPosition + breakPoint.index, lastHeaders); // headerHierarchy.map(header => header.header);
184
+ //const allFlaggedParents: string[] = [ ...page.allFlaggedParents, ...headParents ];
138
185
 
139
186
  /* console.log(`Chunk path:`, chunkPath);
140
187
  console.log(`Chunk with hierarchy preview:`, chunkWithHierarchy.substring(0, 100) + '...'); */
141
188
 
142
- const chunk: T_Chunk = new DyNTS_OAI_Chunk({
189
+ const chunk: T_Chunk = new DyNTS_DAI_DocChunk({
190
+ documentId: page.documentId,
191
+ pageId: page._id,
192
+
143
193
  filePathParents: page.parentedPath,
144
194
  chunkHeadParents: headParents,
145
195
 
146
196
  allFlaggedParents: [ ...page.allFlaggedParents, ...headParents ],
147
197
  path: [ ...page.parentedPath, ...headParents ].join('/'),
148
198
 
149
- documentName: page.documentId,
199
+ documentName: page.externalDocumentId,
150
200
  pageName: page.name,
151
201
  pageLink: getPageLink(page, issuer),
152
202
  chunkIndex: chunkIndex,
@@ -156,6 +206,7 @@ export class DyNTS_OAI_Chunking_Util {
156
206
 
157
207
  chunkContent: chunkWithHierarchy, */
158
208
  }) as T_Chunk;
209
+
159
210
  if (this.debugLog || debugLog) {
160
211
  DyFM_Log.H_info(
161
212
  'Break point (before assembleChunkWithHeaders)',
@@ -163,6 +214,7 @@ export class DyNTS_OAI_Chunking_Util {
163
214
  { chunk: chunk.chunkContent }
164
215
  );
165
216
  }
217
+
166
218
  /* chunk.chunkContent = this.assembleChunkWithHeaders(chunk, issuer); */
167
219
  if (this.debugLog || debugLog) {
168
220
  DyFM_Log.H_info(
@@ -173,6 +225,7 @@ export class DyNTS_OAI_Chunking_Util {
173
225
  }
174
226
  );
175
227
  }
228
+
176
229
  chunks.push(chunk);
177
230
  chunkIndex++;
178
231
  currentPosition += breakPoint.index;
@@ -185,20 +238,23 @@ export class DyNTS_OAI_Chunking_Util {
185
238
  console.log(`--- End chunk ${chunkIndex - 1} ---\n`); */
186
239
  } else {
187
240
  // Ha nem találtunk break point-ot, használjuk a maxChunkSize-t
188
- const chunkContent = leftovers.substring(0, maxChunkSize).trim();
189
- const chunkWithHierarchy = this.addHeaderHierarchy(chunkContent, headerHierarchy, currentPosition, currentPosition + maxChunkSize, lastHeaders);
190
- const chunkPath = this.buildChunkPath(page.name, headerHierarchy, currentPosition, currentPosition + maxChunkSize, lastHeaders);
191
- const headParents = this.getRelevantHeaders(headerHierarchy, currentPosition, currentPosition + maxChunkSize, lastHeaders); // headerHierarchy.map(header => header.header);
192
- const allFlaggedParents = [ ...page.allFlaggedParents, ...headParents ];
241
+ const chunkContent: string = leftovers.substring(0, maxChunkSize).trim();
242
+ //const chunkWithHierarchy: string = this.addHeaderHierarchy(chunkContent, headerHierarchy, currentPosition, currentPosition + maxChunkSize, lastHeaders);
243
+ //const chunkPath: string[] = this.buildChunkPath(page.name, headerHierarchy, currentPosition, currentPosition + maxChunkSize, lastHeaders);
244
+ const headParents: string[] = this.getRelevantHeaders(headerHierarchy, currentPosition, currentPosition + maxChunkSize, lastHeaders); // headerHierarchy.map(header => header.header);
245
+ //const allFlaggedParents: string[] = [ ...page.allFlaggedParents, ...headParents ];
193
246
 
194
- const chunk: T_Chunk = new DyNTS_OAI_Chunk({
247
+ const chunk: T_Chunk = new DyNTS_DAI_DocChunk({
248
+ documentId: page.documentId,
249
+ pageId: page._id,
250
+
195
251
  filePathParents: page.parentedPath,
196
252
  chunkHeadParents: headParents,
197
253
 
198
254
  allFlaggedParents: [ ...page.allFlaggedParents, ...headParents ],
199
255
  path: [ ...page.parentedPath, ...headParents ].join('/'),
200
256
 
201
- documentName: page.documentId,
257
+ documentName: page.externalDocumentId,
202
258
  pageName: page.name,
203
259
  pageLink: getPageLink(page, issuer),
204
260
  chunkIndex: chunkIndex,
@@ -208,6 +264,7 @@ export class DyNTS_OAI_Chunking_Util {
208
264
 
209
265
  chunkContent: chunkWithHierarchy, */
210
266
  }) as T_Chunk;
267
+
211
268
  if (this.debugLog || debugLog) {
212
269
  DyFM_Log.H_info(
213
270
  'Max chunk size',
@@ -215,6 +272,7 @@ export class DyNTS_OAI_Chunking_Util {
215
272
  { chunk: chunk.chunkContent }
216
273
  );
217
274
  }
275
+
218
276
  /* chunk.chunkContent = this.assembleChunkWithHeaders(chunk, issuer); */
219
277
  if (this.debugLog || debugLog) {
220
278
  DyFM_Log.H_info(
@@ -224,6 +282,7 @@ export class DyNTS_OAI_Chunking_Util {
224
282
  }
225
283
  );
226
284
  }
285
+
227
286
  chunks.push(chunk);
228
287
  chunkIndex++;
229
288
  currentPosition += maxChunkSize;
@@ -267,7 +326,7 @@ export class DyNTS_OAI_Chunking_Util {
267
326
  }
268
327
  }
269
328
 
270
- /* private static assembleChunkWithHeaders(chunk: DyNTS_OAI_Chunk, issuer: string): string {
329
+ /* private static assembleChunkWithHeaders(chunk: DyNTS_DAI_DocChunk, issuer: string): string {
271
330
  try {
272
331
  const fileHeaders = chunk.filePathParents.map(
273
332
  (header, index) => `${'>'.repeat(index + 1)} **${header}**`
@@ -285,11 +344,11 @@ export class DyNTS_OAI_Chunking_Util {
285
344
  } */
286
345
 
287
346
  static reassembleChunksToContent(
288
- chunks: DyNTS_OAI_Chunk[],
347
+ chunks: DyNTS_DAI_DocChunk[],
289
348
  issuer: string
290
349
  ): string {
291
350
  try {
292
- let pageContent = '';
351
+ let pageContent: string = '';
293
352
 
294
353
  for (const chunk of chunks) {
295
354
  if (!chunk) {
@@ -319,29 +378,16 @@ export class DyNTS_OAI_Chunking_Util {
319
378
  }
320
379
  }
321
380
 
322
- /**
323
- * Unified break points configuration
324
- */
325
- private static readonly breakPoints = [
326
- { pattern: '\n# ', level: 1, includeLength: 0 }, // Header 1 - cut before marker
327
- { pattern: '\n## ', level: 2, includeLength: 0 }, // Header 2 - cut before marker
328
- { pattern: '\n### ', level: 3, includeLength: 0 }, // Header 3 - cut before marker
329
- { pattern: '\n#### ', level: 4, includeLength: 0 }, // Header 4 - cut before marker
330
- { pattern: '\n\n', level: 0, includeLength: 2 }, // Double line break - include
331
- { pattern: '\n', level: 0, includeLength: 1 }, // Single line break - include
332
- { pattern: '. ', level: 0, includeLength: 2 }, // Sentence end - include
333
- { pattern: ' ', level: 0, includeLength: 1 }, // Word break - include
334
- ];
335
-
336
381
  /**
337
382
  * Find the best break point within the chunk size
338
383
  * @param text - The text to search in
339
384
  * @param maxIndex - Maximum index to search up to
340
385
  * @returns The best break point or null if not found
341
386
  */
342
- private static findBestBreakPoint(text: string, maxIndex: number): { index: number, level: number } | null {
387
+ private static findBestBreakPoint(text: string, maxIndex: number): DyNTS_DAI_DocChunking_BreakPoint | null {
343
388
  for (const breakPoint of this.breakPoints) {
344
- const index = this.findLastOccurrence(text, breakPoint.pattern, maxIndex);
389
+ const index: number = this.findLastOccurrence(text, breakPoint.pattern, maxIndex);
390
+
345
391
  if (index > 0) {
346
392
  return {
347
393
  index: index + breakPoint.includeLength,
@@ -357,20 +403,21 @@ export class DyNTS_OAI_Chunking_Util {
357
403
  * @param content - The content to parse
358
404
  * @returns Array of header positions and levels
359
405
  */
360
- private static parseHeaderHierarchy(content: string): Array<{index: number, level: number, header: string}> {
361
- const headers: Array<{index: number, level: number, header: string}> = [];
362
- const lines = content.split('\n');
363
- let currentIndex = 0;
406
+ private static parseHeaderHierarchy(content: string): DyNTS_DAI_DocChunking_Header[] {
407
+ const headers: DyNTS_DAI_DocChunking_Header[] = [];
408
+ const lines: string[] = content.split('\n');
409
+ let currentIndex: number = 0;
364
410
 
365
411
  for (const line of lines) {
366
- const trimmedLine = line.trim();
412
+ const trimmedLine: string = line.trim();
367
413
 
368
414
  // Check if line starts with # and determine the level
369
415
  if (trimmedLine.startsWith('#')) {
370
- const match = trimmedLine.match(/^(#+)\s+(.+)$/);
416
+ const match: RegExpMatchArray | null = trimmedLine.match(/^(#+)\s+(.+)$/);
417
+
371
418
  if (match) {
372
- const level = match[1].length; // Count the number of # symbols
373
- const headerText = trimmedLine;
419
+ const level: number = match[1].length; // Count the number of # symbols
420
+ const headerText: string = trimmedLine;
374
421
 
375
422
  if (level >= 1 && level <= 4) { // Only support levels 1-4
376
423
  headers.push({
@@ -395,7 +442,7 @@ export class DyNTS_OAI_Chunking_Util {
395
442
  * @param lastHeaders - Map to store last headers of each level
396
443
  */
397
444
  private static updateLastHeaders(
398
- headerHierarchy: Array<{index: number, level: number, header: string}>,
445
+ headerHierarchy: DyNTS_DAI_DocChunking_Header[],
399
446
  currentPosition: number,
400
447
  lastHeaders: Map<number, string>
401
448
  ): void {
@@ -408,7 +455,7 @@ export class DyNTS_OAI_Chunking_Util {
408
455
  // Clear all lower level headers (higher level numbers) when any header comes
409
456
  // For example, if we see a level 2 header, clear levels 3, 4
410
457
  // If we see a level 1 header, clear levels 2, 3, 4
411
- for (let level = header.level + 1; level <= 4; level++) {
458
+ for (let level: number = header.level + 1; level <= 4; level++) {
412
459
  lastHeaders.delete(level);
413
460
  }
414
461
  }
@@ -424,20 +471,21 @@ export class DyNTS_OAI_Chunking_Util {
424
471
  * @returns A releváns szülő fejlécek tömbje
425
472
  */
426
473
  private static getRelevantHeaders(
427
- headerHierarchy: Array<{index: number, level: number, header: string}>,
474
+ headerHierarchy: DyNTS_DAI_DocChunking_Header[],
428
475
  startIndex: number,
429
476
  endIndex: number,
430
477
  lastHeaders: Map<number, string>
431
478
  ): string[] {
432
479
  // Keressük meg az első fejlécet a chunkban
433
- const firstHeaderInChunk = headerHierarchy.find(header =>
480
+ const firstHeaderInChunk: DyNTS_DAI_DocChunking_Header | undefined = headerHierarchy.find(header =>
434
481
  header.index >= startIndex && header.index < endIndex
435
482
  );
436
483
 
437
484
  if (!firstHeaderInChunk) {
438
485
  // Nincs fejléc a chunkban, a legmagasabb szintű utolsó fejlécet használjuk
439
- let highestLevel = 0;
440
- let highestHeader = '';
486
+ let highestLevel: number = 0;
487
+ let highestHeader: string = '';
488
+
441
489
  for (const [level, header] of lastHeaders.entries()) {
442
490
  if (level > highestLevel) {
443
491
  highestLevel = level;
@@ -449,8 +497,9 @@ export class DyNTS_OAI_Chunking_Util {
449
497
 
450
498
  // Szülő fejlécek összegyűjtése az első fejléc szintje alapján
451
499
  const relevantHeaders: string[] = [];
452
- for (let level = 1; level < firstHeaderInChunk.level; level++) {
453
- const parentHeader = lastHeaders.get(level);
500
+ for (let level: number = 1; level < firstHeaderInChunk.level; level++) {
501
+ const parentHeader: string | undefined = lastHeaders.get(level);
502
+
454
503
  if (parentHeader) {
455
504
  relevantHeaders.push(parentHeader);
456
505
  }
@@ -469,13 +518,13 @@ export class DyNTS_OAI_Chunking_Util {
469
518
  */
470
519
  private static buildChunkPath(
471
520
  pageName: string,
472
- headerHierarchy: Array<{index: number, level: number, header: string}>,
521
+ headerHierarchy: DyNTS_DAI_DocChunking_Header[],
473
522
  startIndex: number,
474
523
  endIndex: number,
475
524
  lastHeaders: Map<number, string>
476
525
  ): string[] {
477
526
  // Find the first header within this chunk
478
- const firstHeaderInChunk = headerHierarchy.find(header =>
527
+ const firstHeaderInChunk: DyNTS_DAI_DocChunking_Header | undefined = headerHierarchy.find(header =>
479
528
  header.index >= startIndex && header.index < endIndex
480
529
  );
481
530
 
@@ -484,8 +533,9 @@ export class DyNTS_OAI_Chunking_Util {
484
533
  const pathParts: string[] = [pageName];
485
534
 
486
535
  // Find the highest level header from lastHeaders
487
- let highestLevel = 0;
488
- let highestHeader = '';
536
+ let highestLevel: number = 0;
537
+ let highestHeader: string = '';
538
+
489
539
  for (const [level, header] of lastHeaders.entries()) {
490
540
  if (level > highestLevel) {
491
541
  highestLevel = level;
@@ -505,7 +555,8 @@ export class DyNTS_OAI_Chunking_Util {
505
555
 
506
556
  // Add parent headers from lastHeaders (these are the actual parent headers)
507
557
  for (let level = 1; level < firstHeaderInChunk.level; level++) {
508
- const parentHeader = lastHeaders.get(level);
558
+ const parentHeader: string | undefined = lastHeaders.get(level);
559
+
509
560
  if (parentHeader) {
510
561
  pathParts.push(parentHeader); // Include the full header with markdown symbols
511
562
  }
@@ -528,15 +579,17 @@ export class DyNTS_OAI_Chunking_Util {
528
579
  */
529
580
  private static addHeaderHierarchy(
530
581
  chunkContent: string,
531
- headerHierarchy: Array<{index: number, level: number, header: string}>,
582
+ headerHierarchy: DyNTS_DAI_DocChunking_Header[],
532
583
  startIndex: number,
533
584
  endIndex: number,
534
585
  lastHeaders: Map<number, string>
535
586
  ): string {
536
- const relevantHeaders = this.getRelevantHeaders(headerHierarchy, startIndex, endIndex, lastHeaders);
587
+ const relevantHeaders: string[] = this.getRelevantHeaders(headerHierarchy, startIndex, endIndex, lastHeaders);
588
+
537
589
  if (relevantHeaders.length > 0) {
538
590
  return relevantHeaders.join('\n') + '\n\n' + chunkContent;
539
591
  }
592
+
540
593
  return chunkContent;
541
594
  }
542
595
 
@@ -548,8 +601,9 @@ export class DyNTS_OAI_Chunking_Util {
548
601
  * @returns The index of the last occurrence, or -1 if not found
549
602
  */
550
603
  private static findLastOccurrence(text: string, pattern: string, maxIndex: number): number {
551
- const searchText = text.substring(0, maxIndex);
552
- const lastIndex = searchText.lastIndexOf(pattern);
604
+ const searchText: string = text.substring(0, maxIndex);
605
+ const lastIndex: number = searchText.lastIndexOf(pattern);
606
+
553
607
  return lastIndex;
554
608
  }
555
609
 
@@ -573,8 +627,3 @@ export class DyNTS_OAI_Chunking_Util {
573
627
  };
574
628
  }
575
629
  }
576
-
577
-
578
- function isLast<T>(element: T, array: T[]): boolean {
579
- return array.indexOf(element) === array.length - 1;
580
- }