@getzep/zep-cloud 1.0.12 → 2.0.0-rc.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 (438) hide show
  1. package/Client.d.ts +6 -0
  2. package/Client.js +12 -2
  3. package/LICENSE +201 -0
  4. package/api/resources/document/client/Client.d.ts +9 -9
  5. package/api/resources/document/client/Client.js +20 -20
  6. package/api/resources/graph/client/Client.d.ts +62 -0
  7. package/api/resources/graph/client/Client.js +225 -0
  8. package/api/resources/graph/client/index.d.ts +1 -0
  9. package/{dist/langchain → api/resources/graph/client}/index.js +1 -3
  10. package/api/resources/graph/client/requests/AddDataRequest.d.ts +14 -0
  11. package/api/resources/graph/client/requests/GraphSearchQuery.d.ts +30 -0
  12. package/api/resources/graph/client/requests/index.d.ts +2 -0
  13. package/api/resources/graph/client/requests/index.js +2 -0
  14. package/api/resources/graph/index.d.ts +2 -0
  15. package/{langchain → api/resources/graph}/index.js +2 -3
  16. package/api/resources/graph/resources/edge/client/Client.d.ts +78 -0
  17. package/api/resources/graph/resources/edge/client/Client.js +361 -0
  18. package/api/resources/graph/resources/edge/client/index.d.ts +1 -0
  19. package/api/resources/graph/resources/edge/client/index.js +2 -0
  20. package/api/resources/graph/resources/edge/index.d.ts +1 -0
  21. package/api/resources/graph/resources/edge/index.js +17 -0
  22. package/api/resources/graph/resources/episode/client/Client.d.ts +66 -0
  23. package/api/resources/graph/resources/episode/client/Client.js +293 -0
  24. package/api/resources/graph/resources/episode/client/index.d.ts +1 -0
  25. package/api/resources/graph/resources/episode/client/index.js +17 -0
  26. package/api/resources/graph/resources/episode/client/requests/EpisodeGetByGroupIdRequest.d.ts +13 -0
  27. package/api/resources/graph/resources/episode/client/requests/EpisodeGetByUserIdRequest.d.ts +13 -0
  28. package/api/resources/graph/resources/episode/client/requests/index.d.ts +2 -0
  29. package/api/resources/graph/resources/episode/client/requests/index.js +2 -0
  30. package/api/resources/graph/resources/episode/index.d.ts +1 -0
  31. package/api/resources/graph/resources/episode/index.js +17 -0
  32. package/api/resources/graph/resources/index.d.ts +4 -0
  33. package/api/resources/graph/resources/index.js +33 -0
  34. package/api/resources/graph/resources/node/client/Client.d.ts +65 -0
  35. package/api/resources/graph/resources/node/client/Client.js +288 -0
  36. package/api/resources/graph/resources/node/client/index.d.ts +1 -0
  37. package/api/resources/graph/resources/node/client/index.js +2 -0
  38. package/api/resources/graph/resources/node/index.d.ts +1 -0
  39. package/api/resources/graph/resources/node/index.js +17 -0
  40. package/api/resources/group/client/Client.d.ts +52 -0
  41. package/api/resources/group/client/Client.js +216 -0
  42. package/api/resources/group/client/index.d.ts +1 -0
  43. package/api/resources/group/client/index.js +17 -0
  44. package/api/resources/group/client/requests/CreateGroupRequest.d.ts +12 -0
  45. package/api/resources/group/client/requests/index.d.ts +1 -0
  46. package/api/resources/group/client/requests/index.js +2 -0
  47. package/api/resources/group/index.d.ts +1 -0
  48. package/api/resources/group/index.js +17 -0
  49. package/api/resources/index.d.ts +4 -0
  50. package/api/resources/index.js +5 -1
  51. package/api/resources/memory/client/Client.d.ts +22 -12
  52. package/api/resources/memory/client/Client.js +45 -38
  53. package/api/resources/memory/client/requests/AddFactsRequest.d.ts +1 -1
  54. package/api/resources/memory/client/requests/AddMemoryRequest.d.ts +6 -3
  55. package/api/resources/memory/client/requests/CreateSessionRequest.d.ts +3 -2
  56. package/api/resources/memory/client/requests/MemoryGetRequest.d.ts +0 -5
  57. package/api/resources/memory/client/requests/MemoryGetSessionFactsRequest.d.ts +1 -1
  58. package/api/resources/memory/client/requests/ModelsMessageMetadataUpdate.d.ts +3 -1
  59. package/api/resources/memory/client/requests/SessionSearchQuery.d.ts +12 -3
  60. package/api/resources/memory/client/requests/UpdateSessionRequest.d.ts +3 -1
  61. package/api/resources/user/client/Client.d.ts +13 -0
  62. package/api/resources/user/client/Client.js +79 -6
  63. package/{dist/api/types/DocumentResponse.d.ts → api/types/ApidataDocument.d.ts} +1 -1
  64. package/api/types/{DocumentCollectionResponse.d.ts → ApidataDocumentCollection.d.ts} +1 -3
  65. package/api/types/{DocumentSearchResultPage.d.ts → ApidataDocumentSearchResponse.d.ts} +2 -2
  66. package/api/types/{DocumentSearchResult.d.ts → ApidataDocumentWithScore.d.ts} +1 -1
  67. package/api/types/EndSessionResponse.d.ts +1 -1
  68. package/api/types/EntityEdge.d.ts +25 -0
  69. package/api/types/EntityNode.d.ts +15 -0
  70. package/api/types/Episode.d.ts +12 -0
  71. package/api/types/EpisodeResponse.d.ts +7 -0
  72. package/api/types/EpisodeResponse.js +5 -0
  73. package/api/types/Fact.d.ts +9 -3
  74. package/api/types/GraphDataType.d.ts +9 -0
  75. package/api/types/GraphDataType.js +11 -0
  76. package/api/types/GraphSearchResults.d.ts +8 -0
  77. package/api/types/GraphSearchResults.js +5 -0
  78. package/api/types/GraphSearchScope.d.ts +8 -0
  79. package/api/types/GraphSearchScope.js +10 -0
  80. package/api/types/Group.d.ts +12 -0
  81. package/api/types/Group.js +5 -0
  82. package/api/types/Memory.d.ts +4 -5
  83. package/api/types/Message.d.ts +2 -2
  84. package/api/types/{AddedFact.d.ts → NewFact.d.ts} +1 -1
  85. package/api/types/NewFact.js +5 -0
  86. package/api/types/Reranker.d.ts +10 -0
  87. package/api/types/Reranker.js +12 -0
  88. package/api/types/Session.d.ts +1 -2
  89. package/api/types/{ClassifySessionResponse.d.ts → SessionClassification.d.ts} +2 -2
  90. package/api/types/SessionClassification.js +5 -0
  91. package/api/types/SessionFactRatingExamples.d.ts +8 -0
  92. package/api/types/SessionFactRatingExamples.js +5 -0
  93. package/api/types/SessionFactRatingInstruction.d.ts +21 -0
  94. package/api/types/SessionFactRatingInstruction.js +5 -0
  95. package/api/types/index.d.ts +24 -14
  96. package/api/types/index.js +24 -14
  97. package/dist/Client.d.ts +6 -0
  98. package/dist/Client.js +12 -2
  99. package/dist/api/resources/document/client/Client.d.ts +9 -9
  100. package/dist/api/resources/document/client/Client.js +20 -20
  101. package/dist/api/resources/graph/client/Client.d.ts +62 -0
  102. package/dist/api/resources/graph/client/Client.js +225 -0
  103. package/dist/api/resources/graph/client/index.d.ts +1 -0
  104. package/dist/api/resources/graph/client/index.js +17 -0
  105. package/dist/api/resources/graph/client/requests/AddDataRequest.d.ts +14 -0
  106. package/dist/api/resources/graph/client/requests/AddDataRequest.js +5 -0
  107. package/dist/api/resources/graph/client/requests/GraphSearchQuery.d.ts +30 -0
  108. package/dist/api/resources/graph/client/requests/GraphSearchQuery.js +5 -0
  109. package/dist/api/resources/graph/client/requests/index.d.ts +2 -0
  110. package/dist/api/resources/graph/client/requests/index.js +2 -0
  111. package/dist/api/resources/graph/index.d.ts +2 -0
  112. package/dist/api/resources/graph/index.js +18 -0
  113. package/dist/api/resources/graph/resources/edge/client/Client.d.ts +78 -0
  114. package/dist/api/resources/graph/resources/edge/client/Client.js +361 -0
  115. package/dist/api/resources/graph/resources/edge/client/index.d.ts +1 -0
  116. package/dist/api/resources/graph/resources/edge/client/index.js +2 -0
  117. package/dist/api/resources/graph/resources/edge/index.d.ts +1 -0
  118. package/dist/api/resources/graph/resources/edge/index.js +17 -0
  119. package/dist/api/resources/graph/resources/episode/client/Client.d.ts +66 -0
  120. package/dist/api/resources/graph/resources/episode/client/Client.js +293 -0
  121. package/dist/api/resources/graph/resources/episode/client/index.d.ts +1 -0
  122. package/dist/api/resources/graph/resources/episode/client/index.js +17 -0
  123. package/dist/api/resources/graph/resources/episode/client/requests/EpisodeGetByGroupIdRequest.d.ts +13 -0
  124. package/dist/api/resources/graph/resources/episode/client/requests/EpisodeGetByGroupIdRequest.js +5 -0
  125. package/dist/api/resources/graph/resources/episode/client/requests/EpisodeGetByUserIdRequest.d.ts +13 -0
  126. package/dist/api/resources/graph/resources/episode/client/requests/EpisodeGetByUserIdRequest.js +5 -0
  127. package/dist/api/resources/graph/resources/episode/client/requests/index.d.ts +2 -0
  128. package/dist/api/resources/graph/resources/episode/client/requests/index.js +2 -0
  129. package/dist/api/resources/graph/resources/episode/index.d.ts +1 -0
  130. package/dist/api/resources/graph/resources/episode/index.js +17 -0
  131. package/dist/api/resources/graph/resources/index.d.ts +4 -0
  132. package/dist/api/resources/graph/resources/index.js +33 -0
  133. package/dist/api/resources/graph/resources/node/client/Client.d.ts +65 -0
  134. package/dist/api/resources/graph/resources/node/client/Client.js +288 -0
  135. package/dist/api/resources/graph/resources/node/client/index.d.ts +1 -0
  136. package/dist/api/resources/graph/resources/node/client/index.js +2 -0
  137. package/dist/api/resources/graph/resources/node/index.d.ts +1 -0
  138. package/dist/api/resources/graph/resources/node/index.js +17 -0
  139. package/dist/api/resources/group/client/Client.d.ts +52 -0
  140. package/dist/api/resources/group/client/Client.js +216 -0
  141. package/dist/api/resources/group/client/index.d.ts +1 -0
  142. package/dist/api/resources/group/client/index.js +17 -0
  143. package/dist/api/resources/group/client/requests/CreateGroupRequest.d.ts +12 -0
  144. package/dist/api/resources/group/client/requests/CreateGroupRequest.js +5 -0
  145. package/dist/api/resources/group/client/requests/index.d.ts +1 -0
  146. package/dist/api/resources/group/client/requests/index.js +2 -0
  147. package/dist/api/resources/group/index.d.ts +1 -0
  148. package/dist/api/resources/group/index.js +17 -0
  149. package/dist/api/resources/index.d.ts +4 -0
  150. package/dist/api/resources/index.js +5 -1
  151. package/dist/api/resources/memory/client/Client.d.ts +22 -12
  152. package/dist/api/resources/memory/client/Client.js +45 -38
  153. package/dist/api/resources/memory/client/requests/AddFactsRequest.d.ts +1 -1
  154. package/dist/api/resources/memory/client/requests/AddMemoryRequest.d.ts +6 -3
  155. package/dist/api/resources/memory/client/requests/CreateSessionRequest.d.ts +3 -2
  156. package/dist/api/resources/memory/client/requests/MemoryGetRequest.d.ts +0 -5
  157. package/dist/api/resources/memory/client/requests/MemoryGetSessionFactsRequest.d.ts +1 -1
  158. package/dist/api/resources/memory/client/requests/ModelsMessageMetadataUpdate.d.ts +3 -1
  159. package/dist/api/resources/memory/client/requests/SessionSearchQuery.d.ts +12 -3
  160. package/dist/api/resources/memory/client/requests/UpdateSessionRequest.d.ts +3 -1
  161. package/dist/api/resources/user/client/Client.d.ts +13 -0
  162. package/dist/api/resources/user/client/Client.js +79 -6
  163. package/{api/types/DocumentResponse.d.ts → dist/api/types/ApidataDocument.d.ts} +1 -1
  164. package/dist/api/types/ApidataDocument.js +5 -0
  165. package/dist/api/types/{DocumentCollectionResponse.d.ts → ApidataDocumentCollection.d.ts} +1 -3
  166. package/dist/api/types/ApidataDocumentCollection.js +5 -0
  167. package/dist/api/types/{DocumentSearchResultPage.d.ts → ApidataDocumentSearchResponse.d.ts} +2 -2
  168. package/dist/api/types/ApidataDocumentSearchResponse.js +5 -0
  169. package/dist/api/types/{DocumentSearchResult.d.ts → ApidataDocumentWithScore.d.ts} +1 -1
  170. package/dist/api/types/ApidataDocumentWithScore.js +5 -0
  171. package/dist/api/types/EndSessionResponse.d.ts +1 -1
  172. package/dist/api/types/EntityEdge.d.ts +25 -0
  173. package/dist/api/types/EntityEdge.js +5 -0
  174. package/dist/api/types/EntityNode.d.ts +15 -0
  175. package/dist/api/types/EntityNode.js +5 -0
  176. package/dist/api/types/Episode.d.ts +12 -0
  177. package/dist/api/types/Episode.js +5 -0
  178. package/dist/api/types/EpisodeResponse.d.ts +7 -0
  179. package/dist/api/types/EpisodeResponse.js +5 -0
  180. package/dist/api/types/Fact.d.ts +9 -3
  181. package/dist/api/types/GraphDataType.d.ts +9 -0
  182. package/dist/api/types/GraphDataType.js +11 -0
  183. package/dist/api/types/GraphSearchResults.d.ts +8 -0
  184. package/dist/api/types/GraphSearchResults.js +5 -0
  185. package/dist/api/types/GraphSearchScope.d.ts +8 -0
  186. package/dist/api/types/GraphSearchScope.js +10 -0
  187. package/dist/api/types/Group.d.ts +12 -0
  188. package/dist/api/types/Group.js +5 -0
  189. package/dist/api/types/Memory.d.ts +4 -5
  190. package/dist/api/types/Message.d.ts +2 -2
  191. package/dist/api/types/{AddedFact.d.ts → NewFact.d.ts} +1 -1
  192. package/dist/api/types/NewFact.js +5 -0
  193. package/dist/api/types/Reranker.d.ts +10 -0
  194. package/dist/api/types/Reranker.js +12 -0
  195. package/dist/api/types/Session.d.ts +1 -2
  196. package/dist/api/types/{ClassifySessionResponse.d.ts → SessionClassification.d.ts} +2 -2
  197. package/dist/api/types/SessionClassification.js +5 -0
  198. package/dist/api/types/SessionFactRatingExamples.d.ts +8 -0
  199. package/dist/api/types/SessionFactRatingExamples.js +5 -0
  200. package/dist/api/types/SessionFactRatingInstruction.d.ts +21 -0
  201. package/dist/api/types/SessionFactRatingInstruction.js +5 -0
  202. package/dist/api/types/index.d.ts +24 -14
  203. package/dist/api/types/index.js +24 -14
  204. package/dist/serialization/resources/document/client/addDocuments.d.ts +2 -2
  205. package/dist/serialization/resources/document/client/addDocuments.js +1 -1
  206. package/dist/serialization/resources/document/client/batchGetDocuments.d.ts +3 -3
  207. package/dist/serialization/resources/document/client/batchGetDocuments.js +2 -2
  208. package/dist/serialization/resources/document/client/listCollections.d.ts +3 -3
  209. package/dist/serialization/resources/document/client/listCollections.js +2 -2
  210. package/dist/serialization/resources/graph/client/index.d.ts +1 -0
  211. package/dist/serialization/resources/graph/client/index.js +17 -0
  212. package/dist/serialization/resources/graph/client/requests/AddDataRequest.d.ts +16 -0
  213. package/dist/serialization/resources/graph/client/requests/AddDataRequest.js +37 -0
  214. package/dist/serialization/resources/graph/client/requests/GraphSearchQuery.d.ts +22 -0
  215. package/dist/serialization/resources/graph/client/requests/GraphSearchQuery.js +43 -0
  216. package/dist/serialization/resources/graph/client/requests/index.d.ts +2 -0
  217. package/dist/serialization/resources/graph/client/requests/index.js +7 -0
  218. package/dist/serialization/resources/graph/index.d.ts +2 -0
  219. package/dist/serialization/resources/graph/index.js +18 -0
  220. package/dist/serialization/resources/graph/resources/edge/client/getByGroupId.d.ts +11 -0
  221. package/dist/serialization/resources/graph/resources/edge/client/getByGroupId.js +32 -0
  222. package/dist/serialization/resources/graph/resources/edge/client/getByUserId.d.ts +11 -0
  223. package/dist/serialization/resources/graph/resources/edge/client/getByUserId.js +32 -0
  224. package/dist/serialization/resources/graph/resources/edge/client/index.d.ts +2 -0
  225. package/dist/serialization/resources/graph/resources/edge/client/index.js +28 -0
  226. package/dist/serialization/resources/graph/resources/edge/index.d.ts +1 -0
  227. package/dist/serialization/resources/graph/resources/edge/index.js +17 -0
  228. package/dist/serialization/resources/graph/resources/index.d.ts +2 -0
  229. package/dist/serialization/resources/graph/resources/index.js +28 -0
  230. package/dist/serialization/resources/graph/resources/node/client/getByGroupId.d.ts +11 -0
  231. package/dist/serialization/resources/graph/resources/node/client/getByGroupId.js +32 -0
  232. package/dist/serialization/resources/graph/resources/node/client/getByUserId.d.ts +11 -0
  233. package/dist/serialization/resources/graph/resources/node/client/getByUserId.js +32 -0
  234. package/dist/serialization/resources/graph/resources/node/client/index.d.ts +2 -0
  235. package/dist/serialization/resources/graph/resources/node/client/index.js +28 -0
  236. package/dist/serialization/resources/graph/resources/node/index.d.ts +1 -0
  237. package/dist/serialization/resources/graph/resources/node/index.js +17 -0
  238. package/dist/serialization/resources/group/client/index.d.ts +1 -0
  239. package/dist/serialization/resources/group/client/index.js +17 -0
  240. package/dist/serialization/resources/group/client/requests/CreateGroupRequest.d.ts +14 -0
  241. package/dist/serialization/resources/group/client/requests/CreateGroupRequest.js +35 -0
  242. package/dist/serialization/resources/group/client/requests/index.d.ts +1 -0
  243. package/dist/serialization/resources/group/client/requests/index.js +5 -0
  244. package/dist/serialization/resources/group/index.d.ts +1 -0
  245. package/dist/serialization/resources/group/index.js +17 -0
  246. package/dist/serialization/resources/index.d.ts +4 -0
  247. package/dist/serialization/resources/index.js +5 -1
  248. package/dist/serialization/resources/memory/client/requests/AddFactsRequest.d.ts +2 -2
  249. package/dist/serialization/resources/memory/client/requests/AddFactsRequest.js +2 -2
  250. package/dist/serialization/resources/memory/client/requests/CreateSessionRequest.d.ts +1 -1
  251. package/dist/serialization/resources/memory/client/requests/CreateSessionRequest.js +1 -1
  252. package/dist/serialization/resources/memory/client/requests/SessionSearchQuery.d.ts +1 -1
  253. package/dist/serialization/resources/memory/client/requests/SessionSearchQuery.js +1 -1
  254. package/{serialization/types/DocumentResponse.d.ts → dist/serialization/types/ApidataDocument.d.ts} +2 -2
  255. package/{serialization/types/DocumentResponse.js → dist/serialization/types/ApidataDocument.js} +2 -2
  256. package/dist/serialization/types/{DocumentCollectionResponse.d.ts → ApidataDocumentCollection.d.ts} +2 -2
  257. package/{serialization/types/DocumentCollectionResponse.js → dist/serialization/types/ApidataDocumentCollection.js} +2 -2
  258. package/dist/serialization/types/{DocumentSearchResultPage.d.ts → ApidataDocumentSearchResponse.d.ts} +4 -4
  259. package/dist/serialization/types/{DocumentSearchResultPage.js → ApidataDocumentSearchResponse.js} +4 -4
  260. package/dist/serialization/types/{DocumentSearchResult.d.ts → ApidataDocumentWithScore.d.ts} +2 -2
  261. package/dist/serialization/types/{DocumentSearchResult.js → ApidataDocumentWithScore.js} +2 -2
  262. package/dist/serialization/types/EndSessionResponse.d.ts +2 -2
  263. package/dist/serialization/types/EndSessionResponse.js +2 -2
  264. package/dist/serialization/types/EntityEdge.d.ts +21 -0
  265. package/dist/serialization/types/EntityEdge.js +42 -0
  266. package/dist/serialization/types/EntityNode.d.ts +16 -0
  267. package/dist/serialization/types/EntityNode.js +37 -0
  268. package/dist/serialization/types/Episode.d.ts +18 -0
  269. package/dist/serialization/types/Episode.js +39 -0
  270. package/dist/serialization/types/EpisodeResponse.d.ts +13 -0
  271. package/dist/serialization/types/EpisodeResponse.js +34 -0
  272. package/dist/serialization/types/Fact.d.ts +9 -3
  273. package/dist/serialization/types/Fact.js +9 -3
  274. package/dist/serialization/types/GraphDataType.d.ts +10 -0
  275. package/dist/serialization/types/{MemoryType.js → GraphDataType.js} +2 -2
  276. package/dist/serialization/types/GraphSearchResults.d.ts +15 -0
  277. package/dist/serialization/types/GraphSearchResults.js +36 -0
  278. package/dist/serialization/types/GraphSearchScope.d.ts +10 -0
  279. package/{serialization/types/MemoryType.js → dist/serialization/types/GraphSearchScope.js} +2 -2
  280. package/dist/serialization/types/Group.d.ts +18 -0
  281. package/dist/serialization/types/Group.js +39 -0
  282. package/dist/serialization/types/Memory.d.ts +0 -1
  283. package/dist/serialization/types/Memory.js +0 -1
  284. package/dist/serialization/types/Message.d.ts +2 -2
  285. package/dist/serialization/types/Message.js +2 -2
  286. package/dist/serialization/types/{AddedFact.d.ts → NewFact.d.ts} +2 -2
  287. package/{serialization/types/AddedFact.js → dist/serialization/types/NewFact.js} +2 -2
  288. package/dist/serialization/types/Reranker.d.ts +10 -0
  289. package/dist/serialization/types/Reranker.js +36 -0
  290. package/dist/serialization/types/Session.d.ts +2 -3
  291. package/dist/serialization/types/Session.js +2 -3
  292. package/dist/serialization/types/{ClassifySessionResponse.d.ts → SessionClassification.d.ts} +3 -3
  293. package/{serialization/types/ClassifySessionResponse.js → dist/serialization/types/SessionClassification.js} +3 -3
  294. package/dist/serialization/types/SessionFactRatingExamples.d.ts +14 -0
  295. package/dist/serialization/types/SessionFactRatingExamples.js +35 -0
  296. package/dist/serialization/types/SessionFactRatingInstruction.d.ts +14 -0
  297. package/dist/serialization/types/SessionFactRatingInstruction.js +35 -0
  298. package/dist/serialization/types/index.d.ts +24 -14
  299. package/dist/serialization/types/index.js +24 -14
  300. package/examples/graph/conversations.ts +297 -0
  301. package/examples/graph/group_graph_example.ts +61 -0
  302. package/examples/graph/user_graph_example.ts +158 -0
  303. package/package.json +11 -22
  304. package/serialization/resources/document/client/addDocuments.d.ts +2 -2
  305. package/serialization/resources/document/client/addDocuments.js +1 -1
  306. package/serialization/resources/document/client/batchGetDocuments.d.ts +3 -3
  307. package/serialization/resources/document/client/batchGetDocuments.js +2 -2
  308. package/serialization/resources/document/client/listCollections.d.ts +3 -3
  309. package/serialization/resources/document/client/listCollections.js +2 -2
  310. package/serialization/resources/graph/client/index.d.ts +1 -0
  311. package/serialization/resources/graph/client/index.js +17 -0
  312. package/serialization/resources/graph/client/requests/AddDataRequest.d.ts +16 -0
  313. package/serialization/resources/graph/client/requests/AddDataRequest.js +37 -0
  314. package/serialization/resources/graph/client/requests/GraphSearchQuery.d.ts +22 -0
  315. package/serialization/resources/graph/client/requests/GraphSearchQuery.js +43 -0
  316. package/serialization/resources/graph/client/requests/index.d.ts +2 -0
  317. package/serialization/resources/graph/client/requests/index.js +7 -0
  318. package/serialization/resources/graph/index.d.ts +2 -0
  319. package/serialization/resources/graph/index.js +18 -0
  320. package/serialization/resources/graph/resources/edge/client/getByGroupId.d.ts +11 -0
  321. package/serialization/resources/graph/resources/edge/client/getByGroupId.js +32 -0
  322. package/serialization/resources/graph/resources/edge/client/getByUserId.d.ts +11 -0
  323. package/serialization/resources/graph/resources/edge/client/getByUserId.js +32 -0
  324. package/serialization/resources/graph/resources/edge/client/index.d.ts +2 -0
  325. package/serialization/resources/graph/resources/edge/client/index.js +28 -0
  326. package/serialization/resources/graph/resources/edge/index.d.ts +1 -0
  327. package/serialization/resources/graph/resources/edge/index.js +17 -0
  328. package/serialization/resources/graph/resources/index.d.ts +2 -0
  329. package/serialization/resources/graph/resources/index.js +28 -0
  330. package/serialization/resources/graph/resources/node/client/getByGroupId.d.ts +11 -0
  331. package/serialization/resources/graph/resources/node/client/getByGroupId.js +32 -0
  332. package/serialization/resources/graph/resources/node/client/getByUserId.d.ts +11 -0
  333. package/serialization/resources/graph/resources/node/client/getByUserId.js +32 -0
  334. package/serialization/resources/graph/resources/node/client/index.d.ts +2 -0
  335. package/serialization/resources/graph/resources/node/client/index.js +28 -0
  336. package/serialization/resources/graph/resources/node/index.d.ts +1 -0
  337. package/serialization/resources/graph/resources/node/index.js +17 -0
  338. package/serialization/resources/group/client/index.d.ts +1 -0
  339. package/serialization/resources/group/client/index.js +17 -0
  340. package/serialization/resources/group/client/requests/CreateGroupRequest.d.ts +14 -0
  341. package/serialization/resources/group/client/requests/CreateGroupRequest.js +35 -0
  342. package/serialization/resources/group/client/requests/index.d.ts +1 -0
  343. package/serialization/resources/group/client/requests/index.js +5 -0
  344. package/serialization/resources/group/index.d.ts +1 -0
  345. package/serialization/resources/group/index.js +17 -0
  346. package/serialization/resources/index.d.ts +4 -0
  347. package/serialization/resources/index.js +5 -1
  348. package/serialization/resources/memory/client/requests/AddFactsRequest.d.ts +2 -2
  349. package/serialization/resources/memory/client/requests/AddFactsRequest.js +2 -2
  350. package/serialization/resources/memory/client/requests/CreateSessionRequest.d.ts +1 -1
  351. package/serialization/resources/memory/client/requests/CreateSessionRequest.js +1 -1
  352. package/serialization/resources/memory/client/requests/SessionSearchQuery.d.ts +1 -1
  353. package/serialization/resources/memory/client/requests/SessionSearchQuery.js +1 -1
  354. package/{dist/serialization/types/DocumentResponse.d.ts → serialization/types/ApidataDocument.d.ts} +2 -2
  355. package/{dist/serialization/types/DocumentResponse.js → serialization/types/ApidataDocument.js} +2 -2
  356. package/serialization/types/{DocumentCollectionResponse.d.ts → ApidataDocumentCollection.d.ts} +2 -2
  357. package/{dist/serialization/types/DocumentCollectionResponse.js → serialization/types/ApidataDocumentCollection.js} +2 -2
  358. package/serialization/types/{DocumentSearchResultPage.d.ts → ApidataDocumentSearchResponse.d.ts} +4 -4
  359. package/serialization/types/{DocumentSearchResultPage.js → ApidataDocumentSearchResponse.js} +4 -4
  360. package/serialization/types/{DocumentSearchResult.d.ts → ApidataDocumentWithScore.d.ts} +2 -2
  361. package/serialization/types/{DocumentSearchResult.js → ApidataDocumentWithScore.js} +2 -2
  362. package/serialization/types/EndSessionResponse.d.ts +2 -2
  363. package/serialization/types/EndSessionResponse.js +2 -2
  364. package/serialization/types/EntityEdge.d.ts +21 -0
  365. package/serialization/types/EntityEdge.js +42 -0
  366. package/serialization/types/EntityNode.d.ts +16 -0
  367. package/serialization/types/EntityNode.js +37 -0
  368. package/serialization/types/Episode.d.ts +18 -0
  369. package/serialization/types/Episode.js +39 -0
  370. package/serialization/types/EpisodeResponse.d.ts +13 -0
  371. package/serialization/types/EpisodeResponse.js +34 -0
  372. package/serialization/types/Fact.d.ts +9 -3
  373. package/serialization/types/Fact.js +9 -3
  374. package/serialization/types/GraphDataType.d.ts +10 -0
  375. package/serialization/types/GraphDataType.js +31 -0
  376. package/serialization/types/GraphSearchResults.d.ts +15 -0
  377. package/serialization/types/GraphSearchResults.js +36 -0
  378. package/serialization/types/GraphSearchScope.d.ts +10 -0
  379. package/serialization/types/GraphSearchScope.js +31 -0
  380. package/serialization/types/Group.d.ts +18 -0
  381. package/serialization/types/Group.js +39 -0
  382. package/serialization/types/Memory.d.ts +0 -1
  383. package/serialization/types/Memory.js +0 -1
  384. package/serialization/types/Message.d.ts +2 -2
  385. package/serialization/types/Message.js +2 -2
  386. package/serialization/types/{AddedFact.d.ts → NewFact.d.ts} +2 -2
  387. package/{dist/serialization/types/AddedFact.js → serialization/types/NewFact.js} +2 -2
  388. package/serialization/types/Reranker.d.ts +10 -0
  389. package/serialization/types/Reranker.js +36 -0
  390. package/serialization/types/Session.d.ts +2 -3
  391. package/serialization/types/Session.js +2 -3
  392. package/serialization/types/{ClassifySessionResponse.d.ts → SessionClassification.d.ts} +3 -3
  393. package/{dist/serialization/types/ClassifySessionResponse.js → serialization/types/SessionClassification.js} +3 -3
  394. package/serialization/types/SessionFactRatingExamples.d.ts +14 -0
  395. package/serialization/types/SessionFactRatingExamples.js +35 -0
  396. package/serialization/types/SessionFactRatingInstruction.d.ts +14 -0
  397. package/serialization/types/SessionFactRatingInstruction.js +35 -0
  398. package/serialization/types/index.d.ts +24 -14
  399. package/serialization/types/index.js +24 -14
  400. package/api/types/MemoryType.d.ts +0 -9
  401. package/api/types/MemoryType.js +0 -11
  402. package/dist/api/types/MemoryType.d.ts +0 -9
  403. package/dist/api/types/MemoryType.js +0 -11
  404. package/dist/langchain/index.d.ts +0 -3
  405. package/dist/langchain/message_history.d.ts +0 -39
  406. package/dist/langchain/message_history.js +0 -109
  407. package/dist/langchain/utils.d.ts +0 -4
  408. package/dist/langchain/utils.js +0 -44
  409. package/dist/langchain/vector_store.d.ts +0 -142
  410. package/dist/langchain/vector_store.js +0 -327
  411. package/dist/langchain/zep_memory.d.ts +0 -78
  412. package/dist/langchain/zep_memory.js +0 -174
  413. package/dist/serialization/types/MemoryType.d.ts +0 -10
  414. package/examples/langchain/message_history_example.ts +0 -60
  415. package/examples/langchain/message_history_vector_store_example.ts +0 -122
  416. package/examples/langchain/vector_store_example.ts +0 -71
  417. package/langchain/index.d.ts +0 -3
  418. package/langchain/message_history.d.ts +0 -39
  419. package/langchain/message_history.js +0 -109
  420. package/langchain/utils.d.ts +0 -4
  421. package/langchain/utils.js +0 -44
  422. package/langchain/vector_store.d.ts +0 -142
  423. package/langchain/vector_store.js +0 -327
  424. package/langchain/zep_memory.d.ts +0 -78
  425. package/langchain/zep_memory.js +0 -174
  426. package/serialization/types/MemoryType.d.ts +0 -10
  427. /package/api/{types/AddedFact.js → resources/graph/client/requests/AddDataRequest.js} +0 -0
  428. /package/api/{types/ClassifySessionResponse.js → resources/graph/client/requests/GraphSearchQuery.js} +0 -0
  429. /package/api/{types/DocumentCollectionResponse.js → resources/graph/resources/episode/client/requests/EpisodeGetByGroupIdRequest.js} +0 -0
  430. /package/api/{types/DocumentResponse.js → resources/graph/resources/episode/client/requests/EpisodeGetByUserIdRequest.js} +0 -0
  431. /package/api/{types/DocumentSearchResult.js → resources/group/client/requests/CreateGroupRequest.js} +0 -0
  432. /package/api/types/{DocumentSearchResultPage.js → ApidataDocument.js} +0 -0
  433. /package/{dist/api/types/AddedFact.js → api/types/ApidataDocumentCollection.js} +0 -0
  434. /package/{dist/api/types/ClassifySessionResponse.js → api/types/ApidataDocumentSearchResponse.js} +0 -0
  435. /package/{dist/api/types/DocumentCollectionResponse.js → api/types/ApidataDocumentWithScore.js} +0 -0
  436. /package/{dist/api/types/DocumentResponse.js → api/types/EntityEdge.js} +0 -0
  437. /package/{dist/api/types/DocumentSearchResult.js → api/types/EntityNode.js} +0 -0
  438. /package/{dist/api/types/DocumentSearchResultPage.js → api/types/Episode.js} +0 -0
