@getzep/zep-cloud 1.0.11 → 2.0.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (439) hide show
  1. package/Client.d.ts +6 -0
  2. package/Client.js +12 -2
  3. package/LICENSE +201 -0
  4. package/README.md +15 -3
  5. package/api/resources/document/client/Client.d.ts +9 -9
  6. package/api/resources/document/client/Client.js +20 -20
  7. package/api/resources/graph/client/Client.d.ts +62 -0
  8. package/api/resources/graph/client/Client.js +225 -0
  9. package/api/resources/graph/client/index.d.ts +1 -0
  10. package/{dist/langchain → api/resources/graph/client}/index.js +1 -3
  11. package/api/resources/graph/client/requests/AddDataRequest.d.ts +14 -0
  12. package/api/resources/graph/client/requests/GraphSearchQuery.d.ts +30 -0
  13. package/api/resources/graph/client/requests/index.d.ts +2 -0
  14. package/api/resources/graph/client/requests/index.js +2 -0
  15. package/api/resources/graph/index.d.ts +2 -0
  16. package/{langchain → api/resources/graph}/index.js +2 -3
  17. package/api/resources/graph/resources/edge/client/Client.d.ts +78 -0
  18. package/api/resources/graph/resources/edge/client/Client.js +361 -0
  19. package/api/resources/graph/resources/edge/client/index.d.ts +1 -0
  20. package/api/resources/graph/resources/edge/client/index.js +2 -0
  21. package/api/resources/graph/resources/edge/index.d.ts +1 -0
  22. package/api/resources/graph/resources/edge/index.js +17 -0
  23. package/api/resources/graph/resources/episode/client/Client.d.ts +66 -0
  24. package/api/resources/graph/resources/episode/client/Client.js +293 -0
  25. package/api/resources/graph/resources/episode/client/index.d.ts +1 -0
  26. package/api/resources/graph/resources/episode/client/index.js +17 -0
  27. package/api/resources/graph/resources/episode/client/requests/EpisodeGetByGroupIdRequest.d.ts +13 -0
  28. package/api/resources/graph/resources/episode/client/requests/EpisodeGetByUserIdRequest.d.ts +13 -0
  29. package/api/resources/graph/resources/episode/client/requests/index.d.ts +2 -0
  30. package/api/resources/graph/resources/episode/client/requests/index.js +2 -0
  31. package/api/resources/graph/resources/episode/index.d.ts +1 -0
  32. package/api/resources/graph/resources/episode/index.js +17 -0
  33. package/api/resources/graph/resources/index.d.ts +4 -0
  34. package/api/resources/graph/resources/index.js +33 -0
  35. package/api/resources/graph/resources/node/client/Client.d.ts +65 -0
  36. package/api/resources/graph/resources/node/client/Client.js +288 -0
  37. package/api/resources/graph/resources/node/client/index.d.ts +1 -0
  38. package/api/resources/graph/resources/node/client/index.js +2 -0
  39. package/api/resources/graph/resources/node/index.d.ts +1 -0
  40. package/api/resources/graph/resources/node/index.js +17 -0
  41. package/api/resources/group/client/Client.d.ts +52 -0
  42. package/api/resources/group/client/Client.js +216 -0
  43. package/api/resources/group/client/index.d.ts +1 -0
  44. package/api/resources/group/client/index.js +17 -0
  45. package/api/resources/group/client/requests/CreateGroupRequest.d.ts +12 -0
  46. package/api/resources/group/client/requests/index.d.ts +1 -0
  47. package/api/resources/group/client/requests/index.js +2 -0
  48. package/api/resources/group/index.d.ts +1 -0
  49. package/api/resources/group/index.js +17 -0
  50. package/api/resources/index.d.ts +4 -0
  51. package/api/resources/index.js +5 -1
  52. package/api/resources/memory/client/Client.d.ts +22 -12
  53. package/api/resources/memory/client/Client.js +45 -38
  54. package/api/resources/memory/client/requests/AddFactsRequest.d.ts +1 -1
  55. package/api/resources/memory/client/requests/AddMemoryRequest.d.ts +6 -3
  56. package/api/resources/memory/client/requests/CreateSessionRequest.d.ts +3 -2
  57. package/api/resources/memory/client/requests/MemoryGetRequest.d.ts +0 -5
  58. package/api/resources/memory/client/requests/MemoryGetSessionFactsRequest.d.ts +1 -1
  59. package/api/resources/memory/client/requests/ModelsMessageMetadataUpdate.d.ts +3 -1
  60. package/api/resources/memory/client/requests/SessionSearchQuery.d.ts +12 -3
  61. package/api/resources/memory/client/requests/UpdateSessionRequest.d.ts +3 -1
  62. package/api/resources/user/client/Client.d.ts +13 -0
  63. package/api/resources/user/client/Client.js +79 -6
  64. package/{dist/api/types/DocumentResponse.d.ts → api/types/ApidataDocument.d.ts} +1 -1
  65. package/api/types/{DocumentCollectionResponse.d.ts → ApidataDocumentCollection.d.ts} +1 -3
  66. package/api/types/{DocumentSearchResultPage.d.ts → ApidataDocumentSearchResponse.d.ts} +2 -2
  67. package/api/types/{DocumentSearchResult.d.ts → ApidataDocumentWithScore.d.ts} +1 -1
  68. package/api/types/EndSessionResponse.d.ts +1 -1
  69. package/api/types/EntityEdge.d.ts +25 -0
  70. package/api/types/EntityNode.d.ts +15 -0
  71. package/api/types/Episode.d.ts +12 -0
  72. package/api/types/EpisodeResponse.d.ts +7 -0
  73. package/api/types/EpisodeResponse.js +5 -0
  74. package/api/types/Fact.d.ts +9 -3
  75. package/api/types/GraphDataType.d.ts +9 -0
  76. package/api/types/GraphDataType.js +11 -0
  77. package/api/types/GraphSearchResults.d.ts +8 -0
  78. package/api/types/GraphSearchResults.js +5 -0
  79. package/api/types/GraphSearchScope.d.ts +8 -0
  80. package/api/types/GraphSearchScope.js +10 -0
  81. package/api/types/Group.d.ts +12 -0
  82. package/api/types/Group.js +5 -0
  83. package/api/types/Memory.d.ts +4 -5
  84. package/api/types/Message.d.ts +2 -2
  85. package/api/types/{AddedFact.d.ts → NewFact.d.ts} +1 -1
  86. package/api/types/NewFact.js +5 -0
  87. package/api/types/Reranker.d.ts +10 -0
  88. package/api/types/Reranker.js +12 -0
  89. package/api/types/Session.d.ts +1 -2
  90. package/api/types/{ClassifySessionResponse.d.ts → SessionClassification.d.ts} +2 -2
  91. package/api/types/SessionClassification.js +5 -0
  92. package/api/types/SessionFactRatingExamples.d.ts +8 -0
  93. package/api/types/SessionFactRatingExamples.js +5 -0
  94. package/api/types/SessionFactRatingInstruction.d.ts +21 -0
  95. package/api/types/SessionFactRatingInstruction.js +5 -0
  96. package/api/types/index.d.ts +24 -14
  97. package/api/types/index.js +24 -14
  98. package/dist/Client.d.ts +6 -0
  99. package/dist/Client.js +12 -2
  100. package/dist/api/resources/document/client/Client.d.ts +9 -9
  101. package/dist/api/resources/document/client/Client.js +20 -20
  102. package/dist/api/resources/graph/client/Client.d.ts +62 -0
  103. package/dist/api/resources/graph/client/Client.js +225 -0
  104. package/dist/api/resources/graph/client/index.d.ts +1 -0
  105. package/dist/api/resources/graph/client/index.js +17 -0
  106. package/dist/api/resources/graph/client/requests/AddDataRequest.d.ts +14 -0
  107. package/dist/api/resources/graph/client/requests/AddDataRequest.js +5 -0
  108. package/dist/api/resources/graph/client/requests/GraphSearchQuery.d.ts +30 -0
  109. package/dist/api/resources/graph/client/requests/GraphSearchQuery.js +5 -0
  110. package/dist/api/resources/graph/client/requests/index.d.ts +2 -0
  111. package/dist/api/resources/graph/client/requests/index.js +2 -0
  112. package/dist/api/resources/graph/index.d.ts +2 -0
  113. package/dist/api/resources/graph/index.js +18 -0
  114. package/dist/api/resources/graph/resources/edge/client/Client.d.ts +78 -0
  115. package/dist/api/resources/graph/resources/edge/client/Client.js +361 -0
  116. package/dist/api/resources/graph/resources/edge/client/index.d.ts +1 -0
  117. package/dist/api/resources/graph/resources/edge/client/index.js +2 -0
  118. package/dist/api/resources/graph/resources/edge/index.d.ts +1 -0
  119. package/dist/api/resources/graph/resources/edge/index.js +17 -0
  120. package/dist/api/resources/graph/resources/episode/client/Client.d.ts +66 -0
  121. package/dist/api/resources/graph/resources/episode/client/Client.js +293 -0
  122. package/dist/api/resources/graph/resources/episode/client/index.d.ts +1 -0
  123. package/dist/api/resources/graph/resources/episode/client/index.js +17 -0
  124. package/dist/api/resources/graph/resources/episode/client/requests/EpisodeGetByGroupIdRequest.d.ts +13 -0
  125. package/dist/api/resources/graph/resources/episode/client/requests/EpisodeGetByGroupIdRequest.js +5 -0
  126. package/dist/api/resources/graph/resources/episode/client/requests/EpisodeGetByUserIdRequest.d.ts +13 -0
  127. package/dist/api/resources/graph/resources/episode/client/requests/EpisodeGetByUserIdRequest.js +5 -0
  128. package/dist/api/resources/graph/resources/episode/client/requests/index.d.ts +2 -0
  129. package/dist/api/resources/graph/resources/episode/client/requests/index.js +2 -0
  130. package/dist/api/resources/graph/resources/episode/index.d.ts +1 -0
  131. package/dist/api/resources/graph/resources/episode/index.js +17 -0
  132. package/dist/api/resources/graph/resources/index.d.ts +4 -0
  133. package/dist/api/resources/graph/resources/index.js +33 -0
  134. package/dist/api/resources/graph/resources/node/client/Client.d.ts +65 -0
  135. package/dist/api/resources/graph/resources/node/client/Client.js +288 -0
  136. package/dist/api/resources/graph/resources/node/client/index.d.ts +1 -0
  137. package/dist/api/resources/graph/resources/node/client/index.js +2 -0
  138. package/dist/api/resources/graph/resources/node/index.d.ts +1 -0
  139. package/dist/api/resources/graph/resources/node/index.js +17 -0
  140. package/dist/api/resources/group/client/Client.d.ts +52 -0
  141. package/dist/api/resources/group/client/Client.js +216 -0
  142. package/dist/api/resources/group/client/index.d.ts +1 -0
  143. package/dist/api/resources/group/client/index.js +17 -0
  144. package/dist/api/resources/group/client/requests/CreateGroupRequest.d.ts +12 -0
  145. package/dist/api/resources/group/client/requests/CreateGroupRequest.js +5 -0
  146. package/dist/api/resources/group/client/requests/index.d.ts +1 -0
  147. package/dist/api/resources/group/client/requests/index.js +2 -0
  148. package/dist/api/resources/group/index.d.ts +1 -0
  149. package/dist/api/resources/group/index.js +17 -0
  150. package/dist/api/resources/index.d.ts +4 -0
  151. package/dist/api/resources/index.js +5 -1
  152. package/dist/api/resources/memory/client/Client.d.ts +22 -12
  153. package/dist/api/resources/memory/client/Client.js +45 -38
  154. package/dist/api/resources/memory/client/requests/AddFactsRequest.d.ts +1 -1
  155. package/dist/api/resources/memory/client/requests/AddMemoryRequest.d.ts +6 -3
  156. package/dist/api/resources/memory/client/requests/CreateSessionRequest.d.ts +3 -2
  157. package/dist/api/resources/memory/client/requests/MemoryGetRequest.d.ts +0 -5
  158. package/dist/api/resources/memory/client/requests/MemoryGetSessionFactsRequest.d.ts +1 -1
  159. package/dist/api/resources/memory/client/requests/ModelsMessageMetadataUpdate.d.ts +3 -1
  160. package/dist/api/resources/memory/client/requests/SessionSearchQuery.d.ts +12 -3
  161. package/dist/api/resources/memory/client/requests/UpdateSessionRequest.d.ts +3 -1
  162. package/dist/api/resources/user/client/Client.d.ts +13 -0
  163. package/dist/api/resources/user/client/Client.js +79 -6
  164. package/{api/types/DocumentResponse.d.ts → dist/api/types/ApidataDocument.d.ts} +1 -1
  165. package/dist/api/types/ApidataDocument.js +5 -0
  166. package/dist/api/types/{DocumentCollectionResponse.d.ts → ApidataDocumentCollection.d.ts} +1 -3
  167. package/dist/api/types/ApidataDocumentCollection.js +5 -0
  168. package/dist/api/types/{DocumentSearchResultPage.d.ts → ApidataDocumentSearchResponse.d.ts} +2 -2
  169. package/dist/api/types/ApidataDocumentSearchResponse.js +5 -0
  170. package/dist/api/types/{DocumentSearchResult.d.ts → ApidataDocumentWithScore.d.ts} +1 -1
  171. package/dist/api/types/ApidataDocumentWithScore.js +5 -0
  172. package/dist/api/types/EndSessionResponse.d.ts +1 -1
  173. package/dist/api/types/EntityEdge.d.ts +25 -0
  174. package/dist/api/types/EntityEdge.js +5 -0
  175. package/dist/api/types/EntityNode.d.ts +15 -0
  176. package/dist/api/types/EntityNode.js +5 -0
  177. package/dist/api/types/Episode.d.ts +12 -0
  178. package/dist/api/types/Episode.js +5 -0
  179. package/dist/api/types/EpisodeResponse.d.ts +7 -0
  180. package/dist/api/types/EpisodeResponse.js +5 -0
  181. package/dist/api/types/Fact.d.ts +9 -3
  182. package/dist/api/types/GraphDataType.d.ts +9 -0
  183. package/dist/api/types/GraphDataType.js +11 -0
  184. package/dist/api/types/GraphSearchResults.d.ts +8 -0
  185. package/dist/api/types/GraphSearchResults.js +5 -0
  186. package/dist/api/types/GraphSearchScope.d.ts +8 -0
  187. package/dist/api/types/GraphSearchScope.js +10 -0
  188. package/dist/api/types/Group.d.ts +12 -0
  189. package/dist/api/types/Group.js +5 -0
  190. package/dist/api/types/Memory.d.ts +4 -5
  191. package/dist/api/types/Message.d.ts +2 -2
  192. package/dist/api/types/{AddedFact.d.ts → NewFact.d.ts} +1 -1
  193. package/dist/api/types/NewFact.js +5 -0
  194. package/dist/api/types/Reranker.d.ts +10 -0
  195. package/dist/api/types/Reranker.js +12 -0
  196. package/dist/api/types/Session.d.ts +1 -2
  197. package/dist/api/types/{ClassifySessionResponse.d.ts → SessionClassification.d.ts} +2 -2
  198. package/dist/api/types/SessionClassification.js +5 -0
  199. package/dist/api/types/SessionFactRatingExamples.d.ts +8 -0
  200. package/dist/api/types/SessionFactRatingExamples.js +5 -0
  201. package/dist/api/types/SessionFactRatingInstruction.d.ts +21 -0
  202. package/dist/api/types/SessionFactRatingInstruction.js +5 -0
  203. package/dist/api/types/index.d.ts +24 -14
  204. package/dist/api/types/index.js +24 -14
  205. package/dist/serialization/resources/document/client/addDocuments.d.ts +2 -2
  206. package/dist/serialization/resources/document/client/addDocuments.js +1 -1
  207. package/dist/serialization/resources/document/client/batchGetDocuments.d.ts +3 -3
  208. package/dist/serialization/resources/document/client/batchGetDocuments.js +2 -2
  209. package/dist/serialization/resources/document/client/listCollections.d.ts +3 -3
  210. package/dist/serialization/resources/document/client/listCollections.js +2 -2
  211. package/dist/serialization/resources/graph/client/index.d.ts +1 -0
  212. package/dist/serialization/resources/graph/client/index.js +17 -0
  213. package/dist/serialization/resources/graph/client/requests/AddDataRequest.d.ts +16 -0
  214. package/dist/serialization/resources/graph/client/requests/AddDataRequest.js +37 -0
  215. package/dist/serialization/resources/graph/client/requests/GraphSearchQuery.d.ts +22 -0
  216. package/dist/serialization/resources/graph/client/requests/GraphSearchQuery.js +43 -0
  217. package/dist/serialization/resources/graph/client/requests/index.d.ts +2 -0
  218. package/dist/serialization/resources/graph/client/requests/index.js +7 -0
  219. package/dist/serialization/resources/graph/index.d.ts +2 -0
  220. package/dist/serialization/resources/graph/index.js +18 -0
  221. package/dist/serialization/resources/graph/resources/edge/client/getByGroupId.d.ts +11 -0
  222. package/dist/serialization/resources/graph/resources/edge/client/getByGroupId.js +32 -0
  223. package/dist/serialization/resources/graph/resources/edge/client/getByUserId.d.ts +11 -0
  224. package/dist/serialization/resources/graph/resources/edge/client/getByUserId.js +32 -0
  225. package/dist/serialization/resources/graph/resources/edge/client/index.d.ts +2 -0
  226. package/dist/serialization/resources/graph/resources/edge/client/index.js +28 -0
  227. package/dist/serialization/resources/graph/resources/edge/index.d.ts +1 -0
  228. package/dist/serialization/resources/graph/resources/edge/index.js +17 -0
  229. package/dist/serialization/resources/graph/resources/index.d.ts +2 -0
  230. package/dist/serialization/resources/graph/resources/index.js +28 -0
  231. package/dist/serialization/resources/graph/resources/node/client/getByGroupId.d.ts +11 -0
  232. package/dist/serialization/resources/graph/resources/node/client/getByGroupId.js +32 -0
  233. package/dist/serialization/resources/graph/resources/node/client/getByUserId.d.ts +11 -0
  234. package/dist/serialization/resources/graph/resources/node/client/getByUserId.js +32 -0
  235. package/dist/serialization/resources/graph/resources/node/client/index.d.ts +2 -0
  236. package/dist/serialization/resources/graph/resources/node/client/index.js +28 -0
  237. package/dist/serialization/resources/graph/resources/node/index.d.ts +1 -0
  238. package/dist/serialization/resources/graph/resources/node/index.js +17 -0
  239. package/dist/serialization/resources/group/client/index.d.ts +1 -0
  240. package/dist/serialization/resources/group/client/index.js +17 -0
  241. package/dist/serialization/resources/group/client/requests/CreateGroupRequest.d.ts +14 -0
  242. package/dist/serialization/resources/group/client/requests/CreateGroupRequest.js +35 -0
  243. package/dist/serialization/resources/group/client/requests/index.d.ts +1 -0
  244. package/dist/serialization/resources/group/client/requests/index.js +5 -0
  245. package/dist/serialization/resources/group/index.d.ts +1 -0
  246. package/dist/serialization/resources/group/index.js +17 -0
  247. package/dist/serialization/resources/index.d.ts +4 -0
  248. package/dist/serialization/resources/index.js +5 -1
  249. package/dist/serialization/resources/memory/client/requests/AddFactsRequest.d.ts +2 -2
  250. package/dist/serialization/resources/memory/client/requests/AddFactsRequest.js +2 -2
  251. package/dist/serialization/resources/memory/client/requests/CreateSessionRequest.d.ts +1 -1
  252. package/dist/serialization/resources/memory/client/requests/CreateSessionRequest.js +1 -1
  253. package/dist/serialization/resources/memory/client/requests/SessionSearchQuery.d.ts +1 -1
  254. package/dist/serialization/resources/memory/client/requests/SessionSearchQuery.js +1 -1
  255. package/{serialization/types/DocumentResponse.d.ts → dist/serialization/types/ApidataDocument.d.ts} +2 -2
  256. package/{serialization/types/DocumentResponse.js → dist/serialization/types/ApidataDocument.js} +2 -2
  257. package/dist/serialization/types/{DocumentCollectionResponse.d.ts → ApidataDocumentCollection.d.ts} +2 -2
  258. package/{serialization/types/DocumentCollectionResponse.js → dist/serialization/types/ApidataDocumentCollection.js} +2 -2
  259. package/dist/serialization/types/{DocumentSearchResultPage.d.ts → ApidataDocumentSearchResponse.d.ts} +4 -4
  260. package/dist/serialization/types/{DocumentSearchResultPage.js → ApidataDocumentSearchResponse.js} +4 -4
  261. package/dist/serialization/types/{DocumentSearchResult.d.ts → ApidataDocumentWithScore.d.ts} +2 -2
  262. package/dist/serialization/types/{DocumentSearchResult.js → ApidataDocumentWithScore.js} +2 -2
  263. package/dist/serialization/types/EndSessionResponse.d.ts +2 -2
  264. package/dist/serialization/types/EndSessionResponse.js +2 -2
  265. package/dist/serialization/types/EntityEdge.d.ts +21 -0
  266. package/dist/serialization/types/EntityEdge.js +42 -0
  267. package/dist/serialization/types/EntityNode.d.ts +16 -0
  268. package/dist/serialization/types/EntityNode.js +37 -0
  269. package/dist/serialization/types/Episode.d.ts +18 -0
  270. package/dist/serialization/types/Episode.js +39 -0
  271. package/dist/serialization/types/EpisodeResponse.d.ts +13 -0
  272. package/dist/serialization/types/EpisodeResponse.js +34 -0
  273. package/dist/serialization/types/Fact.d.ts +9 -3
  274. package/dist/serialization/types/Fact.js +9 -3
  275. package/dist/serialization/types/GraphDataType.d.ts +10 -0
  276. package/dist/serialization/types/{MemoryType.js → GraphDataType.js} +2 -2
  277. package/dist/serialization/types/GraphSearchResults.d.ts +15 -0
  278. package/dist/serialization/types/GraphSearchResults.js +36 -0
  279. package/dist/serialization/types/GraphSearchScope.d.ts +10 -0
  280. package/{serialization/types/MemoryType.js → dist/serialization/types/GraphSearchScope.js} +2 -2
  281. package/dist/serialization/types/Group.d.ts +18 -0
  282. package/dist/serialization/types/Group.js +39 -0
  283. package/dist/serialization/types/Memory.d.ts +0 -1
  284. package/dist/serialization/types/Memory.js +0 -1
  285. package/dist/serialization/types/Message.d.ts +2 -2
  286. package/dist/serialization/types/Message.js +2 -2
  287. package/dist/serialization/types/{AddedFact.d.ts → NewFact.d.ts} +2 -2
  288. package/{serialization/types/AddedFact.js → dist/serialization/types/NewFact.js} +2 -2
  289. package/dist/serialization/types/Reranker.d.ts +10 -0
  290. package/dist/serialization/types/Reranker.js +36 -0
  291. package/dist/serialization/types/Session.d.ts +2 -3
  292. package/dist/serialization/types/Session.js +2 -3
  293. package/dist/serialization/types/{ClassifySessionResponse.d.ts → SessionClassification.d.ts} +3 -3
  294. package/{serialization/types/ClassifySessionResponse.js → dist/serialization/types/SessionClassification.js} +3 -3
  295. package/dist/serialization/types/SessionFactRatingExamples.d.ts +14 -0
  296. package/dist/serialization/types/SessionFactRatingExamples.js +35 -0
  297. package/dist/serialization/types/SessionFactRatingInstruction.d.ts +14 -0
  298. package/dist/serialization/types/SessionFactRatingInstruction.js +35 -0
  299. package/dist/serialization/types/index.d.ts +24 -14
  300. package/dist/serialization/types/index.js +24 -14
  301. package/examples/graph/conversations.ts +297 -0
  302. package/examples/graph/group_graph_example.ts +61 -0
  303. package/examples/graph/user_graph_example.ts +158 -0
  304. package/package.json +5 -5
  305. package/serialization/resources/document/client/addDocuments.d.ts +2 -2
  306. package/serialization/resources/document/client/addDocuments.js +1 -1
  307. package/serialization/resources/document/client/batchGetDocuments.d.ts +3 -3
  308. package/serialization/resources/document/client/batchGetDocuments.js +2 -2
  309. package/serialization/resources/document/client/listCollections.d.ts +3 -3
  310. package/serialization/resources/document/client/listCollections.js +2 -2
  311. package/serialization/resources/graph/client/index.d.ts +1 -0
  312. package/serialization/resources/graph/client/index.js +17 -0
  313. package/serialization/resources/graph/client/requests/AddDataRequest.d.ts +16 -0
  314. package/serialization/resources/graph/client/requests/AddDataRequest.js +37 -0
  315. package/serialization/resources/graph/client/requests/GraphSearchQuery.d.ts +22 -0
  316. package/serialization/resources/graph/client/requests/GraphSearchQuery.js +43 -0
  317. package/serialization/resources/graph/client/requests/index.d.ts +2 -0
  318. package/serialization/resources/graph/client/requests/index.js +7 -0
  319. package/serialization/resources/graph/index.d.ts +2 -0
  320. package/serialization/resources/graph/index.js +18 -0
  321. package/serialization/resources/graph/resources/edge/client/getByGroupId.d.ts +11 -0
  322. package/serialization/resources/graph/resources/edge/client/getByGroupId.js +32 -0
  323. package/serialization/resources/graph/resources/edge/client/getByUserId.d.ts +11 -0
  324. package/serialization/resources/graph/resources/edge/client/getByUserId.js +32 -0
  325. package/serialization/resources/graph/resources/edge/client/index.d.ts +2 -0
  326. package/serialization/resources/graph/resources/edge/client/index.js +28 -0
  327. package/serialization/resources/graph/resources/edge/index.d.ts +1 -0
  328. package/serialization/resources/graph/resources/edge/index.js +17 -0
  329. package/serialization/resources/graph/resources/index.d.ts +2 -0
  330. package/serialization/resources/graph/resources/index.js +28 -0
  331. package/serialization/resources/graph/resources/node/client/getByGroupId.d.ts +11 -0
  332. package/serialization/resources/graph/resources/node/client/getByGroupId.js +32 -0
  333. package/serialization/resources/graph/resources/node/client/getByUserId.d.ts +11 -0
  334. package/serialization/resources/graph/resources/node/client/getByUserId.js +32 -0
  335. package/serialization/resources/graph/resources/node/client/index.d.ts +2 -0
  336. package/serialization/resources/graph/resources/node/client/index.js +28 -0
  337. package/serialization/resources/graph/resources/node/index.d.ts +1 -0
  338. package/serialization/resources/graph/resources/node/index.js +17 -0
  339. package/serialization/resources/group/client/index.d.ts +1 -0
  340. package/serialization/resources/group/client/index.js +17 -0
  341. package/serialization/resources/group/client/requests/CreateGroupRequest.d.ts +14 -0
  342. package/serialization/resources/group/client/requests/CreateGroupRequest.js +35 -0
  343. package/serialization/resources/group/client/requests/index.d.ts +1 -0
  344. package/serialization/resources/group/client/requests/index.js +5 -0
  345. package/serialization/resources/group/index.d.ts +1 -0
  346. package/serialization/resources/group/index.js +17 -0
  347. package/serialization/resources/index.d.ts +4 -0
  348. package/serialization/resources/index.js +5 -1
  349. package/serialization/resources/memory/client/requests/AddFactsRequest.d.ts +2 -2
  350. package/serialization/resources/memory/client/requests/AddFactsRequest.js +2 -2
  351. package/serialization/resources/memory/client/requests/CreateSessionRequest.d.ts +1 -1
  352. package/serialization/resources/memory/client/requests/CreateSessionRequest.js +1 -1
  353. package/serialization/resources/memory/client/requests/SessionSearchQuery.d.ts +1 -1
  354. package/serialization/resources/memory/client/requests/SessionSearchQuery.js +1 -1
  355. package/{dist/serialization/types/DocumentResponse.d.ts → serialization/types/ApidataDocument.d.ts} +2 -2
  356. package/{dist/serialization/types/DocumentResponse.js → serialization/types/ApidataDocument.js} +2 -2
  357. package/serialization/types/{DocumentCollectionResponse.d.ts → ApidataDocumentCollection.d.ts} +2 -2
  358. package/{dist/serialization/types/DocumentCollectionResponse.js → serialization/types/ApidataDocumentCollection.js} +2 -2
  359. package/serialization/types/{DocumentSearchResultPage.d.ts → ApidataDocumentSearchResponse.d.ts} +4 -4
  360. package/serialization/types/{DocumentSearchResultPage.js → ApidataDocumentSearchResponse.js} +4 -4
  361. package/serialization/types/{DocumentSearchResult.d.ts → ApidataDocumentWithScore.d.ts} +2 -2
  362. package/serialization/types/{DocumentSearchResult.js → ApidataDocumentWithScore.js} +2 -2
  363. package/serialization/types/EndSessionResponse.d.ts +2 -2
  364. package/serialization/types/EndSessionResponse.js +2 -2
  365. package/serialization/types/EntityEdge.d.ts +21 -0
  366. package/serialization/types/EntityEdge.js +42 -0
  367. package/serialization/types/EntityNode.d.ts +16 -0
  368. package/serialization/types/EntityNode.js +37 -0
  369. package/serialization/types/Episode.d.ts +18 -0
  370. package/serialization/types/Episode.js +39 -0
  371. package/serialization/types/EpisodeResponse.d.ts +13 -0
  372. package/serialization/types/EpisodeResponse.js +34 -0
  373. package/serialization/types/Fact.d.ts +9 -3
  374. package/serialization/types/Fact.js +9 -3
  375. package/serialization/types/GraphDataType.d.ts +10 -0
  376. package/serialization/types/GraphDataType.js +31 -0
  377. package/serialization/types/GraphSearchResults.d.ts +15 -0
  378. package/serialization/types/GraphSearchResults.js +36 -0
  379. package/serialization/types/GraphSearchScope.d.ts +10 -0
  380. package/serialization/types/GraphSearchScope.js +31 -0
  381. package/serialization/types/Group.d.ts +18 -0
  382. package/serialization/types/Group.js +39 -0
  383. package/serialization/types/Memory.d.ts +0 -1
  384. package/serialization/types/Memory.js +0 -1
  385. package/serialization/types/Message.d.ts +2 -2
  386. package/serialization/types/Message.js +2 -2
  387. package/serialization/types/{AddedFact.d.ts → NewFact.d.ts} +2 -2
  388. package/{dist/serialization/types/AddedFact.js → serialization/types/NewFact.js} +2 -2
  389. package/serialization/types/Reranker.d.ts +10 -0
  390. package/serialization/types/Reranker.js +36 -0
  391. package/serialization/types/Session.d.ts +2 -3
  392. package/serialization/types/Session.js +2 -3
  393. package/serialization/types/{ClassifySessionResponse.d.ts → SessionClassification.d.ts} +3 -3
  394. package/{dist/serialization/types/ClassifySessionResponse.js → serialization/types/SessionClassification.js} +3 -3
  395. package/serialization/types/SessionFactRatingExamples.d.ts +14 -0
  396. package/serialization/types/SessionFactRatingExamples.js +35 -0
  397. package/serialization/types/SessionFactRatingInstruction.d.ts +14 -0
  398. package/serialization/types/SessionFactRatingInstruction.js +35 -0
  399. package/serialization/types/index.d.ts +24 -14
  400. package/serialization/types/index.js +24 -14
  401. package/api/types/MemoryType.d.ts +0 -9
  402. package/api/types/MemoryType.js +0 -11
  403. package/dist/api/types/MemoryType.d.ts +0 -9
  404. package/dist/api/types/MemoryType.js +0 -11
  405. package/dist/langchain/index.d.ts +0 -3
  406. package/dist/langchain/message_history.d.ts +0 -39
  407. package/dist/langchain/message_history.js +0 -109
  408. package/dist/langchain/utils.d.ts +0 -4
  409. package/dist/langchain/utils.js +0 -43
  410. package/dist/langchain/vector_store.d.ts +0 -142
  411. package/dist/langchain/vector_store.js +0 -327
  412. package/dist/langchain/zep_memory.d.ts +0 -78
  413. package/dist/langchain/zep_memory.js +0 -174
  414. package/dist/serialization/types/MemoryType.d.ts +0 -10
  415. package/examples/langchain/message_history_example.ts +0 -60
  416. package/examples/langchain/message_history_vector_store_example.ts +0 -122
  417. package/examples/langchain/vector_store_example.ts +0 -71
  418. package/langchain/index.d.ts +0 -3
  419. package/langchain/message_history.d.ts +0 -39
  420. package/langchain/message_history.js +0 -109
  421. package/langchain/utils.d.ts +0 -4
  422. package/langchain/utils.js +0 -43
  423. package/langchain/vector_store.d.ts +0 -142
  424. package/langchain/vector_store.js +0 -327
  425. package/langchain/zep_memory.d.ts +0 -78
  426. package/langchain/zep_memory.js +0 -174
  427. package/serialization/types/MemoryType.d.ts +0 -10
  428. /package/api/{types/AddedFact.js → resources/graph/client/requests/AddDataRequest.js} +0 -0
  429. /package/api/{types/ClassifySessionResponse.js → resources/graph/client/requests/GraphSearchQuery.js} +0 -0
  430. /package/api/{types/DocumentCollectionResponse.js → resources/graph/resources/episode/client/requests/EpisodeGetByGroupIdRequest.js} +0 -0
  431. /package/api/{types/DocumentResponse.js → resources/graph/resources/episode/client/requests/EpisodeGetByUserIdRequest.js} +0 -0
  432. /package/api/{types/DocumentSearchResult.js → resources/group/client/requests/CreateGroupRequest.js} +0 -0
  433. /package/api/types/{DocumentSearchResultPage.js → ApidataDocument.js} +0 -0
  434. /package/{dist/api/types/AddedFact.js → api/types/ApidataDocumentCollection.js} +0 -0
  435. /package/{dist/api/types/ClassifySessionResponse.js → api/types/ApidataDocumentSearchResponse.js} +0 -0
  436. /package/{dist/api/types/DocumentCollectionResponse.js → api/types/ApidataDocumentWithScore.js} +0 -0
  437. /package/{dist/api/types/DocumentResponse.js → api/types/EntityEdge.js} +0 -0
  438. /package/{dist/api/types/DocumentSearchResult.js → api/types/EntityNode.js} +0 -0
  439. /package/{dist/api/types/DocumentSearchResultPage.js → api/types/Episode.js} +0 -0