@@ -1,44 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.condenseZepMemoryIntoHumanMessage = exports.getZepMessageRoleType = void 0;
4
- const messages_1 = require("@langchain/core/messages");
5
- const getZepMessageRoleType = (role) => {
6
- switch (role) {
7
- case "human":
8
- return "user";
9
- case "ai":
10
- return "assistant";
11
- case "system":
12
- return "system";
13
- case "function":
14
- return "function";
15
- case "tool":
16
- return "tool";
17
- default:
18
- return "norole";
19
- }
20
- };
21
- exports.getZepMessageRoleType = getZepMessageRoleType;
22
- const condenseZepMemoryIntoHumanMessage = (memory) => {
23
- var _a;
24
- let systemPrompt = "";
25
- if (memory.relevantFacts) {
26
- const relevantFactStrings = memory.relevantFacts.map(({ fact }) => fact).filter(x => !!x);
27
- systemPrompt += relevantFactStrings.join("\n");
28
- }
29
- // Extract summary, if present, and messages
30
- if (memory.summary && ((_a = memory.summary) === null || _a === void 0 ? void 0 : _a.content)) {
31
- systemPrompt += memory.summary.content;
32
- }
33
- let concatMessages = "";
34
- if (memory.messages) {
35
- concatMessages = memory.messages
36
- .map((msg) => {
37
- var _a;
38
- return `${(_a = msg.role) !== null && _a !== void 0 ? _a : msg.roleType}: ${msg.content}`;
39
- })
40
- .join("\n");
41
- }
42
- return new messages_1.HumanMessage(systemPrompt + "\n" + concatMessages);
43
- };
44
- exports.condenseZepMemoryIntoHumanMessage = condenseZepMemoryIntoHumanMessage;
@@ -1,142 +0,0 @@
1
- import type { EmbeddingsInterface } from "@langchain/core/embeddings";
2
- import { MaxMarginalRelevanceSearchOptions, VectorStore } from "@langchain/core/vectorstores";
3
- import { Document } from "@langchain/core/documents";
4
- import { Callbacks } from "@langchain/core/callbacks/manager";
5
- import { ZepClient } from "../";
6
- /**
7
- * Interface for the configuration options for a ZepVectorStore instance.
8
- */
9
- export interface IZepConfig {
10
- apiUrl?: string;
11
- apiKey?: string;
12
- client?: ZepClient;
13
- collectionName: string;
14
- description?: string;
15
- metadata?: Record<string, never>;
16
- }
17
- /**
18
- * Interface for the parameters required to delete documents from a
19
- * ZepVectorStore instance.
20
- */
21
- export interface IZepDeleteParams {
22
- uuids: string[];
23
- }
24
- /**
25
- * ZepVectorStore is a VectorStore implementation
26
- * that uses the Zep long-term memory store as a backend.
27
- *
28
- * If the collection does not exist, it will be created automatically.
29
- *
30
- * Requires `zep-js` to be installed:
31
- * ```bash
32
- * npm install @getzep/zep-js
33
- * ```
34
- *
35
- * @property {ZepClient} client - The ZepClient instance used to interact with Zep's API.
36
- * @property {Promise<void>} initPromise - A promise that resolves
37
- * when the collection is initialized.
38
- * @property {DocumentCollection} collection - The Zep document collection.
39
- */
40
- export declare class ZepVectorStore extends VectorStore {
41
- client: ZepClient;
42
- collectionName: string;
43
- private readonly initPromise;
44
- constructor(embeddings: EmbeddingsInterface, args: IZepConfig);
45
- /**
46
- * Initializes the document collection. If the collection does not exist, it creates a new one.
47
- *
48
- * @param {IZepConfig} args - The configuration object for the Zep API.
49
- */
50
- private initCollection;
51
- /**
52
- * Creates a new document collection.
53
- *
54
- * @param {IZepConfig} args - The configuration object for the Zep API.
55
- */
56
- private createCollection;
57
- /**
58
- * Adds vectors and corresponding documents to the collection.
59
- *
60
- * @param {number[][]} vectors - The vectors to add.
61
- * @param {Document[]} documents - The corresponding documents to add.
62
- * @returns {Promise<string[]>} - A promise that resolves with the UUIDs of the added documents.
63
- */
64
- addVectors(vectors: number[][], documents: Document[]): Promise<string[]>;
65
- /**
66
- * Adds documents to the collection. The documents are first embedded into vectors
67
- * using the provided embedding model.
68
- *
69
- * @param {Document[]} documents - The documents to add.
70
- * @returns {Promise<string[]>} - A promise that resolves with the UUIDs of the added documents.
71
- */
72
- addDocuments(documents: Document[]): Promise<string[]>;
73
- _vectorstoreType(): string;
74
- /**
75
- * Deletes documents from the collection.
76
- *
77
- * @param {IZepDeleteParams} params - The list of Zep document UUIDs to delete.
78
- * @returns {Promise<void>}
79
- */
80
- delete(params: IZepDeleteParams): Promise<void>;
81
- /**
82
- * Performs a similarity search in the collection and returns the results with their scores.
83
- *
84
- * @param {number[]} query - The query vector.
85
- * @param {number} k - The number of results to return.
86
- * @param {Record<string, unknown>} filter - The filter to apply to the search. Zep only supports Record<string, unknown> as filter.
87
- * @returns {Promise<[Document, number][]>} - A promise that resolves with the search results and their scores.
88
- */
89
- similaritySearchVectorWithScore(query: number[], k: number, filter?: Record<string, unknown> | undefined): Promise<[Document, number][]>;
90
- _similaritySearchWithScore(query: string, k: number, filter?: Record<string, unknown> | undefined): Promise<[Document, number][]>;
91
- similaritySearchWithScore(query: string, k?: number, filter?: Record<string, unknown> | undefined, _callbacks?: undefined): Promise<[Document, number][]>;
92
- /**
93
- * Performs a similarity search on the Zep collection.
94
- *
95
- * @param {string} query - The query string to search for.
96
- * @param {number} [k=4] - The number of results to return. Defaults to 4.
97
- * @param {this["FilterType"] | undefined} [filter=undefined] - An optional set of JSONPath filters to apply to the search.
98
- * @param {Callbacks | undefined} [_callbacks=undefined] - Optional callbacks. Currently not implemented.
99
- * @returns {Promise<Document[]>} - A promise that resolves to an array of Documents that are similar to the query.
100
- *
101
- * @async
102
- */
103
- similaritySearch(query: string, k?: number, filter?: this["FilterType"] | undefined, _callbacks?: Callbacks | undefined): Promise<Document[]>;
104
- /**
105
- * Return documents selected using the maximal marginal relevance.
106
- * Maximal marginal relevance optimizes for similarity to the query AND diversity
107
- * among selected documents.
108
- *
109
- * @param {string} query - Text to look up documents similar to.
110
- * @param options
111
- * @param {number} options.k - Number of documents to return.
112
- * @param {number} options.fetchK=20- Number of documents to fetch before passing to the MMR algorithm.
113
- * @param {number} options.lambda=0.5 - Number between 0 and 1 that determines the degree of diversity among the results,
114
- * where 0 corresponds to maximum diversity and 1 to minimum diversity.
115
- * @param {Record<string, any>} options.filter - Optional Zep JSONPath query to pre-filter on document metadata field
116
- *
117
- * @returns {Promise<Document[]>} - List of documents selected by maximal marginal relevance.
118
- */
119
- maxMarginalRelevanceSearch(query: string, options: MaxMarginalRelevanceSearchOptions<this["FilterType"]>): Promise<Document[]>;
120
- static init(zepConfig: IZepConfig): Promise<ZepVectorStore>;
121
- /**
122
- * Creates a new ZepVectorStore instance from an array of texts. Each text is converted into a Document and added to the collection.
123
- *
124
- * @param {string[]} texts - The texts to convert into Documents.
125
- * @param {object[] | object} metadatas - The metadata to associate with each Document.
126
- * If an array is provided, each element is associated with the corresponding Document.
127
- * If an object is provided, it is associated with all Documents.
128
- * @param {Embeddings} embeddings - The embeddings to use for vectorizing the texts.
129
- * @param {IZepConfig} zepConfig - The configuration object for the Zep API.
130
- * @returns {Promise<ZepVectorStore>} - A promise that resolves with the new ZepVectorStore instance.
131
- */
132
- static fromTexts(texts: string[], metadatas: object[] | object, embeddings: EmbeddingsInterface, zepConfig: IZepConfig): Promise<ZepVectorStore>;
133
- /**
134
- * Creates a new ZepVectorStore instance from an array of Documents. Each Document is added to a Zep collection.
135
- *
136
- * @param {Document[]} docs - The Documents to add.
137
- * @param {Embeddings} embeddings - The embeddings to use for vectorizing the Document contents.
138
- * @param {IZepConfig} zepConfig - The configuration object for the Zep API.
139
- * @returns {Promise<ZepVectorStore>} - A promise that resolves with the new ZepVectorStore instance.
140
- */
141
- static fromDocuments(docs: Document[], embeddings: EmbeddingsInterface, zepConfig: IZepConfig): Promise<ZepVectorStore>;
142
- }
@@ -1,327 +0,0 @@
1
- "use strict";
2
- /* eslint import/no-extraneous-dependencies: 0 */
3
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5
- return new (P || (P = Promise))(function (resolve, reject) {
6
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
7
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
8
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
9
- step((generator = generator.apply(thisArg, _arguments || [])).next());
10
- });
11
- };
12
- var __asyncValues = (this && this.__asyncValues) || function (o) {
13
- if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
14
- var m = o[Symbol.asyncIterator], i;
15
- return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
16
- function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
17
- function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
18
- };
19
- Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.ZepVectorStore = void 0;
21
- const vectorstores_1 = require("@langchain/core/vectorstores");
22
- const documents_1 = require("@langchain/core/documents");
23
- const math_1 = require("@langchain/core/utils/math");
24
- const testing_1 = require("@langchain/core/utils/testing");
25
- const api_1 = require("../api");
26
- const __1 = require("../");
27
- function zepDocsToDocumentsAndScore(results) {
28
- return results.map((d) => {
29
- var _a;
30
- return [
31
- new documents_1.Document({
32
- pageContent: (_a = d.content) !== null && _a !== void 0 ? _a : "",
33
- metadata: d.metadata,
34
- }),
35
- d.score ? d.score : 0,
36
- ];
37
- });
38
- }
39
- function assignMetadata(value) {
40
- if (typeof value === "object" && value !== null) {
41
- return value;
42
- }
43
- if (value !== undefined) {
44
- console.warn("Metadata filters must be an object, Record, or undefined.");
45
- }
46
- return undefined;
47
- }
48
- /**
49
- * ZepVectorStore is a VectorStore implementation
50
- * that uses the Zep long-term memory store as a backend.
51
- *
52
- * If the collection does not exist, it will be created automatically.
53
- *
54
- * Requires `zep-js` to be installed:
55
- * ```bash
56
- * npm install @getzep/zep-js
57
- * ```
58
- *
59
- * @property {ZepClient} client - The ZepClient instance used to interact with Zep's API.
60
- * @property {Promise<void>} initPromise - A promise that resolves
61
- * when the collection is initialized.
62
- * @property {DocumentCollection} collection - The Zep document collection.
63
- */
64
- class ZepVectorStore extends vectorstores_1.VectorStore {
65
- constructor(embeddings, args) {
66
- super(embeddings, args);
67
- this.initPromise = this.initCollection(args).catch((err) => {
68
- console.error("Error initializing collection:", err);
69
- throw err;
70
- });
71
- }
72
- /**
73
- * Initializes the document collection. If the collection does not exist, it creates a new one.
74
- *
75
- * @param {IZepConfig} args - The configuration object for the Zep API.
76
- */
77
- initCollection(args) {
78
- return __awaiter(this, void 0, void 0, function* () {
79
- if (args.client) {
80
- this.client = args.client;
81
- }
82
- else {
83
- this.client = new __1.ZepClient({
84
- apiKey: args.apiKey,
85
- environment: args.apiUrl,
86
- });
87
- }
88
- try {
89
- this.collectionName = args.collectionName;
90
- yield this.client.document.getCollection(this.collectionName);
91
- }
92
- catch (err) {
93
- if (err instanceof Error) {
94
- if (err instanceof api_1.NotFoundError || err.name === "NotFoundError") {
95
- yield this.createCollection(args);
96
- }
97
- else {
98
- throw err;
99
- }
100
- }
101
- }
102
- });
103
- }
104
- /**
105
- * Creates a new document collection.
106
- *
107
- * @param {IZepConfig} args - The configuration object for the Zep API.
108
- */
109
- createCollection(args) {
110
- return __awaiter(this, void 0, void 0, function* () {
111
- yield this.client.document.addCollection(args.collectionName, {
112
- description: args.description,
113
- metadata: args.metadata,
114
- });
115
- // eslint-disable-next-line no-console
116
- console.info("Created new collection:", args.collectionName);
117
- });
118
- }
119
- /**
120
- * Adds vectors and corresponding documents to the collection.
121
- *
122
- * @param {number[][]} vectors - The vectors to add.
123
- * @param {Document[]} documents - The corresponding documents to add.
124
- * @returns {Promise<string[]>} - A promise that resolves with the UUIDs of the added documents.
125
- */
126
- addVectors(vectors, documents) {
127
- return __awaiter(this, void 0, void 0, function* () {
128
- const docs = [];
129
- for (let i = 0; i < documents.length; i += 1) {
130
- const doc = {
131
- content: documents[i].pageContent,
132
- metadata: documents[i].metadata,
133
- };
134
- docs.push(doc);
135
- }
136
- // Wait for collection to be initialized
137
- yield this.initPromise;
138
- return this.client.document.addDocuments(this.collectionName, docs);
139
- });
140
- }
141
- /**
142
- * Adds documents to the collection. The documents are first embedded into vectors
143
- * using the provided embedding model.
144
- *
145
- * @param {Document[]} documents - The documents to add.
146
- * @returns {Promise<string[]>} - A promise that resolves with the UUIDs of the added documents.
147
- */
148
- addDocuments(documents) {
149
- return __awaiter(this, void 0, void 0, function* () {
150
- const vectors = [];
151
- return this.addVectors(vectors, documents);
152
- });
153
- }
154
- // eslint-disable-next-line class-methods-use-this,no-underscore-dangle
155
- _vectorstoreType() {
156
- return "zep";
157
- }
158
- /**
159
- * Deletes documents from the collection.
160
- *
161
- * @param {IZepDeleteParams} params - The list of Zep document UUIDs to delete.
162
- * @returns {Promise<void>}
163
- */
164
- delete(params) {
165
- var e_1, _a;
166
- return __awaiter(this, void 0, void 0, function* () {
167
- // Wait for collection to be initialized
168
- yield this.initPromise;
169
- try {
170
- // eslint-disable-next-line no-restricted-syntax
171
- for (var _b = __asyncValues(params.uuids), _c; _c = yield _b.next(), !_c.done;) {
172
- const uuid = _c.value;
173
- yield this.client.document.deleteDocument(this.collectionName, uuid);
174
- }
175
- }
176
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
177
- finally {
178
- try {
179
- if (_c && !_c.done && (_a = _b.return)) yield _a.call(_b);
180
- }
181
- finally { if (e_1) throw e_1.error; }
182
- }
183
- });
184
- }
185
- /**
186
- * Performs a similarity search in the collection and returns the results with their scores.
187
- *
188
- * @param {number[]} query - The query vector.
189
- * @param {number} k - The number of results to return.
190
- * @param {Record<string, unknown>} filter - The filter to apply to the search. Zep only supports Record<string, unknown> as filter.
191
- * @returns {Promise<[Document, number][]>} - A promise that resolves with the search results and their scores.
192
- */
193
- similaritySearchVectorWithScore(query, k, filter) {
194
- return __awaiter(this, void 0, void 0, function* () {
195
- // Deprecated
196
- console.warn("Zep does not support vector search. Using text search instead.");
197
- return [];
198
- });
199
- }
200
- // eslint-disable-next-line no-underscore-dangle
201
- _similaritySearchWithScore(query, k, filter) {
202
- return __awaiter(this, void 0, void 0, function* () {
203
- yield this.initPromise;
204
- const { results } = yield this.client.document.search(this.collectionName, {
205
- text: query,
206
- metadata: assignMetadata(filter),
207
- limit: k,
208
- });
209
- return zepDocsToDocumentsAndScore(results);
210
- });
211
- }
212
- similaritySearchWithScore(query, k = 4, filter = undefined,
213
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
214
- _callbacks = undefined // implement passing to embedQuery later
215
- ) {
216
- return __awaiter(this, void 0, void 0, function* () {
217
- return this._similaritySearchWithScore(query, k, filter);
218
- });
219
- }
220
- /**
221
- * Performs a similarity search on the Zep collection.
222
- *
223
- * @param {string} query - The query string to search for.
224
- * @param {number} [k=4] - The number of results to return. Defaults to 4.
225
- * @param {this["FilterType"] | undefined} [filter=undefined] - An optional set of JSONPath filters to apply to the search.
226
- * @param {Callbacks | undefined} [_callbacks=undefined] - Optional callbacks. Currently not implemented.
227
- * @returns {Promise<Document[]>} - A promise that resolves to an array of Documents that are similar to the query.
228
- *
229
- * @async
230
- */
231
- similaritySearch(query, k = 4, filter = undefined,
232
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
233
- _callbacks = undefined // implement passing to embedQuery later
234
- ) {
235
- return __awaiter(this, void 0, void 0, function* () {
236
- yield this.initPromise;
237
- const { results: zepResults } = yield this.client.document.search(this.collectionName, {
238
- text: query,
239
- metadata: assignMetadata(filter),
240
- limit: k,
241
- });
242
- const results = zepDocsToDocumentsAndScore(zepResults);
243
- return results.map((result) => result[0]);
244
- });
245
- }
246
- /**
247
- * Return documents selected using the maximal marginal relevance.
248
- * Maximal marginal relevance optimizes for similarity to the query AND diversity
249
- * among selected documents.
250
- *
251
- * @param {string} query - Text to look up documents similar to.
252
- * @param options
253
- * @param {number} options.k - Number of documents to return.
254
- * @param {number} options.fetchK=20- Number of documents to fetch before passing to the MMR algorithm.
255
- * @param {number} options.lambda=0.5 - Number between 0 and 1 that determines the degree of diversity among the results,
256
- * where 0 corresponds to maximum diversity and 1 to minimum diversity.
257
- * @param {Record<string, any>} options.filter - Optional Zep JSONPath query to pre-filter on document metadata field
258
- *
259
- * @returns {Promise<Document[]>} - List of documents selected by maximal marginal relevance.
260
- */
261
- maxMarginalRelevanceSearch(query, options) {
262
- return __awaiter(this, void 0, void 0, function* () {
263
- const { k, fetchK = 20, lambda = 0.5, filter } = options;
264
- const r = yield this.client.document.search(this.collectionName, {
265
- text: query,
266
- metadata: assignMetadata(filter),
267
- limit: fetchK,
268
- });
269
- const queryEmbedding = Array.from(r.queryVector);
270
- const results = zepDocsToDocumentsAndScore(r.results);
271
- const embeddingList = r.results.map((doc) => Array.from(doc.embedding ? doc.embedding : []));
272
- const mmrIndexes = (0, math_1.maximalMarginalRelevance)(queryEmbedding, embeddingList, lambda, k);
273
- return mmrIndexes.filter((idx) => idx !== -1).map((idx) => results[idx][0]);
274
- });
275
- }
276
- static init(zepConfig) {
277
- return __awaiter(this, void 0, void 0, function* () {
278
- const instance = new this(new testing_1.FakeEmbeddings(), zepConfig);
279
- // Wait for collection to be initialized
280
- yield instance.initPromise;
281
- return instance;
282
- });
283
- }
284
- /**
285
- * Creates a new ZepVectorStore instance from an array of texts. Each text is converted into a Document and added to the collection.
286
- *
287
- * @param {string[]} texts - The texts to convert into Documents.
288
- * @param {object[] | object} metadatas - The metadata to associate with each Document.
289
- * If an array is provided, each element is associated with the corresponding Document.
290
- * If an object is provided, it is associated with all Documents.
291
- * @param {Embeddings} embeddings - The embeddings to use for vectorizing the texts.
292
- * @param {IZepConfig} zepConfig - The configuration object for the Zep API.
293
- * @returns {Promise<ZepVectorStore>} - A promise that resolves with the new ZepVectorStore instance.
294
- */
295
- static fromTexts(texts, metadatas, embeddings, zepConfig) {
296
- return __awaiter(this, void 0, void 0, function* () {
297
- const docs = [];
298
- for (let i = 0; i < texts.length; i += 1) {
299
- const metadata = Array.isArray(metadatas) ? metadatas[i] : metadatas;
300
- const newDoc = new documents_1.Document({
301
- pageContent: texts[i],
302
- metadata,
303
- });
304
- docs.push(newDoc);
305
- }
306
- return ZepVectorStore.fromDocuments(docs, embeddings, zepConfig);
307
- });
308
- }
309
- /**
310
- * Creates a new ZepVectorStore instance from an array of Documents. Each Document is added to a Zep collection.
311
- *
312
- * @param {Document[]} docs - The Documents to add.
313
- * @param {Embeddings} embeddings - The embeddings to use for vectorizing the Document contents.
314
- * @param {IZepConfig} zepConfig - The configuration object for the Zep API.
315
- * @returns {Promise<ZepVectorStore>} - A promise that resolves with the new ZepVectorStore instance.
316
- */
317
- static fromDocuments(docs, embeddings, zepConfig) {
318
- return __awaiter(this, void 0, void 0, function* () {
319
- const instance = new this(embeddings, zepConfig);
320
- // Wait for collection to be initialized
321
- yield instance.initPromise;
322
- yield instance.addDocuments(docs);
323
- return instance;
324
- });
325
- }
326
- }
327
- exports.ZepVectorStore = ZepVectorStore;
@@ -1,78 +0,0 @@
1
- import { InputValues, MemoryVariables, OutputValues } from "@langchain/core/memory";
2
- import { BaseChatMemory, BaseChatMemoryInput } from "langchain/memory";
3
- import { ZepClient } from "../";
4
- export interface ZepMemoryInput extends BaseChatMemoryInput {
5
- humanPrefix?: string;
6
- aiPrefix?: string;
7
- memoryKey?: string;
8
- baseURL?: string;
9
- sessionId: string;
10
- apiKey: string;
11
- }
12
- /**
13
- * Class used to manage the memory of a chat session, including loading
14
- * and saving the chat history, and clearing the memory when needed. It
15
- * uses the ZepClient to interact with the Zep service for managing the
16
- * chat session's memory.
17
- * @example
18
- * ```typescript
19
- * const sessionId = randomUUID();
20
- *
21
- * // Initialize ZepMemory with session ID, base URL, and API key
22
- * const memory = new ZepMemory({
23
- * sessionId,
24
- * apiKey: "change_this_key",
25
- * });
26
- *
27
- * // Create a ChatOpenAI model instance with specific parameters
28
- * const model = new ChatOpenAI({
29
- * modelName: "gpt-3.5-turbo",
30
- * temperature: 0,
31
- * });
32
- *
33
- * // Create a ConversationChain with the model and memory
34
- * const chain = new ConversationChain({ llm: model, memory });
35
- *
36
- * // Example of calling the chain with an input
37
- * const res1 = await chain.call({ input: "Hi! I'm Jim." });
38
- * console.log({ res1 });
39
- *
40
- * // Follow-up call to the chain to demonstrate memory usage
41
- * const res2 = await chain.call({ input: "What did I just say my name was?" });
42
- * console.log({ res2 });
43
- *
44
- * // Output the session ID and the current state of memory
45
- * console.log("Session ID: ", sessionId);
46
- * console.log("Memory: ", await memory.loadMemoryVariables({}));
47
- *
48
- * ```
49
- */
50
- export declare class ZepMemory extends BaseChatMemory implements ZepMemoryInput {
51
- humanPrefix: string;
52
- aiPrefix: string;
53
- memoryKey: string;
54
- apiKey: string;
55
- sessionId: string;
56
- zepClient: ZepClient;
57
- constructor(fields: ZepMemoryInput);
58
- get memoryKeys(): string[];
59
- /**
60
- * Method that retrieves the chat history from the Zep service and formats
61
- * it into a list of messages.
62
- * @param values Input values for the method.
63
- * @returns Promise that resolves with the chat history formatted into a list of messages.
64
- */
65
- loadMemoryVariables(values: InputValues): Promise<MemoryVariables>;
66
- /**
67
- * Method that saves the input and output messages to the Zep service.
68
- * @param inputValues Input messages to be saved.
69
- * @param outputValues Output messages to be saved.
70
- * @returns Promise that resolves when the messages have been saved.
71
- */
72
- saveContext(inputValues: InputValues, outputValues: OutputValues): Promise<void>;
73
- /**
74
- * Method that deletes the chat history from the Zep service.
75
- * @returns Promise that resolves when the chat history has been deleted.
76
- */
77
- clear(): Promise<void>;
78
- }