@@ -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
- }
@@ -1,174 +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
- Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.ZepMemory = void 0;
14
- const memory_1 = require("@langchain/core/memory");
15
- const memory_2 = require("langchain/memory");
16
- const __1 = require("../");
17
- const api_1 = require("../api");
18
- const utils_1 = require("./utils");
19
- /**
20
- * Class used to manage the memory of a chat session, including loading
21
- * and saving the chat history, and clearing the memory when needed. It
22
- * uses the ZepClient to interact with the Zep service for managing the
23
- * chat session's memory.
24
- * @example
25
- * ```typescript
26
- * const sessionId = randomUUID();
27
- *
28
- * // Initialize ZepMemory with session ID, base URL, and API key
29
- * const memory = new ZepMemory({
30
- * sessionId,
31
- * apiKey: "change_this_key",
32
- * });
33
- *
34
- * // Create a ChatOpenAI model instance with specific parameters
35
- * const model = new ChatOpenAI({
36
- * modelName: "gpt-3.5-turbo",
37
- * temperature: 0,
38
- * });
39
- *
40
- * // Create a ConversationChain with the model and memory
41
- * const chain = new ConversationChain({ llm: model, memory });
42
- *
43
- * // Example of calling the chain with an input
44
- * const res1 = await chain.call({ input: "Hi! I'm Jim." });
45
- * console.log({ res1 });
46
- *
47
- * // Follow-up call to the chain to demonstrate memory usage
48
- * const res2 = await chain.call({ input: "What did I just say my name was?" });
49
- * console.log({ res2 });
50
- *
51
- * // Output the session ID and the current state of memory
52
- * console.log("Session ID: ", sessionId);
53
- * console.log("Memory: ", await memory.loadMemoryVariables({}));
54
- *
55
- * ```
56
- */
57
- class ZepMemory extends memory_2.BaseChatMemory {
58
- constructor(fields) {
59
- var _a, _b, _c, _d;
60
- super({
61
- returnMessages: (_a = fields === null || fields === void 0 ? void 0 : fields.returnMessages) !== null && _a !== void 0 ? _a : false,
62
- inputKey: fields === null || fields === void 0 ? void 0 : fields.inputKey,
63
- outputKey: fields === null || fields === void 0 ? void 0 : fields.outputKey,
64
- });
65
- this.humanPrefix = "Human";
66
- this.aiPrefix = "AI";
67
- this.memoryKey = "history";
68
- this.humanPrefix = (_b = fields.humanPrefix) !== null && _b !== void 0 ? _b : this.humanPrefix;
69
- this.aiPrefix = (_c = fields.aiPrefix) !== null && _c !== void 0 ? _c : this.aiPrefix;
70
- this.memoryKey = (_d = fields.memoryKey) !== null && _d !== void 0 ? _d : this.memoryKey;
71
- this.apiKey = fields.apiKey;
72
- this.sessionId = fields.sessionId;
73
- this.zepClient = new __1.ZepClient({
74
- environment: fields.baseURL,
75
- apiKey: this.apiKey,
76
- });
77
- }
78
- get memoryKeys() {
79
- return [this.memoryKey];
80
- }
81
- /**
82
- * Method that retrieves the chat history from the Zep service and formats
83
- * it into a list of messages.
84
- * @param values Input values for the method.
85
- * @returns Promise that resolves with the chat history formatted into a list of messages.
86
- */
87
- loadMemoryVariables(values) {
88
- var _a;
89
- return __awaiter(this, void 0, void 0, function* () {
90
- // use either lastN provided by developer or undefined to use the
91
- // server preset.
92
- const memoryType = (_a = values.memoryType) !== null && _a !== void 0 ? _a : "perpetual";
93
- let memory = null;
94
- try {
95
- memory = yield this.zepClient.memory.get(this.sessionId, {
96
- memoryType: memoryType,
97
- });
98
- }
99
- catch (error) {
100
- if (error instanceof api_1.NotFoundError) {
101
- return this.returnMessages ? { [this.memoryKey]: [] } : { [this.memoryKey]: "" };
102
- }
103
- throw error;
104
- }
105
- if (this.returnMessages) {
106
- return {
107
- [this.memoryKey]: [(0, utils_1.condenseZepMemoryIntoHumanMessage)(memory)],
108
- };
109
- }
110
- return {
111
- [this.memoryKey]: (0, utils_1.condenseZepMemoryIntoHumanMessage)(memory).content,
112
- };
113
- });
114
- }
115
- /**
116
- * Method that saves the input and output messages to the Zep service.
117
- * @param inputValues Input messages to be saved.
118
- * @param outputValues Output messages to be saved.
119
- * @returns Promise that resolves when the messages have been saved.
120
- */
121
- saveContext(inputValues, outputValues) {
122
- const _super = Object.create(null, {
123
- saveContext: { get: () => super.saveContext }
124
- });
125
- return __awaiter(this, void 0, void 0, function* () {
126
- const input = (0, memory_1.getInputValue)(inputValues, this.inputKey);
127
- const output = (0, memory_1.getOutputValue)(outputValues, this.outputKey);
128
- // Add the new memory to the session using the ZepClient
129
- if (this.sessionId) {
130
- try {
131
- yield this.zepClient.memory.add(this.sessionId, {
132
- messages: [
133
- {
134
- role: this.humanPrefix,
135
- roleType: "user",
136
- content: `${input}`,
137
- },
138
- {
139
- role: this.aiPrefix,
140
- roleType: "assistant",
141
- content: `${output}`,
142
- },
143
- ],
144
- });
145
- }
146
- catch (error) {
147
- console.error("Error adding memory: ", error);
148
- }
149
- }
150
- // Call the superclass's saveContext method
151
- yield _super.saveContext.call(this, inputValues, outputValues);
152
- });
153
- }
154
- /**
155
- * Method that deletes the chat history from the Zep service.
156
- * @returns Promise that resolves when the chat history has been deleted.
157
- */
158
- clear() {
159
- const _super = Object.create(null, {
160
- clear: { get: () => super.clear }
161
- });
162
- return __awaiter(this, void 0, void 0, function* () {
163
- try {
164
- yield this.zepClient.memory.delete(this.sessionId);
165
- }
166
- catch (error) {
167
- console.error("Error deleting session: ", error);
168
- }
169
- // Clear the superclass's chat history
170
- yield _super.clear.call(this);
171
- });
172
- }
173
- }
174
- exports.ZepMemory = ZepMemory;
@@ -1,10 +0,0 @@
1
- /**
2
- * This file was auto-generated by Fern from our API Definition.
3
- */
4
- import * as serializers from "../index";
5
- import * as Zep from "../../api/index";
6
- import * as core from "../../core";
7
- export declare const MemoryType: core.serialization.Schema<serializers.MemoryType.Raw, Zep.MemoryType>;
8
- export declare namespace MemoryType {
9
- type Raw = "perpetual" | "summary_retriever" | "message_window";
10
- }
@@ -1,60 +0,0 @@
1
- import { ZepClient } from "../../src";
2
- import { ZepChatMessageHistory } from "../../src/langchain";
3
- import { ChatOpenAI } from "@langchain/openai";
4
- import { ChatPromptTemplate, MessagesPlaceholder } from "@langchain/core/prompts";
5
- import { RunnableWithMessageHistory } from "@langchain/core/runnables";
6
- import { ConsoleCallbackHandler } from "@langchain/core/tracers/console";
7
-
8
- async function main() {
9
- const sessionId = process.env.ZEP_SESSION_ID;
10
- if (!sessionId) {
11
- throw new Error("ZEP_SESSION_ID not set");
12
- }
13
- const zepClient = new ZepClient({
14
- apiKey: process.env.ZEP_API_KEY,
15
- });
16
-
17
- const prompt = ChatPromptTemplate.fromMessages([
18
- ["system", "Answer the user's question below. Be polite and helpful:"],
19
- new MessagesPlaceholder("history"),
20
- ["human", "{question}"],
21
- ]);
22
-
23
- const chain = prompt
24
- .pipe(
25
- new ChatOpenAI({
26
- temperature: 0.8,
27
- modelName: "gpt-3.5-turbo-1106",
28
- })
29
- )
30
- .withConfig({
31
- callbacks: [new ConsoleCallbackHandler()],
32
- });
33
-
34
- const chainWithHistory = new RunnableWithMessageHistory({
35
- runnable: chain,
36
- getMessageHistory: (sessionId) =>
37
- new ZepChatMessageHistory({
38
- client: zepClient,
39
- sessionId: sessionId,
40
- memoryType: "perpetual",
41
- }),
42
- inputMessagesKey: "question",
43
- historyMessagesKey: "history",
44
- });
45
-
46
- const result = await chainWithHistory.invoke(
47
- {
48
- question: "What did we talk about earlier?",
49
- },
50
- {
51
- configurable: {
52
- sessionId: sessionId,
53
- },
54
- }
55
- );
56
-
57
- console.log("result", result);
58
- }
59
-
60
- main();
@@ -1,122 +0,0 @@
1
- import { ZepClient } from "../../src";
2
- import { ChatOpenAI } from "@langchain/openai";
3
- import { BasePromptTemplate, ChatPromptTemplate, MessagesPlaceholder, PromptTemplate } from "@langchain/core/prompts";
4
- import { ZepChatMessageHistory, ZepVectorStore } from "../../src/langchain";
5
- import { Document } from "@langchain/core/documents";
6
- import {
7
- RunnableLambda,
8
- RunnableMap,
9
- RunnablePassthrough,
10
- RunnableWithMessageHistory,
11
- } from "@langchain/core/runnables";
12
- import { StringOutputParser } from "@langchain/core/output_parsers";
13
- import { ConsoleCallbackHandler } from "@langchain/core/tracers/console";
14
- import { formatDocument } from "langchain/schema/prompt_template";
15
-
16
- const DEFAULT_DOCUMENT_PROMPT = PromptTemplate.fromTemplate("{pageContent}");
17
- interface ChainInput {
18
- question: string;
19
- sessionId: string;
20
- }
21
- async function combineDocuments(
22
- docs: Document[],
23
- documentPrompt: BasePromptTemplate = DEFAULT_DOCUMENT_PROMPT,
24
- documentSeparator: string = "\n\n"
25
- ) {
26
- const docStrings: string[] = await Promise.all(
27
- docs.map((doc) => {
28
- return formatDocument(doc, documentPrompt);
29
- })
30
- );
31
- return docStrings.join(documentSeparator);
32
- }
33
- async function main() {
34
- const collectionName = process.env.ZEP_COLLECTION_NAME;
35
- if (!collectionName) {
36
- throw new Error("ZEP_COLLECTION_NAME is required");
37
- }
38
- const sessionId = process.env.ZEP_SESSION_ID;
39
- if (!sessionId) {
40
- throw new Error("ZEP_SESSION_ID is required");
41
- }
42
- const zepClient = new ZepClient({
43
- apiKey: process.env.ZEP_API_KEY,
44
- });
45
-
46
- const vectorStore = await ZepVectorStore.init({
47
- client: zepClient,
48
- collectionName: collectionName,
49
- });
50
-
51
- const prompt = ChatPromptTemplate.fromMessages([
52
- ["system", `Answer the question based only on the following context: {context}`],
53
- new MessagesPlaceholder("history"),
54
- ["human", "{question}"],
55
- ]);
56
-
57
- const model = new ChatOpenAI({
58
- temperature: 0.8,
59
- modelName: "gpt-3.5-turbo-1106",
60
- });
61
- const retriever = vectorStore.asRetriever();
62
- const searchQuery = new RunnableLambda({
63
- func: async (input: any) => {
64
- const { question } = await zepClient.memory.synthesizeQuestion(input.session_id);
65
- return question;
66
- },
67
- });
68
- const retrieverLambda = new RunnableLambda({
69
- func: async (question: string) => {
70
- const response = await retriever.invoke(question);
71
- return combineDocuments(response);
72
- },
73
- });
74
- const setupAndRetrieval = RunnableMap.from({
75
- context: searchQuery.pipe(retrieverLambda),
76
- question: (x: any) => x.question,
77
- history: (x: any) => x.history,
78
- });
79
- const outputParser = new StringOutputParser();
80
-
81
- const ragChain = setupAndRetrieval.pipe(prompt).pipe(model).pipe(outputParser);
82
-
83
- const invokeChain = (chainInput: ChainInput) => {
84
- const chainWithHistory = new RunnableWithMessageHistory({
85
- runnable: RunnablePassthrough.assign({
86
- session_id: () => chainInput.sessionId,
87
- }).pipe(ragChain),
88
- getMessageHistory: (sessionId) =>
89
- new ZepChatMessageHistory({
90
- client: zepClient,
91
- sessionId: sessionId,
92
- memoryType: "perpetual",
93
- }),
94
- inputMessagesKey: "question",
95
- historyMessagesKey: "history",
96
- });
97
-
98
- return chainWithHistory.invoke(
99
- { question: chainInput.question },
100
- {
101
- configurable: {
102
- sessionId: chainInput.sessionId,
103
- },
104
- }
105
- );
106
- };
107
-
108
- const chain = new RunnableLambda({
109
- func: invokeChain,
110
- }).withConfig({
111
- callbacks: [new ConsoleCallbackHandler()],
112
- });
113
-
114
- const result = await chain.invoke({
115
- question: "Project Gutenberg?",
116
- sessionId: sessionId,
117
- });
118
-
119
- console.log("result", result);
120
- }
121
-
122
- main();
@@ -1,71 +0,0 @@
1
- import { ZepClient } from "../../src";
2
- import { ChatOpenAI } from "@langchain/openai";
3
- import { BasePromptTemplate, ChatPromptTemplate, PromptTemplate } from "@langchain/core/prompts";
4
- import { ZepVectorStore } from "../../src/langchain";
5
- import { Document } from "@langchain/core/documents";
6
- import { RunnableMap, RunnableLambda, RunnablePassthrough } from "@langchain/core/runnables";
7
- import { StringOutputParser } from "@langchain/core/output_parsers";
8
- import { ConsoleCallbackHandler } from "@langchain/core/tracers/console";
9
- import { formatDocument } from "langchain/schema/prompt_template";
10
-
11
- const DEFAULT_DOCUMENT_PROMPT = PromptTemplate.fromTemplate("{pageContent}");
12
-
13
- async function combineDocuments(
14
- docs: Document[],
15
- documentPrompt: BasePromptTemplate = DEFAULT_DOCUMENT_PROMPT,
16
- documentSeparator: string = "\n\n"
17
- ) {
18
- const docStrings: string[] = await Promise.all(
19
- docs.map((doc) => {
20
- return formatDocument(doc, documentPrompt);
21
- })
22
- );
23
- return docStrings.join(documentSeparator);
24
- }
25
- async function main() {
26
- const collectionName = process.env.ZEP_COLLECTION_NAME;
27
- if (!collectionName) {
28
- throw new Error("ZEP_COLLECTION_NAME is required");
29
- }
30
- const zepClient = new ZepClient({
31
- apiKey: process.env.ZEP_API_KEY,
32
- });
33
-
34
- const vectorStore = await ZepVectorStore.init({
35
- client: zepClient,
36
- collectionName: collectionName,
37
- });
38
-
39
- const prompt = ChatPromptTemplate.fromMessages([
40
- ["system", `Answer the question based only on the following context: {context}`],
41
- ["human", "{question}"],
42
- ]);
43
-
44
- const model = new ChatOpenAI({
45
- temperature: 0.8,
46
- modelName: "gpt-3.5-turbo-1106",
47
- });
48
- const retriever = vectorStore.asRetriever();
49
-
50
- const setupAndRetrieval = RunnableMap.from({
51
- context: new RunnableLambda({
52
- func: (input: string) => retriever.invoke(input).then(combineDocuments),
53
- }),
54
- question: new RunnablePassthrough(),
55
- });
56
- const outputParser = new StringOutputParser();
57
-
58
- const chain = setupAndRetrieval
59
- .pipe(prompt)
60
- .pipe(model)
61
- .pipe(outputParser)
62
- .withConfig({
63
- callbacks: [new ConsoleCallbackHandler()],
64
- });
65
-
66
- const result = await chain.invoke("Project Gutenberg?");
67
-
68
- console.log("result", result);
69
- }
70
-
71
- main();
@@ -1,3 +0,0 @@
1
- export * from "./message_history";
2
- export * from "./vector_store";
3
- export * from "./zep_memory";
@@ -1,39 +0,0 @@
1
- import { BaseMessage } from "@langchain/core/messages";
2
- import { BaseChatMessageHistory } from "@langchain/core/chat_history";
3
- import { ZepClient } from "../";
4
- import { Zep } from "../";
5
- /**
6
- * Interface defining the structure of the input data for the ZepMemory
7
- * class. It includes properties like humanPrefix, aiPrefix, memoryKey,
8
- * baseURL, sessionId, and apiKey.
9
- */
10
- interface ZepMemoryInput {
11
- sessionId: string;
12
- client: ZepClient;
13
- memoryType: Zep.MemoryType;
14
- humanPrefix?: string;
15
- aiPrefix?: string;
16
- }
17
- /**
18
- * Class used to manage the memory of a chat session, including loading
19
- * and saving the chat history, and clearing the memory when needed. It
20
- * uses the ZepClient to interact with the Zep service for managing the
21
- * chat session's memory.
22
- *
23
- */
24
- export declare class ZepChatMessageHistory extends BaseChatMessageHistory implements ZepMemoryInput {
25
- lc_namespace: string[];
26
- sessionId: string;
27
- client: ZepClient;
28
- memoryType: Zep.MemoryType;
29
- humanPrefix: string;
30
- aiPrefix: string;
31
- constructor(fields: ZepMemoryInput);
32
- private getMemory;
33
- getMessages(): Promise<BaseMessage[]>;
34
- addAIChatMessage(message: string, metadata?: any): Promise<void>;
35
- addMessage(message: BaseMessage, metadata?: any): Promise<void>;
36
- addUserMessage(message: string, metadata?: any): Promise<void>;
37
- clear(): Promise<void>;
38
- }
39
- export {};
@@ -1,109 +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
- Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.ZepChatMessageHistory = void 0;
14
- const messages_1 = require("@langchain/core/messages");
15
- const chat_history_1 = require("@langchain/core/chat_history");
16
- const api_1 = require("../api");
17
- const utils_1 = require("./utils");
18
- /**
19
- * Class used to manage the memory of a chat session, including loading
20
- * and saving the chat history, and clearing the memory when needed. It
21
- * uses the ZepClient to interact with the Zep service for managing the
22
- * chat session's memory.
23
- *
24
- */
25
- class ZepChatMessageHistory extends chat_history_1.BaseChatMessageHistory {
26
- constructor(fields) {
27
- super();
28
- this.lc_namespace = [];
29
- this.humanPrefix = "human";
30
- this.aiPrefix = "ai";
31
- this.sessionId = fields.sessionId;
32
- this.memoryType = fields.memoryType;
33
- this.client = fields.client;
34
- if (fields.humanPrefix) {
35
- this.humanPrefix = fields.humanPrefix;
36
- }
37
- if (fields.aiPrefix) {
38
- this.aiPrefix = fields.aiPrefix;
39
- }
40
- }
41
- getMemory() {
42
- return __awaiter(this, void 0, void 0, function* () {
43
- try {
44
- return this.client.memory.get(this.sessionId, { memoryType: this.memoryType });
45
- }
46
- catch (error) {
47
- if (error instanceof api_1.NotFoundError) {
48
- console.warn(`Session ${this.sessionId} not found in Zep. Returning None`);
49
- }
50
- else {
51
- console.error("Error getting memory: ", error);
52
- }
53
- return null;
54
- }
55
- });
56
- }
57
- getMessages() {
58
- return __awaiter(this, void 0, void 0, function* () {
59
- const memory = yield this.getMemory();
60
- if (!memory) {
61
- return [];
62
- }
63
- return [(0, utils_1.condenseZepMemoryIntoHumanMessage)(memory)];
64
- });
65
- }
66
- addAIChatMessage(message, metadata) {
67
- return __awaiter(this, void 0, void 0, function* () {
68
- yield this.addMessage(new messages_1.AIMessage({ content: message }), metadata);
69
- });
70
- }
71
- addMessage(message, metadata) {
72
- var _a;
73
- return __awaiter(this, void 0, void 0, function* () {
74
- const messageToSave = message;
75
- if (message._getType() === "ai") {
76
- messageToSave.name = this.aiPrefix;
77
- }
78
- else if (message._getType() === "human") {
79
- messageToSave.name = this.humanPrefix;
80
- }
81
- if (message.content === null) {
82
- throw new Error("Message content cannot be null");
83
- }
84
- if (Array.isArray(message.content)) {
85
- throw new Error("Message content cannot be a list");
86
- }
87
- yield this.client.memory.add(this.sessionId, {
88
- messages: [
89
- {
90
- content: message.content,
91
- role: (_a = message.name) !== null && _a !== void 0 ? _a : message._getType(),
92
- roleType: (0, utils_1.getZepMessageRoleType)(message._getType()),
93
- metadata,
94
- },
95
- ],
96
- });
97
- });
98
- }
99
- addUserMessage(message, metadata) {
100
- return __awaiter(this, void 0, void 0, function* () {
101
- yield this.addMessage(new messages_1.HumanMessage({ content: message }, metadata));
102
- });
103
- }
104
- clear() {
105
- console.warn("Clearing memory", this.sessionId);
106
- return Promise.resolve(undefined);
107
- }
108
- }
109
- exports.ZepChatMessageHistory = ZepChatMessageHistory;
@@ -1,4 +0,0 @@
1
- import { HumanMessage, MessageType } from "@langchain/core/messages";
2
- import { Memory, RoleType } from "../api";
3
- export declare const getZepMessageRoleType: (role: MessageType) => RoleType;
4
- export declare const condenseZepMemoryIntoHumanMessage: (memory: Memory) => HumanMessage;