@langchain/classic 1.0.0-alpha.1 → 1.0.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 (178) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/LICENSE +6 -6
  3. package/README.md +174 -66
  4. package/dist/agents/initialize.d.ts +2 -2
  5. package/dist/agents/initialize.d.ts.map +1 -1
  6. package/dist/agents/mrkl/outputParser.d.cts +1 -1
  7. package/dist/agents/mrkl/outputParser.d.cts.map +1 -1
  8. package/dist/agents/openai_tools/index.d.cts.map +1 -1
  9. package/dist/agents/openai_tools/index.d.ts.map +1 -1
  10. package/dist/agents/react/index.d.ts +2 -2
  11. package/dist/agents/react/index.d.ts.map +1 -1
  12. package/dist/agents/structured_chat/index.d.ts +2 -2
  13. package/dist/agents/structured_chat/index.d.ts.map +1 -1
  14. package/dist/agents/tool_calling/index.d.cts.map +1 -1
  15. package/dist/agents/tool_calling/index.d.ts.map +1 -1
  16. package/dist/agents/toolkits/conversational_retrieval/token_buffer_memory.d.cts +2 -2
  17. package/dist/agents/toolkits/conversational_retrieval/token_buffer_memory.d.cts.map +1 -1
  18. package/dist/agents/toolkits/conversational_retrieval/tool.d.cts +8 -2
  19. package/dist/agents/toolkits/conversational_retrieval/tool.d.cts.map +1 -1
  20. package/dist/agents/toolkits/conversational_retrieval/tool.d.ts +8 -2
  21. package/dist/agents/toolkits/conversational_retrieval/tool.d.ts.map +1 -1
  22. package/dist/chains/index.cjs +3 -0
  23. package/dist/chains/index.cjs.map +1 -1
  24. package/dist/chains/index.d.cts +2 -1
  25. package/dist/chains/index.d.ts +2 -1
  26. package/dist/chains/index.js +3 -1
  27. package/dist/chains/index.js.map +1 -1
  28. package/dist/chains/openai_moderation.cjs +107 -0
  29. package/dist/chains/openai_moderation.cjs.map +1 -0
  30. package/dist/chains/openai_moderation.d.cts +74 -0
  31. package/dist/chains/openai_moderation.d.cts.map +1 -0
  32. package/dist/chains/openai_moderation.d.ts +74 -0
  33. package/dist/chains/openai_moderation.d.ts.map +1 -0
  34. package/dist/chains/openai_moderation.js +106 -0
  35. package/dist/chains/openai_moderation.js.map +1 -0
  36. package/dist/chains/question_answering/load.d.cts +2 -2
  37. package/dist/chains/question_answering/load.d.cts.map +1 -1
  38. package/dist/chains/question_answering/load.d.ts +2 -2
  39. package/dist/chains/question_answering/load.d.ts.map +1 -1
  40. package/dist/chains/summarization/load.d.cts +2 -2
  41. package/dist/chains/summarization/load.d.cts.map +1 -1
  42. package/dist/chains/summarization/load.d.ts +2 -2
  43. package/dist/chains/summarization/load.d.ts.map +1 -1
  44. package/dist/embeddings/cache_backed.d.cts +1 -1
  45. package/dist/embeddings/cache_backed.d.ts +1 -1
  46. package/dist/evaluation/agents/trajectory.d.cts.map +1 -1
  47. package/dist/evaluation/comparison/pairwise.d.cts.map +1 -1
  48. package/dist/evaluation/criteria/criteria.d.cts.map +1 -1
  49. package/dist/experimental/autogpt/prompt.d.cts +2 -2
  50. package/dist/experimental/autogpt/prompt.d.cts.map +1 -1
  51. package/dist/hub/base.cjs +1 -1
  52. package/dist/hub/base.js +1 -1
  53. package/dist/langchain-core/dist/messages/base.d.cts +2 -0
  54. package/dist/langchain-core/dist/messages/base.d.cts.map +1 -1
  55. package/dist/langchain-core/dist/messages/format.d.cts +8 -0
  56. package/dist/langchain-core/dist/messages/format.d.cts.map +1 -0
  57. package/dist/libs/langchain-core/dist/messages/base.d.ts +2 -0
  58. package/dist/libs/langchain-core/dist/messages/base.d.ts.map +1 -1
  59. package/dist/libs/langchain-core/dist/messages/format.d.ts +8 -0
  60. package/dist/libs/langchain-core/dist/messages/format.d.ts.map +1 -0
  61. package/dist/load/import_map.cjs +1 -1
  62. package/dist/load/import_map.js +1 -1
  63. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@4.1.11_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/client.cjs +74 -18
  64. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/client.cjs.map +1 -0
  65. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@4.1.11_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/client.js +75 -19
  66. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/client.js.map +1 -0
  67. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@4.1.11_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/env.cjs +1 -1
  68. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/env.cjs.map +1 -0
  69. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@4.1.11_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/env.js +1 -1
  70. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/env.js.map +1 -0
  71. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@4.1.11_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/experimental/otel/constants.cjs +1 -1
  72. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/experimental/otel/constants.cjs.map +1 -0
  73. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@4.1.11_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/experimental/otel/constants.js +1 -1
  74. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@4.1.11_/node_modules/langsmith/dist/experimental/otel/constants.cjs.map → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/experimental/otel/constants.js.map} +1 -1
  75. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@4.1.11_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/experimental/otel/translator.cjs +1 -1
  76. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/experimental/otel/translator.cjs.map +1 -0
  77. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@4.1.11_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/experimental/otel/translator.js +1 -1
  78. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/experimental/otel/translator.js.map +1 -0
  79. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@4.1.11_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/index.cjs +2 -2
  80. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/index.cjs.map +1 -0
  81. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@4.1.11_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/index.js +2 -2
  82. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/index.js.map +1 -0
  83. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@4.1.11_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/run_trees.cjs +7 -5
  84. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/run_trees.cjs.map +1 -0
  85. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@4.1.11_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/run_trees.js +7 -5
  86. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/run_trees.js.map +1 -0
  87. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@4.1.11_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/singletons/constants.cjs +1 -1
  88. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/singletons/constants.cjs.map +1 -0
  89. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@4.1.11_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/singletons/constants.js +1 -1
  90. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/singletons/constants.js.map +1 -0
  91. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@4.1.11_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/singletons/fetch.cjs +1 -1
  92. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/singletons/fetch.cjs.map +1 -0
  93. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@4.1.11_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/singletons/fetch.js +1 -1
  94. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/singletons/fetch.js.map +1 -0
  95. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@4.1.11_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/singletons/otel.cjs +1 -1
  96. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/singletons/otel.cjs.map +1 -0
  97. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@4.1.11_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/singletons/otel.js +1 -1
  98. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/singletons/otel.js.map +1 -0
  99. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@4.1.11_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/utils/_uuid.cjs +1 -1
  100. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/utils/_uuid.cjs.map +1 -0
  101. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@4.1.11_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/utils/_uuid.js +1 -1
  102. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@4.1.11_/node_modules/langsmith/dist/utils/_uuid.cjs.map → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/utils/_uuid.js.map} +1 -1
  103. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@4.1.11_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/utils/async_caller.cjs +1 -1
  104. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/utils/async_caller.cjs.map +1 -0
  105. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@4.1.11_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/utils/async_caller.js +1 -1
  106. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@4.1.11_/node_modules/langsmith/dist/utils/async_caller.cjs.map → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/utils/async_caller.js.map} +1 -1
  107. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@4.1.11_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/utils/env.cjs +19 -23
  108. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/utils/env.cjs.map +1 -0
  109. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@4.1.11_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/utils/env.js +19 -23
  110. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/utils/env.js.map +1 -0
  111. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@4.1.11_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/utils/error.cjs +16 -3
  112. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/utils/error.cjs.map +1 -0
  113. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@4.1.11_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/utils/error.js +16 -3
  114. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/utils/error.js.map +1 -0
  115. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@4.1.11_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/utils/fast-safe-stringify/index.cjs +1 -1
  116. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/utils/fast-safe-stringify/index.cjs.map +1 -0
  117. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@4.1.11_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/utils/fast-safe-stringify/index.js +1 -1
  118. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/utils/fast-safe-stringify/index.js.map +1 -0
  119. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@4.1.11_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/utils/messages.cjs +1 -1
  120. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/utils/messages.cjs.map +1 -0
  121. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@4.1.11_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/utils/messages.js +1 -1
  122. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@4.1.11_/node_modules/langsmith/dist/utils/messages.cjs.map → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/utils/messages.js.map} +1 -1
  123. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@4.1.11_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/utils/project.cjs +1 -1
  124. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/utils/project.cjs.map +1 -0
  125. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@4.1.11_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/utils/project.js +1 -1
  126. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/utils/project.js.map +1 -0
  127. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@4.1.11_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/utils/prompts.cjs +1 -1
  128. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/utils/prompts.cjs.map +1 -0
  129. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@4.1.11_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/utils/prompts.js +1 -1
  130. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@4.1.11_/node_modules/langsmith/dist/utils/prompts.cjs.map → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/utils/prompts.js.map} +1 -1
  131. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@4.1.11_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/utils/warn.cjs +1 -1
  132. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/utils/warn.cjs.map +1 -0
  133. package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@4.1.11_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/dist/utils/warn.js +1 -1
  134. package/dist/node_modules/.pnpm/langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_/node_modules/langsmith/dist/utils/warn.js.map +1 -0
  135. package/dist/output_parsers/structured.d.cts +7 -1
  136. package/dist/output_parsers/structured.d.cts.map +1 -1
  137. package/dist/output_parsers/structured.d.ts +7 -1
  138. package/dist/output_parsers/structured.d.ts.map +1 -1
  139. package/dist/smith/runner_utils.cjs +3 -3
  140. package/dist/smith/runner_utils.js +3 -3
  141. package/dist/tools/retriever.d.cts +12 -1
  142. package/dist/tools/retriever.d.cts.map +1 -1
  143. package/dist/tools/retriever.d.ts +12 -1
  144. package/dist/tools/retriever.d.ts.map +1 -1
  145. package/package.json +225 -225
  146. package/dist/node_modules/.pnpm/langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@4.1.11_/node_modules/langsmith/dist/client.cjs.map +0 -1
  147. package/dist/node_modules/.pnpm/langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@4.1.11_/node_modules/langsmith/dist/client.js.map +0 -1
  148. package/dist/node_modules/.pnpm/langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@4.1.11_/node_modules/langsmith/dist/env.cjs.map +0 -1
  149. package/dist/node_modules/.pnpm/langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@4.1.11_/node_modules/langsmith/dist/env.js.map +0 -1
  150. package/dist/node_modules/.pnpm/langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@4.1.11_/node_modules/langsmith/dist/experimental/otel/constants.js.map +0 -1
  151. package/dist/node_modules/.pnpm/langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@4.1.11_/node_modules/langsmith/dist/experimental/otel/translator.cjs.map +0 -1
  152. package/dist/node_modules/.pnpm/langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@4.1.11_/node_modules/langsmith/dist/experimental/otel/translator.js.map +0 -1
  153. package/dist/node_modules/.pnpm/langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@4.1.11_/node_modules/langsmith/dist/index.cjs.map +0 -1
  154. package/dist/node_modules/.pnpm/langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@4.1.11_/node_modules/langsmith/dist/index.js.map +0 -1
  155. package/dist/node_modules/.pnpm/langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@4.1.11_/node_modules/langsmith/dist/run_trees.cjs.map +0 -1
  156. package/dist/node_modules/.pnpm/langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@4.1.11_/node_modules/langsmith/dist/run_trees.js.map +0 -1
  157. package/dist/node_modules/.pnpm/langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@4.1.11_/node_modules/langsmith/dist/singletons/constants.cjs.map +0 -1
  158. package/dist/node_modules/.pnpm/langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@4.1.11_/node_modules/langsmith/dist/singletons/constants.js.map +0 -1
  159. package/dist/node_modules/.pnpm/langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@4.1.11_/node_modules/langsmith/dist/singletons/fetch.cjs.map +0 -1
  160. package/dist/node_modules/.pnpm/langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@4.1.11_/node_modules/langsmith/dist/singletons/fetch.js.map +0 -1
  161. package/dist/node_modules/.pnpm/langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@4.1.11_/node_modules/langsmith/dist/singletons/otel.cjs.map +0 -1
  162. package/dist/node_modules/.pnpm/langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@4.1.11_/node_modules/langsmith/dist/singletons/otel.js.map +0 -1
  163. package/dist/node_modules/.pnpm/langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@4.1.11_/node_modules/langsmith/dist/utils/_uuid.js.map +0 -1
  164. package/dist/node_modules/.pnpm/langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@4.1.11_/node_modules/langsmith/dist/utils/async_caller.js.map +0 -1
  165. package/dist/node_modules/.pnpm/langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@4.1.11_/node_modules/langsmith/dist/utils/env.cjs.map +0 -1
  166. package/dist/node_modules/.pnpm/langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@4.1.11_/node_modules/langsmith/dist/utils/env.js.map +0 -1
  167. package/dist/node_modules/.pnpm/langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@4.1.11_/node_modules/langsmith/dist/utils/error.cjs.map +0 -1
  168. package/dist/node_modules/.pnpm/langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@4.1.11_/node_modules/langsmith/dist/utils/error.js.map +0 -1
  169. package/dist/node_modules/.pnpm/langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@4.1.11_/node_modules/langsmith/dist/utils/fast-safe-stringify/index.cjs.map +0 -1
  170. package/dist/node_modules/.pnpm/langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@4.1.11_/node_modules/langsmith/dist/utils/fast-safe-stringify/index.js.map +0 -1
  171. package/dist/node_modules/.pnpm/langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@4.1.11_/node_modules/langsmith/dist/utils/messages.js.map +0 -1
  172. package/dist/node_modules/.pnpm/langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@4.1.11_/node_modules/langsmith/dist/utils/project.cjs.map +0 -1
  173. package/dist/node_modules/.pnpm/langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@4.1.11_/node_modules/langsmith/dist/utils/project.js.map +0 -1
  174. package/dist/node_modules/.pnpm/langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@4.1.11_/node_modules/langsmith/dist/utils/prompts.js.map +0 -1
  175. package/dist/node_modules/.pnpm/langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@4.1.11_/node_modules/langsmith/dist/utils/warn.cjs.map +0 -1
  176. package/dist/node_modules/.pnpm/langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@4.1.11_/node_modules/langsmith/dist/utils/warn.js.map +0 -1
  177. /package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@4.1.11_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/index.cjs +0 -0
  178. /package/dist/node_modules/.pnpm/{langsmith@0.3.64_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@4.1.11_ → langsmith@0.3.74_@opentelemetry_api@1.9.0_openai@5.12.2_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@6.0.5__zod@3.25.76_}/node_modules/langsmith/index.js +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":["ChatPromptTemplate","StructuredToolInterface","LanguageModelLike","ToolDefinition","AgentRunnableSequence","ToolsAgentStep","CreateToolCallingAgentParams","createToolCallingAgent","llm","tools","prompt","streamRunnable","___index_js1","AgentFinish","AgentAction"],"sources":["../../../src/agents/tool_calling/index.d.ts"],"sourcesContent":["import { ChatPromptTemplate } from \"@langchain/core/prompts\";\nimport { StructuredToolInterface } from \"@langchain/core/tools\";\nimport { LanguageModelLike, ToolDefinition } from \"@langchain/core/language_models/base\";\nimport { AgentRunnableSequence } from \"../agent.js\";\nimport { ToolsAgentStep } from \"./output_parser.js\";\n/**\n * Params used by the createOpenAIToolsAgent function.\n */\nexport type CreateToolCallingAgentParams = {\n /**\n * LLM to use as the agent. Should work with OpenAI tool calling,\n * so must either be an OpenAI model that supports that or a wrapper of\n * a different model that adds in equivalent support.\n */\n llm: LanguageModelLike;\n /** Tools this agent has access to. */\n tools: StructuredToolInterface[] | ToolDefinition[];\n /** The prompt to use, must have an input key of `agent_scratchpad`. */\n prompt: ChatPromptTemplate;\n /**\n * Whether to invoke the underlying model in streaming mode,\n * allowing streaming of intermediate steps. Defaults to true.\n */\n streamRunnable?: boolean;\n};\n/**\n * Create an agent that uses tools.\n * @param params Params required to create the agent. Includes an LLM, tools, and prompt.\n * @returns A runnable sequence representing an agent. It takes as input all the same input\n * variables as the prompt passed in does. It returns as output either an\n * AgentAction or AgentFinish.\n * @example\n * ```typescript\n * import { ChatAnthropic } from \"@langchain/anthropic\";\n * import { ChatPromptTemplate, MessagesPlaceholder } from \"@langchain/core/prompts\";\n * import { AgentExecutor, createToolCallingAgent } from \"langchain/agents\";\n *\n * const prompt = ChatPromptTemplate.fromMessages(\n * [\n * [\"system\", \"You are a helpful assistant\"],\n * [\"placeholder\", \"{chat_history}\"],\n * [\"human\", \"{input}\"],\n * [\"placeholder\", \"{agent_scratchpad}\"],\n * ]\n * );\n *\n *\n * const llm = new ChatAnthropic({\n * modelName: \"claude-3-opus-20240229\",\n * temperature: 0,\n * });\n *\n * // Define the tools the agent will have access to.\n * const tools = [...];\n *\n * const agent = createToolCallingAgent({ llm, tools, prompt });\n *\n * const agentExecutor = new AgentExecutor({ agent, tools });\n *\n * const result = await agentExecutor.invoke({input: \"what is LangChain?\"});\n *\n * // Using with chat history\n * import { AIMessage, HumanMessage } from \"@langchain/core/messages\";\n *\n * const result2 = await agentExecutor.invoke(\n * {\n * input: \"what's my name?\",\n * chat_history: [\n * new HumanMessage({content: \"hi! my name is bob\"}),\n * new AIMessage({content: \"Hello Bob! How can I assist you today?\"}),\n * ],\n * }\n * );\n * ```\n */\nexport declare function createToolCallingAgent({ llm, tools, prompt, streamRunnable }: CreateToolCallingAgentParams): AgentRunnableSequence<{\n steps: ToolsAgentStep[];\n}, import(\"../index.js\").AgentFinish | import(\"../index.js\").AgentAction[]>;\n"],"mappings":";;;;;;;;;;;AAQYM,KAAAA,4BAAAA,GAA4B;EAAA;;;;;EAUV,GAAA,EAJrBJ,iBAIqB;EAyDNK;EAAsB,KAAA,EA3DnCN,uBA2DmC,EAAA,GA3DPE,cA2DO,EAAA;EAAA;EAAM,MAAEM,EAzD1CT,kBAyD0CS;EAAK;;;;EAClC,cAAA,CAAA,EAAA,OAAA;CACW;;AAFuG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAnHF,sBAAAA;;;;;GAA+DD,+BAA+BF;SAC3GC;GAAc,WAAA,GACW,WAAA"}
1
+ {"version":3,"file":"index.d.ts","names":["ChatPromptTemplate","StructuredToolInterface","LanguageModelLike","ToolDefinition","AgentRunnableSequence","ToolsAgentStep","CreateToolCallingAgentParams","createToolCallingAgent","llm","tools","prompt","streamRunnable","___index_js0","AgentFinish","AgentAction"],"sources":["../../../src/agents/tool_calling/index.d.ts"],"sourcesContent":["import { ChatPromptTemplate } from \"@langchain/core/prompts\";\nimport { StructuredToolInterface } from \"@langchain/core/tools\";\nimport { LanguageModelLike, ToolDefinition } from \"@langchain/core/language_models/base\";\nimport { AgentRunnableSequence } from \"../agent.js\";\nimport { ToolsAgentStep } from \"./output_parser.js\";\n/**\n * Params used by the createOpenAIToolsAgent function.\n */\nexport type CreateToolCallingAgentParams = {\n /**\n * LLM to use as the agent. Should work with OpenAI tool calling,\n * so must either be an OpenAI model that supports that or a wrapper of\n * a different model that adds in equivalent support.\n */\n llm: LanguageModelLike;\n /** Tools this agent has access to. */\n tools: StructuredToolInterface[] | ToolDefinition[];\n /** The prompt to use, must have an input key of `agent_scratchpad`. */\n prompt: ChatPromptTemplate;\n /**\n * Whether to invoke the underlying model in streaming mode,\n * allowing streaming of intermediate steps. Defaults to true.\n */\n streamRunnable?: boolean;\n};\n/**\n * Create an agent that uses tools.\n * @param params Params required to create the agent. Includes an LLM, tools, and prompt.\n * @returns A runnable sequence representing an agent. It takes as input all the same input\n * variables as the prompt passed in does. It returns as output either an\n * AgentAction or AgentFinish.\n * @example\n * ```typescript\n * import { ChatAnthropic } from \"@langchain/anthropic\";\n * import { ChatPromptTemplate, MessagesPlaceholder } from \"@langchain/core/prompts\";\n * import { AgentExecutor, createToolCallingAgent } from \"langchain/agents\";\n *\n * const prompt = ChatPromptTemplate.fromMessages(\n * [\n * [\"system\", \"You are a helpful assistant\"],\n * [\"placeholder\", \"{chat_history}\"],\n * [\"human\", \"{input}\"],\n * [\"placeholder\", \"{agent_scratchpad}\"],\n * ]\n * );\n *\n *\n * const llm = new ChatAnthropic({\n * modelName: \"claude-3-opus-20240229\",\n * temperature: 0,\n * });\n *\n * // Define the tools the agent will have access to.\n * const tools = [...];\n *\n * const agent = createToolCallingAgent({ llm, tools, prompt });\n *\n * const agentExecutor = new AgentExecutor({ agent, tools });\n *\n * const result = await agentExecutor.invoke({input: \"what is LangChain?\"});\n *\n * // Using with chat history\n * import { AIMessage, HumanMessage } from \"@langchain/core/messages\";\n *\n * const result2 = await agentExecutor.invoke(\n * {\n * input: \"what's my name?\",\n * chat_history: [\n * new HumanMessage({content: \"hi! my name is bob\"}),\n * new AIMessage({content: \"Hello Bob! How can I assist you today?\"}),\n * ],\n * }\n * );\n * ```\n */\nexport declare function createToolCallingAgent({ llm, tools, prompt, streamRunnable }: CreateToolCallingAgentParams): AgentRunnableSequence<{\n steps: ToolsAgentStep[];\n}, import(\"../index.js\").AgentFinish | import(\"../index.js\").AgentAction[]>;\n"],"mappings":";;;;;;;;;;;AAQYM,KAAAA,4BAAAA,GAA4B;EAAA;;;;;EAUV,GAAA,EAJrBJ,iBAIqB;EAyDNK;EAAsB,KAAA,EA3DnCN,uBA2DmC,EAAA,GA3DPE,cA2DO,EAAA;EAAA;EAAM,MAAEM,EAzD1CT,kBAyD0CS;EAAK;;;;EAClC,cAAA,CAAA,EAAA,OAAA;CACW;;AAFuG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAnHF,sBAAAA;;;;;GAA+DD,+BAA+BF;SAC3GC;GAAc,WAAA,GACW,WAAA"}
@@ -1,5 +1,5 @@
1
1
  import { BaseChatMemory, BaseChatMemoryInput } from "../../../memory/chat_memory.cjs";
2
- import * as _langchain_core_messages0 from "@langchain/core/messages";
2
+ import * as _langchain_core_messages1 from "@langchain/core/messages";
3
3
  import { InputValues, MemoryVariables, OutputValues } from "@langchain/core/memory";
4
4
  import { ChatOpenAI } from "@langchain/openai";
5
5
 
@@ -37,7 +37,7 @@ declare class OpenAIAgentTokenBufferMemory extends BaseChatMemory {
37
37
  * Retrieves the messages from the chat history.
38
38
  * @returns Promise that resolves with the messages from the chat history.
39
39
  */
40
- getMessages(): Promise<_langchain_core_messages0.BaseMessage<_langchain_core_messages0.MessageStructure, _langchain_core_messages0.MessageType>[]>;
40
+ getMessages(): Promise<_langchain_core_messages1.BaseMessage<_langchain_core_messages1.MessageStructure, _langchain_core_messages1.MessageType>[]>;
41
41
  /**
42
42
  * Loads memory variables from the input values.
43
43
  * @param _values Input values.
@@ -1 +1 @@
1
- {"version":3,"file":"token_buffer_memory.d.cts","names":["ChatOpenAI","InputValues","MemoryVariables","OutputValues","BaseChatMemory","BaseChatMemoryInput","OpenAIAgentTokenBufferMemoryFields","OpenAIAgentTokenBufferMemory","_langchain_core_messages0","MessageStructure","MessageType","BaseMessage","Promise"],"sources":["../../../../src/agents/toolkits/conversational_retrieval/token_buffer_memory.d.ts"],"sourcesContent":["import { ChatOpenAI } from \"@langchain/openai\";\nimport { InputValues, MemoryVariables, OutputValues } from \"@langchain/core/memory\";\nimport { BaseChatMemory, BaseChatMemoryInput } from \"../../../memory/chat_memory.js\";\n/**\n * Type definition for the fields required to initialize an instance of\n * OpenAIAgentTokenBufferMemory.\n */\nexport type OpenAIAgentTokenBufferMemoryFields = BaseChatMemoryInput & {\n llm: ChatOpenAI;\n humanPrefix?: string;\n aiPrefix?: string;\n memoryKey?: string;\n maxTokenLimit?: number;\n returnMessages?: boolean;\n outputKey?: string;\n intermediateStepsKey?: string;\n};\n/**\n * Memory used to save agent output and intermediate steps.\n */\nexport declare class OpenAIAgentTokenBufferMemory extends BaseChatMemory {\n humanPrefix: string;\n aiPrefix: string;\n llm: ChatOpenAI;\n memoryKey: string;\n maxTokenLimit: number;\n returnMessages: boolean;\n outputKey: string;\n intermediateStepsKey: string;\n constructor(fields: OpenAIAgentTokenBufferMemoryFields);\n get memoryKeys(): string[];\n /**\n * Retrieves the messages from the chat history.\n * @returns Promise that resolves with the messages from the chat history.\n */\n getMessages(): Promise<import(\"@langchain/core/messages\").BaseMessage<import(\"@langchain/core/messages\").MessageStructure, import(\"@langchain/core/messages\").MessageType>[]>;\n /**\n * Loads memory variables from the input values.\n * @param _values Input values.\n * @returns Promise that resolves with the loaded memory variables.\n */\n loadMemoryVariables(_values: InputValues): Promise<MemoryVariables>;\n /**\n * Saves the context of the chat, including user input, AI output, and\n * intermediate steps. Prunes the chat history if the total token count\n * exceeds the maximum limit.\n * @param inputValues Input values.\n * @param outputValues Output values.\n * @returns Promise that resolves when the context has been saved.\n */\n saveContext(inputValues: InputValues, outputValues: OutputValues): Promise<void>;\n}\n"],"mappings":";;;;;;;;;;AAOA;AAA8C,KAAlCM,kCAAAA,GAAqCD,mBAAH,GAAA;EAAA,GAAGA,EACxCL,UADwCK;EAAmB,WAC3DL,CAAAA,EAAAA,MAAAA;EAAU,QAAA,CAAA,EAAA,MAAA;EAYEO,SAAAA,CAAAA,EAAAA,MAAAA;EAA4B,aAAA,CAAA,EAAA,MAAA;EAAA,cAGxCP,CAAAA,EAAAA,OAAAA;EAAU,SAMKM,CAAAA,EAAAA,MAAAA;EAAkC,oBAAAE,CAAAA,EAAAA,MAMmDC;CAAgB;;;;AAMtEP,cArBlCK,4BAAAA,SAAqCH,cAAAA,CAqBHF;EAAe,WAAvBU,EAAAA,MAAAA;EAAO,QASzBX,EAAAA,MAAAA;EAAW,GAAgBE,EA3B/CH,UA2B+CG;EAAY,SAAGS,EAAAA,MAAAA;EAAO,aA9BpBR,EAAAA,MAAAA;EAAc,cAAA,EAAA,OAAA;;;sBAShDE;;;;;;iBAMLM,QAA0JJ,yBAAAA,CAA/GG,YANJH,yBAAAA,CAMmDC,gBAAAA,EAAgBD,yBAAAA,CAAqCE,WAAAA;;;;;;+BAMjIT,cAAcW,QAAQV;;;;;;;;;2BAS1BD,2BAA2BE,eAAeS"}
1
+ {"version":3,"file":"token_buffer_memory.d.cts","names":["ChatOpenAI","InputValues","MemoryVariables","OutputValues","BaseChatMemory","BaseChatMemoryInput","OpenAIAgentTokenBufferMemoryFields","OpenAIAgentTokenBufferMemory","_langchain_core_messages1","MessageStructure","MessageType","BaseMessage","Promise"],"sources":["../../../../src/agents/toolkits/conversational_retrieval/token_buffer_memory.d.ts"],"sourcesContent":["import { ChatOpenAI } from \"@langchain/openai\";\nimport { InputValues, MemoryVariables, OutputValues } from \"@langchain/core/memory\";\nimport { BaseChatMemory, BaseChatMemoryInput } from \"../../../memory/chat_memory.js\";\n/**\n * Type definition for the fields required to initialize an instance of\n * OpenAIAgentTokenBufferMemory.\n */\nexport type OpenAIAgentTokenBufferMemoryFields = BaseChatMemoryInput & {\n llm: ChatOpenAI;\n humanPrefix?: string;\n aiPrefix?: string;\n memoryKey?: string;\n maxTokenLimit?: number;\n returnMessages?: boolean;\n outputKey?: string;\n intermediateStepsKey?: string;\n};\n/**\n * Memory used to save agent output and intermediate steps.\n */\nexport declare class OpenAIAgentTokenBufferMemory extends BaseChatMemory {\n humanPrefix: string;\n aiPrefix: string;\n llm: ChatOpenAI;\n memoryKey: string;\n maxTokenLimit: number;\n returnMessages: boolean;\n outputKey: string;\n intermediateStepsKey: string;\n constructor(fields: OpenAIAgentTokenBufferMemoryFields);\n get memoryKeys(): string[];\n /**\n * Retrieves the messages from the chat history.\n * @returns Promise that resolves with the messages from the chat history.\n */\n getMessages(): Promise<import(\"@langchain/core/messages\").BaseMessage<import(\"@langchain/core/messages\").MessageStructure, import(\"@langchain/core/messages\").MessageType>[]>;\n /**\n * Loads memory variables from the input values.\n * @param _values Input values.\n * @returns Promise that resolves with the loaded memory variables.\n */\n loadMemoryVariables(_values: InputValues): Promise<MemoryVariables>;\n /**\n * Saves the context of the chat, including user input, AI output, and\n * intermediate steps. Prunes the chat history if the total token count\n * exceeds the maximum limit.\n * @param inputValues Input values.\n * @param outputValues Output values.\n * @returns Promise that resolves when the context has been saved.\n */\n saveContext(inputValues: InputValues, outputValues: OutputValues): Promise<void>;\n}\n"],"mappings":";;;;;;;;;;AAOA;AAA8C,KAAlCM,kCAAAA,GAAqCD,mBAAH,GAAA;EAAA,GAAGA,EACxCL,UADwCK;EAAmB,WAC3DL,CAAAA,EAAAA,MAAAA;EAAU,QAAA,CAAA,EAAA,MAAA;EAYEO,SAAAA,CAAAA,EAAAA,MAAAA;EAA4B,aAAA,CAAA,EAAA,MAAA;EAAA,cAGxCP,CAAAA,EAAAA,OAAAA;EAAU,SAMKM,CAAAA,EAAAA,MAAAA;EAAkC,oBAAAE,CAAAA,EAAAA,MAMmDC;CAAgB;;;;AAMtEP,cArBlCK,4BAAAA,SAAqCH,cAAAA,CAqBHF;EAAe,WAAvBU,EAAAA,MAAAA;EAAO,QASzBX,EAAAA,MAAAA;EAAW,GAAgBE,EA3B/CH,UA2B+CG;EAAY,SAAGS,EAAAA,MAAAA;EAAO,aA9BpBR,EAAAA,MAAAA;EAAc,cAAA,EAAA,OAAA;;;sBAShDE;;;;;;iBAMLM,QAA0JJ,yBAAAA,CAA/GG,YANJH,yBAAAA,CAMmDC,gBAAAA,EAAgBD,yBAAAA,CAAqCE,WAAAA;;;;;;+BAMjIT,cAAcW,QAAQV;;;;;;;;;2BAS1BD,2BAA2BE,eAAeS"}
@@ -5,9 +5,15 @@ import { z } from "zod";
5
5
  //#region src/agents/toolkits/conversational_retrieval/tool.d.ts
6
6
  declare function createRetrieverTool(retriever: BaseRetrieverInterface, input: Omit<DynamicStructuredToolInput, "func" | "schema">): DynamicStructuredTool<z.ZodObject<{
7
7
  input: z.ZodString;
8
- }, z.core.$strip>, {
8
+ }, "strip", z.ZodTypeAny, {
9
9
  input: string;
10
- }, unknown, string>;
10
+ }, {
11
+ input: string;
12
+ }>, {
13
+ input: string;
14
+ }, {
15
+ input: string;
16
+ }, string>;
11
17
  //#endregion
12
18
  export { createRetrieverTool };
13
19
  //# sourceMappingURL=tool.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tool.d.cts","names":["BaseRetrieverInterface","z","DynamicStructuredTool","DynamicStructuredToolInput","createRetrieverTool","Omit","ZodString","core","$strip","ZodObject"],"sources":["../../../../src/agents/toolkits/conversational_retrieval/tool.d.ts"],"sourcesContent":["import type { BaseRetrieverInterface } from \"@langchain/core/retrievers\";\nimport { z } from \"zod\";\nimport { DynamicStructuredTool, DynamicStructuredToolInput } from \"@langchain/core/tools\";\nexport declare function createRetrieverTool(retriever: BaseRetrieverInterface, input: Omit<DynamicStructuredToolInput, \"func\" | \"schema\">): DynamicStructuredTool<z.ZodObject<{\n input: z.ZodString;\n}, z.core.$strip>, {\n input: string;\n}, unknown, string>;\n"],"mappings":";;;;;iBAGwBI,mBAAAA,YAA+BJ,+BAA+BK,KAAKF,iDAAiDD,sBAAsBD,CAAAA,CAAEQ;SACzJR,CAAAA,CAAEK;AADb,CAAA,EAEGL,CAAAA,CAAEM,IAAAA,CAAKC,MAFcJ,CAAAA,EAAAA;EAAmB,KAAA,EAAA,MAAA;CAAA,EAAA,OAAYJ,EAAAA,MAAAA,CAAAA"}
1
+ {"version":3,"file":"tool.d.cts","names":["BaseRetrieverInterface","z","DynamicStructuredTool","DynamicStructuredToolInput","createRetrieverTool","Omit","ZodString","ZodTypeAny","ZodObject"],"sources":["../../../../src/agents/toolkits/conversational_retrieval/tool.d.ts"],"sourcesContent":["import type { BaseRetrieverInterface } from \"@langchain/core/retrievers\";\nimport { z } from \"zod\";\nimport { DynamicStructuredTool, DynamicStructuredToolInput } from \"@langchain/core/tools\";\nexport declare function createRetrieverTool(retriever: BaseRetrieverInterface, input: Omit<DynamicStructuredToolInput, \"func\" | \"schema\">): DynamicStructuredTool<z.ZodObject<{\n input: z.ZodString;\n}, \"strip\", z.ZodTypeAny, {\n input: string;\n}, {\n input: string;\n}>, {\n input: string;\n}, {\n input: string;\n}, string>;\n"],"mappings":";;;;;iBAGwBI,mBAAAA,YAA+BJ,+BAA+BK,KAAKF,iDAAiDD,sBAAsBD,CAAAA,CAAEO;SACzJP,CAAAA,CAAEK;AADb,CAAA,EAAA,OAAwBF,EAEZH,CAAAA,CAAEM,UAFUH,EAAmB;EAAA,KAAA,EAAA,MAAA;CAAA,EAAA;EAAkC,KAAcD,EAAAA,MAAAA;CAA0B,CAAA,EAAA;EAA3B,KAC7EG,EAAAA,MAAAA;CAAS,EAAA;EACE,KAF4IE,EAAAA,MAAAA;CAAS,EAAA,MAAjCN,CAAAA"}
@@ -5,9 +5,15 @@ import { BaseRetrieverInterface } from "@langchain/core/retrievers";
5
5
  //#region src/agents/toolkits/conversational_retrieval/tool.d.ts
6
6
  declare function createRetrieverTool(retriever: BaseRetrieverInterface, input: Omit<DynamicStructuredToolInput, "func" | "schema">): DynamicStructuredTool<z.ZodObject<{
7
7
  input: z.ZodString;
8
- }, z.core.$strip>, {
8
+ }, "strip", z.ZodTypeAny, {
9
9
  input: string;
10
- }, unknown, string>;
10
+ }, {
11
+ input: string;
12
+ }>, {
13
+ input: string;
14
+ }, {
15
+ input: string;
16
+ }, string>;
11
17
  //#endregion
12
18
  export { createRetrieverTool };
13
19
  //# sourceMappingURL=tool.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tool.d.ts","names":["BaseRetrieverInterface","z","DynamicStructuredTool","DynamicStructuredToolInput","createRetrieverTool","Omit","ZodString","core","$strip","ZodObject"],"sources":["../../../../src/agents/toolkits/conversational_retrieval/tool.d.ts"],"sourcesContent":["import type { BaseRetrieverInterface } from \"@langchain/core/retrievers\";\nimport { z } from \"zod\";\nimport { DynamicStructuredTool, DynamicStructuredToolInput } from \"@langchain/core/tools\";\nexport declare function createRetrieverTool(retriever: BaseRetrieverInterface, input: Omit<DynamicStructuredToolInput, \"func\" | \"schema\">): DynamicStructuredTool<z.ZodObject<{\n input: z.ZodString;\n}, z.core.$strip>, {\n input: string;\n}, unknown, string>;\n"],"mappings":";;;;;iBAGwBI,mBAAAA,YAA+BJ,+BAA+BK,KAAKF,iDAAiDD,sBAAsBD,CAAAA,CAAEQ;SACzJR,CAAAA,CAAEK;AADb,CAAA,EAEGL,CAAAA,CAAEM,IAAAA,CAAKC,MAFcJ,CAAAA,EAAAA;EAAmB,KAAA,EAAA,MAAA;CAAA,EAAA,OAAYJ,EAAAA,MAAAA,CAAAA"}
1
+ {"version":3,"file":"tool.d.ts","names":["BaseRetrieverInterface","z","DynamicStructuredTool","DynamicStructuredToolInput","createRetrieverTool","Omit","ZodString","ZodTypeAny","ZodObject"],"sources":["../../../../src/agents/toolkits/conversational_retrieval/tool.d.ts"],"sourcesContent":["import type { BaseRetrieverInterface } from \"@langchain/core/retrievers\";\nimport { z } from \"zod\";\nimport { DynamicStructuredTool, DynamicStructuredToolInput } from \"@langchain/core/tools\";\nexport declare function createRetrieverTool(retriever: BaseRetrieverInterface, input: Omit<DynamicStructuredToolInput, \"func\" | \"schema\">): DynamicStructuredTool<z.ZodObject<{\n input: z.ZodString;\n}, \"strip\", z.ZodTypeAny, {\n input: string;\n}, {\n input: string;\n}>, {\n input: string;\n}, {\n input: string;\n}, string>;\n"],"mappings":";;;;;iBAGwBI,mBAAAA,YAA+BJ,+BAA+BK,KAAKF,iDAAiDD,sBAAsBD,CAAAA,CAAEO;SACzJP,CAAAA,CAAEK;AADb,CAAA,EAAA,OAAwBF,EAEZH,CAAAA,CAAEM,UAFUH,EAAmB;EAAA,KAAA,EAAA,MAAA;CAAA,EAAA;EAAkC,KAAcD,EAAAA,MAAAA;CAA0B,CAAA,EAAA;EAA3B,KAC7EG,EAAAA,MAAAA;CAAS,EAAA;EACE,KAF4IE,EAAAA,MAAAA;CAAS,EAAA,MAAjCN,CAAAA"}
@@ -22,6 +22,7 @@ const require_transform = require('./transform.cjs');
22
22
  const require_extraction = require('./openai_functions/extraction.cjs');
23
23
  const require_tagging = require('./openai_functions/tagging.cjs');
24
24
  const require_openapi = require('./openai_functions/openapi.cjs');
25
+ const require_openai_moderation = require('./openai_moderation.cjs');
25
26
 
26
27
  //#region src/chains/index.ts
27
28
  var chains_exports = {};
@@ -40,6 +41,7 @@ require_rolldown_runtime.__export(chains_exports, {
40
41
  MultiPromptChain: () => require_multi_prompt.MultiPromptChain,
41
42
  MultiRetrievalQAChain: () => require_multi_retrieval_qa.MultiRetrievalQAChain,
42
43
  MultiRouteChain: () => require_multi_route.MultiRouteChain,
44
+ OpenAIModerationChain: () => require_openai_moderation.OpenAIModerationChain,
43
45
  PRINCIPLES: () => require_constitutional_principle.PRINCIPLES,
44
46
  RefineDocumentsChain: () => require_combine_docs_chain.RefineDocumentsChain,
45
47
  RetrievalQAChain: () => require_retrieval_qa.RetrievalQAChain,
@@ -77,6 +79,7 @@ exports.MapReduceDocumentsChain = require_combine_docs_chain.MapReduceDocumentsC
77
79
  exports.MultiPromptChain = require_multi_prompt.MultiPromptChain;
78
80
  exports.MultiRetrievalQAChain = require_multi_retrieval_qa.MultiRetrievalQAChain;
79
81
  exports.MultiRouteChain = require_multi_route.MultiRouteChain;
82
+ exports.OpenAIModerationChain = require_openai_moderation.OpenAIModerationChain;
80
83
  exports.PRINCIPLES = require_constitutional_principle.PRINCIPLES;
81
84
  exports.RefineDocumentsChain = require_combine_docs_chain.RefineDocumentsChain;
82
85
  exports.RetrievalQAChain = require_retrieval_qa.RetrievalQAChain;
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":[],"sources":["../../src/chains/index.ts"],"sourcesContent":["export { BaseChain, type ChainInputs } from \"./base.js\";\nexport { LLMChain, type LLMChainInput } from \"./llm_chain.js\";\nexport {\n APIChain,\n type APIChainInput,\n type APIChainOptions,\n} from \"./api/api_chain.js\";\nexport { ConversationChain } from \"./conversation.js\";\nexport {\n SequentialChain,\n type SequentialChainInput,\n SimpleSequentialChain,\n type SimpleSequentialChainInput,\n} from \"./sequential_chain.js\";\nexport {\n StuffDocumentsChain,\n type StuffDocumentsChainInput,\n MapReduceDocumentsChain,\n type MapReduceDocumentsChainInput,\n RefineDocumentsChain,\n type RefineDocumentsChainInput,\n} from \"./combine_docs_chain.js\";\nexport {\n ChatVectorDBQAChain,\n type ChatVectorDBQAChainInput,\n} from \"./chat_vector_db_chain.js\";\nexport {\n AnalyzeDocumentChain,\n type AnalyzeDocumentChainInput,\n} from \"./analyze_documents_chain.js\";\nexport { VectorDBQAChain, type VectorDBQAChainInput } from \"./vector_db_qa.js\";\nexport {\n loadQAChain,\n type QAChainParams,\n loadQAStuffChain,\n type StuffQAChainParams,\n loadQAMapReduceChain,\n type MapReduceQAChainParams,\n loadQARefineChain,\n type RefineQAChainParams,\n} from \"./question_answering/load.js\";\nexport {\n loadSummarizationChain,\n type SummarizationChainParams,\n} from \"./summarization/load.js\";\nexport {\n ConversationalRetrievalQAChain,\n type ConversationalRetrievalQAChainInput,\n} from \"./conversational_retrieval_chain.js\";\nexport {\n RetrievalQAChain,\n type RetrievalQAChainInput,\n} from \"./retrieval_qa.js\";\nexport {\n type ConstitutionalChainInput,\n ConstitutionalChain,\n} from \"./constitutional_ai/constitutional_chain.js\";\nexport {\n ConstitutionalPrinciple,\n PRINCIPLES,\n} from \"./constitutional_ai/constitutional_principle.js\";\nexport type {\n SerializedLLMChain,\n SerializedSequentialChain,\n SerializedSimpleSequentialChain,\n SerializedAnalyzeDocumentChain,\n SerializedAPIChain,\n SerializedBaseChain,\n SerializedChatVectorDBQAChain,\n SerializedMapReduceDocumentsChain,\n SerializedStuffDocumentsChain,\n SerializedVectorDBQAChain,\n SerializedRefineDocumentsChain,\n} from \"./serde.js\";\nexport {\n MultiRouteChain,\n type MultiRouteChainInput,\n RouterChain,\n} from \"./router/multi_route.js\";\nexport {\n LLMRouterChain,\n type LLMRouterChainInput,\n type RouterOutputSchema,\n} from \"./router/llm_router.js\";\nexport { MultiPromptChain } from \"./router/multi_prompt.js\";\nexport { MultiRetrievalQAChain } from \"./router/multi_retrieval_qa.js\";\nexport { TransformChain, type TransformChainFields } from \"./transform.js\";\nexport {\n createExtractionChain,\n createExtractionChainFromZod,\n} from \"./openai_functions/extraction.js\";\nexport {\n type TaggingChainOptions,\n createTaggingChain,\n createTaggingChainFromZod,\n} from \"./openai_functions/tagging.js\";\nexport {\n type OpenAPIChainOptions,\n createOpenAPIChain,\n convertOpenAPISpecToOpenAIFunctions,\n} from \"./openai_functions/openapi.js\";\n"],"mappings":""}
1
+ {"version":3,"file":"index.cjs","names":[],"sources":["../../src/chains/index.ts"],"sourcesContent":["export { BaseChain, type ChainInputs } from \"./base.js\";\nexport { LLMChain, type LLMChainInput } from \"./llm_chain.js\";\nexport {\n APIChain,\n type APIChainInput,\n type APIChainOptions,\n} from \"./api/api_chain.js\";\nexport { ConversationChain } from \"./conversation.js\";\nexport {\n SequentialChain,\n type SequentialChainInput,\n SimpleSequentialChain,\n type SimpleSequentialChainInput,\n} from \"./sequential_chain.js\";\nexport {\n StuffDocumentsChain,\n type StuffDocumentsChainInput,\n MapReduceDocumentsChain,\n type MapReduceDocumentsChainInput,\n RefineDocumentsChain,\n type RefineDocumentsChainInput,\n} from \"./combine_docs_chain.js\";\nexport {\n ChatVectorDBQAChain,\n type ChatVectorDBQAChainInput,\n} from \"./chat_vector_db_chain.js\";\nexport {\n AnalyzeDocumentChain,\n type AnalyzeDocumentChainInput,\n} from \"./analyze_documents_chain.js\";\nexport { VectorDBQAChain, type VectorDBQAChainInput } from \"./vector_db_qa.js\";\nexport {\n loadQAChain,\n type QAChainParams,\n loadQAStuffChain,\n type StuffQAChainParams,\n loadQAMapReduceChain,\n type MapReduceQAChainParams,\n loadQARefineChain,\n type RefineQAChainParams,\n} from \"./question_answering/load.js\";\nexport {\n loadSummarizationChain,\n type SummarizationChainParams,\n} from \"./summarization/load.js\";\nexport {\n ConversationalRetrievalQAChain,\n type ConversationalRetrievalQAChainInput,\n} from \"./conversational_retrieval_chain.js\";\nexport {\n RetrievalQAChain,\n type RetrievalQAChainInput,\n} from \"./retrieval_qa.js\";\nexport {\n type ConstitutionalChainInput,\n ConstitutionalChain,\n} from \"./constitutional_ai/constitutional_chain.js\";\nexport {\n ConstitutionalPrinciple,\n PRINCIPLES,\n} from \"./constitutional_ai/constitutional_principle.js\";\nexport type {\n SerializedLLMChain,\n SerializedSequentialChain,\n SerializedSimpleSequentialChain,\n SerializedAnalyzeDocumentChain,\n SerializedAPIChain,\n SerializedBaseChain,\n SerializedChatVectorDBQAChain,\n SerializedMapReduceDocumentsChain,\n SerializedStuffDocumentsChain,\n SerializedVectorDBQAChain,\n SerializedRefineDocumentsChain,\n} from \"./serde.js\";\nexport {\n MultiRouteChain,\n type MultiRouteChainInput,\n RouterChain,\n} from \"./router/multi_route.js\";\nexport {\n LLMRouterChain,\n type LLMRouterChainInput,\n type RouterOutputSchema,\n} from \"./router/llm_router.js\";\nexport { MultiPromptChain } from \"./router/multi_prompt.js\";\nexport { MultiRetrievalQAChain } from \"./router/multi_retrieval_qa.js\";\nexport { TransformChain, type TransformChainFields } from \"./transform.js\";\nexport {\n createExtractionChain,\n createExtractionChainFromZod,\n} from \"./openai_functions/extraction.js\";\nexport {\n type TaggingChainOptions,\n createTaggingChain,\n createTaggingChainFromZod,\n} from \"./openai_functions/tagging.js\";\nexport {\n type OpenAPIChainOptions,\n createOpenAPIChain,\n convertOpenAPISpecToOpenAIFunctions,\n} from \"./openai_functions/openapi.js\";\n\nexport {\n type OpenAIModerationChainInput,\n OpenAIModerationChain,\n} from \"./openai_moderation.js\";\n"],"mappings":""}
@@ -22,4 +22,5 @@ import { TransformChain, TransformChainFields } from "./transform.cjs";
22
22
  import { createExtractionChain, createExtractionChainFromZod } from "./openai_functions/extraction.cjs";
23
23
  import { TaggingChainOptions, createTaggingChain, createTaggingChainFromZod } from "./openai_functions/tagging.cjs";
24
24
  import { OpenAPIChainOptions, convertOpenAPISpecToOpenAIFunctions, createOpenAPIChain } from "./openai_functions/openapi.cjs";
25
- export { APIChain, type APIChainInput, type APIChainOptions, AnalyzeDocumentChain, type AnalyzeDocumentChainInput, BaseChain, type ChainInputs, ChatVectorDBQAChain, type ChatVectorDBQAChainInput, ConstitutionalChain, type ConstitutionalChainInput, ConstitutionalPrinciple, ConversationChain, ConversationalRetrievalQAChain, type ConversationalRetrievalQAChainInput, LLMChain, type LLMChainInput, LLMRouterChain, type LLMRouterChainInput, MapReduceDocumentsChain, type MapReduceDocumentsChainInput, type MapReduceQAChainParams, MultiPromptChain, MultiRetrievalQAChain, MultiRouteChain, type MultiRouteChainInput, type OpenAPIChainOptions, PRINCIPLES, type QAChainParams, RefineDocumentsChain, type RefineDocumentsChainInput, type RefineQAChainParams, RetrievalQAChain, type RetrievalQAChainInput, RouterChain, type RouterOutputSchema, SequentialChain, type SequentialChainInput, type SerializedAPIChain, type SerializedAnalyzeDocumentChain, type SerializedBaseChain, type SerializedChatVectorDBQAChain, type SerializedLLMChain, type SerializedMapReduceDocumentsChain, type SerializedRefineDocumentsChain, type SerializedSequentialChain, type SerializedSimpleSequentialChain, type SerializedStuffDocumentsChain, type SerializedVectorDBQAChain, SimpleSequentialChain, type SimpleSequentialChainInput, StuffDocumentsChain, type StuffDocumentsChainInput, type StuffQAChainParams, type SummarizationChainParams, type TaggingChainOptions, TransformChain, type TransformChainFields, VectorDBQAChain, type VectorDBQAChainInput, convertOpenAPISpecToOpenAIFunctions, createExtractionChain, createExtractionChainFromZod, createOpenAPIChain, createTaggingChain, createTaggingChainFromZod, loadQAChain, loadQAMapReduceChain, loadQARefineChain, loadQAStuffChain, loadSummarizationChain };
25
+ import { OpenAIModerationChain, OpenAIModerationChainInput } from "./openai_moderation.cjs";
26
+ export { APIChain, type APIChainInput, type APIChainOptions, AnalyzeDocumentChain, type AnalyzeDocumentChainInput, BaseChain, type ChainInputs, ChatVectorDBQAChain, type ChatVectorDBQAChainInput, ConstitutionalChain, type ConstitutionalChainInput, ConstitutionalPrinciple, ConversationChain, ConversationalRetrievalQAChain, type ConversationalRetrievalQAChainInput, LLMChain, type LLMChainInput, LLMRouterChain, type LLMRouterChainInput, MapReduceDocumentsChain, type MapReduceDocumentsChainInput, type MapReduceQAChainParams, MultiPromptChain, MultiRetrievalQAChain, MultiRouteChain, type MultiRouteChainInput, OpenAIModerationChain, type OpenAIModerationChainInput, type OpenAPIChainOptions, PRINCIPLES, type QAChainParams, RefineDocumentsChain, type RefineDocumentsChainInput, type RefineQAChainParams, RetrievalQAChain, type RetrievalQAChainInput, RouterChain, type RouterOutputSchema, SequentialChain, type SequentialChainInput, type SerializedAPIChain, type SerializedAnalyzeDocumentChain, type SerializedBaseChain, type SerializedChatVectorDBQAChain, type SerializedLLMChain, type SerializedMapReduceDocumentsChain, type SerializedRefineDocumentsChain, type SerializedSequentialChain, type SerializedSimpleSequentialChain, type SerializedStuffDocumentsChain, type SerializedVectorDBQAChain, SimpleSequentialChain, type SimpleSequentialChainInput, StuffDocumentsChain, type StuffDocumentsChainInput, type StuffQAChainParams, type SummarizationChainParams, type TaggingChainOptions, TransformChain, type TransformChainFields, VectorDBQAChain, type VectorDBQAChainInput, convertOpenAPISpecToOpenAIFunctions, createExtractionChain, createExtractionChainFromZod, createOpenAPIChain, createTaggingChain, createTaggingChainFromZod, loadQAChain, loadQAMapReduceChain, loadQARefineChain, loadQAStuffChain, loadSummarizationChain };
@@ -22,4 +22,5 @@ import { TransformChain, TransformChainFields } from "./transform.js";
22
22
  import { createExtractionChain, createExtractionChainFromZod } from "./openai_functions/extraction.js";
23
23
  import { TaggingChainOptions, createTaggingChain, createTaggingChainFromZod } from "./openai_functions/tagging.js";
24
24
  import { OpenAPIChainOptions, convertOpenAPISpecToOpenAIFunctions, createOpenAPIChain } from "./openai_functions/openapi.js";
25
- export { APIChain, type APIChainInput, type APIChainOptions, AnalyzeDocumentChain, type AnalyzeDocumentChainInput, BaseChain, type ChainInputs, ChatVectorDBQAChain, type ChatVectorDBQAChainInput, ConstitutionalChain, type ConstitutionalChainInput, ConstitutionalPrinciple, ConversationChain, ConversationalRetrievalQAChain, type ConversationalRetrievalQAChainInput, LLMChain, type LLMChainInput, LLMRouterChain, type LLMRouterChainInput, MapReduceDocumentsChain, type MapReduceDocumentsChainInput, type MapReduceQAChainParams, MultiPromptChain, MultiRetrievalQAChain, MultiRouteChain, type MultiRouteChainInput, type OpenAPIChainOptions, PRINCIPLES, type QAChainParams, RefineDocumentsChain, type RefineDocumentsChainInput, type RefineQAChainParams, RetrievalQAChain, type RetrievalQAChainInput, RouterChain, type RouterOutputSchema, SequentialChain, type SequentialChainInput, type SerializedAPIChain, type SerializedAnalyzeDocumentChain, type SerializedBaseChain, type SerializedChatVectorDBQAChain, type SerializedLLMChain, type SerializedMapReduceDocumentsChain, type SerializedRefineDocumentsChain, type SerializedSequentialChain, type SerializedSimpleSequentialChain, type SerializedStuffDocumentsChain, type SerializedVectorDBQAChain, SimpleSequentialChain, type SimpleSequentialChainInput, StuffDocumentsChain, type StuffDocumentsChainInput, type StuffQAChainParams, type SummarizationChainParams, type TaggingChainOptions, TransformChain, type TransformChainFields, VectorDBQAChain, type VectorDBQAChainInput, convertOpenAPISpecToOpenAIFunctions, createExtractionChain, createExtractionChainFromZod, createOpenAPIChain, createTaggingChain, createTaggingChainFromZod, loadQAChain, loadQAMapReduceChain, loadQARefineChain, loadQAStuffChain, loadSummarizationChain };
25
+ import { OpenAIModerationChain, OpenAIModerationChainInput } from "./openai_moderation.js";
26
+ export { APIChain, type APIChainInput, type APIChainOptions, AnalyzeDocumentChain, type AnalyzeDocumentChainInput, BaseChain, type ChainInputs, ChatVectorDBQAChain, type ChatVectorDBQAChainInput, ConstitutionalChain, type ConstitutionalChainInput, ConstitutionalPrinciple, ConversationChain, ConversationalRetrievalQAChain, type ConversationalRetrievalQAChainInput, LLMChain, type LLMChainInput, LLMRouterChain, type LLMRouterChainInput, MapReduceDocumentsChain, type MapReduceDocumentsChainInput, type MapReduceQAChainParams, MultiPromptChain, MultiRetrievalQAChain, MultiRouteChain, type MultiRouteChainInput, OpenAIModerationChain, type OpenAIModerationChainInput, type OpenAPIChainOptions, PRINCIPLES, type QAChainParams, RefineDocumentsChain, type RefineDocumentsChainInput, type RefineQAChainParams, RetrievalQAChain, type RetrievalQAChainInput, RouterChain, type RouterOutputSchema, SequentialChain, type SequentialChainInput, type SerializedAPIChain, type SerializedAnalyzeDocumentChain, type SerializedBaseChain, type SerializedChatVectorDBQAChain, type SerializedLLMChain, type SerializedMapReduceDocumentsChain, type SerializedRefineDocumentsChain, type SerializedSequentialChain, type SerializedSimpleSequentialChain, type SerializedStuffDocumentsChain, type SerializedVectorDBQAChain, SimpleSequentialChain, type SimpleSequentialChainInput, StuffDocumentsChain, type StuffDocumentsChainInput, type StuffQAChainParams, type SummarizationChainParams, type TaggingChainOptions, TransformChain, type TransformChainFields, VectorDBQAChain, type VectorDBQAChainInput, convertOpenAPISpecToOpenAIFunctions, createExtractionChain, createExtractionChainFromZod, createOpenAPIChain, createTaggingChain, createTaggingChainFromZod, loadQAChain, loadQAMapReduceChain, loadQARefineChain, loadQAStuffChain, loadSummarizationChain };
@@ -22,6 +22,7 @@ import { TransformChain } from "./transform.js";
22
22
  import { createExtractionChain, createExtractionChainFromZod } from "./openai_functions/extraction.js";
23
23
  import { createTaggingChain, createTaggingChainFromZod } from "./openai_functions/tagging.js";
24
24
  import { convertOpenAPISpecToOpenAIFunctions, createOpenAPIChain } from "./openai_functions/openapi.js";
25
+ import { OpenAIModerationChain } from "./openai_moderation.js";
25
26
 
26
27
  //#region src/chains/index.ts
27
28
  var chains_exports = {};
@@ -40,6 +41,7 @@ __export(chains_exports, {
40
41
  MultiPromptChain: () => MultiPromptChain,
41
42
  MultiRetrievalQAChain: () => MultiRetrievalQAChain,
42
43
  MultiRouteChain: () => MultiRouteChain,
44
+ OpenAIModerationChain: () => OpenAIModerationChain,
43
45
  PRINCIPLES: () => PRINCIPLES,
44
46
  RefineDocumentsChain: () => RefineDocumentsChain,
45
47
  RetrievalQAChain: () => RetrievalQAChain,
@@ -63,5 +65,5 @@ __export(chains_exports, {
63
65
  });
64
66
 
65
67
  //#endregion
66
- export { APIChain, AnalyzeDocumentChain, BaseChain, ChatVectorDBQAChain, ConstitutionalChain, ConstitutionalPrinciple, ConversationChain, ConversationalRetrievalQAChain, LLMChain, LLMRouterChain, MapReduceDocumentsChain, MultiPromptChain, MultiRetrievalQAChain, MultiRouteChain, PRINCIPLES, RefineDocumentsChain, RetrievalQAChain, RouterChain, SequentialChain, SimpleSequentialChain, StuffDocumentsChain, TransformChain, VectorDBQAChain, chains_exports, convertOpenAPISpecToOpenAIFunctions, createExtractionChain, createExtractionChainFromZod, createOpenAPIChain, createTaggingChain, createTaggingChainFromZod, loadQAChain, loadQAMapReduceChain, loadQARefineChain, loadQAStuffChain, loadSummarizationChain };
68
+ export { APIChain, AnalyzeDocumentChain, BaseChain, ChatVectorDBQAChain, ConstitutionalChain, ConstitutionalPrinciple, ConversationChain, ConversationalRetrievalQAChain, LLMChain, LLMRouterChain, MapReduceDocumentsChain, MultiPromptChain, MultiRetrievalQAChain, MultiRouteChain, OpenAIModerationChain, PRINCIPLES, RefineDocumentsChain, RetrievalQAChain, RouterChain, SequentialChain, SimpleSequentialChain, StuffDocumentsChain, TransformChain, VectorDBQAChain, chains_exports, convertOpenAPISpecToOpenAIFunctions, createExtractionChain, createExtractionChainFromZod, createOpenAPIChain, createTaggingChain, createTaggingChainFromZod, loadQAChain, loadQAMapReduceChain, loadQARefineChain, loadQAStuffChain, loadSummarizationChain };
67
69
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/chains/index.ts"],"sourcesContent":["export { BaseChain, type ChainInputs } from \"./base.js\";\nexport { LLMChain, type LLMChainInput } from \"./llm_chain.js\";\nexport {\n APIChain,\n type APIChainInput,\n type APIChainOptions,\n} from \"./api/api_chain.js\";\nexport { ConversationChain } from \"./conversation.js\";\nexport {\n SequentialChain,\n type SequentialChainInput,\n SimpleSequentialChain,\n type SimpleSequentialChainInput,\n} from \"./sequential_chain.js\";\nexport {\n StuffDocumentsChain,\n type StuffDocumentsChainInput,\n MapReduceDocumentsChain,\n type MapReduceDocumentsChainInput,\n RefineDocumentsChain,\n type RefineDocumentsChainInput,\n} from \"./combine_docs_chain.js\";\nexport {\n ChatVectorDBQAChain,\n type ChatVectorDBQAChainInput,\n} from \"./chat_vector_db_chain.js\";\nexport {\n AnalyzeDocumentChain,\n type AnalyzeDocumentChainInput,\n} from \"./analyze_documents_chain.js\";\nexport { VectorDBQAChain, type VectorDBQAChainInput } from \"./vector_db_qa.js\";\nexport {\n loadQAChain,\n type QAChainParams,\n loadQAStuffChain,\n type StuffQAChainParams,\n loadQAMapReduceChain,\n type MapReduceQAChainParams,\n loadQARefineChain,\n type RefineQAChainParams,\n} from \"./question_answering/load.js\";\nexport {\n loadSummarizationChain,\n type SummarizationChainParams,\n} from \"./summarization/load.js\";\nexport {\n ConversationalRetrievalQAChain,\n type ConversationalRetrievalQAChainInput,\n} from \"./conversational_retrieval_chain.js\";\nexport {\n RetrievalQAChain,\n type RetrievalQAChainInput,\n} from \"./retrieval_qa.js\";\nexport {\n type ConstitutionalChainInput,\n ConstitutionalChain,\n} from \"./constitutional_ai/constitutional_chain.js\";\nexport {\n ConstitutionalPrinciple,\n PRINCIPLES,\n} from \"./constitutional_ai/constitutional_principle.js\";\nexport type {\n SerializedLLMChain,\n SerializedSequentialChain,\n SerializedSimpleSequentialChain,\n SerializedAnalyzeDocumentChain,\n SerializedAPIChain,\n SerializedBaseChain,\n SerializedChatVectorDBQAChain,\n SerializedMapReduceDocumentsChain,\n SerializedStuffDocumentsChain,\n SerializedVectorDBQAChain,\n SerializedRefineDocumentsChain,\n} from \"./serde.js\";\nexport {\n MultiRouteChain,\n type MultiRouteChainInput,\n RouterChain,\n} from \"./router/multi_route.js\";\nexport {\n LLMRouterChain,\n type LLMRouterChainInput,\n type RouterOutputSchema,\n} from \"./router/llm_router.js\";\nexport { MultiPromptChain } from \"./router/multi_prompt.js\";\nexport { MultiRetrievalQAChain } from \"./router/multi_retrieval_qa.js\";\nexport { TransformChain, type TransformChainFields } from \"./transform.js\";\nexport {\n createExtractionChain,\n createExtractionChainFromZod,\n} from \"./openai_functions/extraction.js\";\nexport {\n type TaggingChainOptions,\n createTaggingChain,\n createTaggingChainFromZod,\n} from \"./openai_functions/tagging.js\";\nexport {\n type OpenAPIChainOptions,\n createOpenAPIChain,\n convertOpenAPISpecToOpenAIFunctions,\n} from \"./openai_functions/openapi.js\";\n"],"mappings":""}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/chains/index.ts"],"sourcesContent":["export { BaseChain, type ChainInputs } from \"./base.js\";\nexport { LLMChain, type LLMChainInput } from \"./llm_chain.js\";\nexport {\n APIChain,\n type APIChainInput,\n type APIChainOptions,\n} from \"./api/api_chain.js\";\nexport { ConversationChain } from \"./conversation.js\";\nexport {\n SequentialChain,\n type SequentialChainInput,\n SimpleSequentialChain,\n type SimpleSequentialChainInput,\n} from \"./sequential_chain.js\";\nexport {\n StuffDocumentsChain,\n type StuffDocumentsChainInput,\n MapReduceDocumentsChain,\n type MapReduceDocumentsChainInput,\n RefineDocumentsChain,\n type RefineDocumentsChainInput,\n} from \"./combine_docs_chain.js\";\nexport {\n ChatVectorDBQAChain,\n type ChatVectorDBQAChainInput,\n} from \"./chat_vector_db_chain.js\";\nexport {\n AnalyzeDocumentChain,\n type AnalyzeDocumentChainInput,\n} from \"./analyze_documents_chain.js\";\nexport { VectorDBQAChain, type VectorDBQAChainInput } from \"./vector_db_qa.js\";\nexport {\n loadQAChain,\n type QAChainParams,\n loadQAStuffChain,\n type StuffQAChainParams,\n loadQAMapReduceChain,\n type MapReduceQAChainParams,\n loadQARefineChain,\n type RefineQAChainParams,\n} from \"./question_answering/load.js\";\nexport {\n loadSummarizationChain,\n type SummarizationChainParams,\n} from \"./summarization/load.js\";\nexport {\n ConversationalRetrievalQAChain,\n type ConversationalRetrievalQAChainInput,\n} from \"./conversational_retrieval_chain.js\";\nexport {\n RetrievalQAChain,\n type RetrievalQAChainInput,\n} from \"./retrieval_qa.js\";\nexport {\n type ConstitutionalChainInput,\n ConstitutionalChain,\n} from \"./constitutional_ai/constitutional_chain.js\";\nexport {\n ConstitutionalPrinciple,\n PRINCIPLES,\n} from \"./constitutional_ai/constitutional_principle.js\";\nexport type {\n SerializedLLMChain,\n SerializedSequentialChain,\n SerializedSimpleSequentialChain,\n SerializedAnalyzeDocumentChain,\n SerializedAPIChain,\n SerializedBaseChain,\n SerializedChatVectorDBQAChain,\n SerializedMapReduceDocumentsChain,\n SerializedStuffDocumentsChain,\n SerializedVectorDBQAChain,\n SerializedRefineDocumentsChain,\n} from \"./serde.js\";\nexport {\n MultiRouteChain,\n type MultiRouteChainInput,\n RouterChain,\n} from \"./router/multi_route.js\";\nexport {\n LLMRouterChain,\n type LLMRouterChainInput,\n type RouterOutputSchema,\n} from \"./router/llm_router.js\";\nexport { MultiPromptChain } from \"./router/multi_prompt.js\";\nexport { MultiRetrievalQAChain } from \"./router/multi_retrieval_qa.js\";\nexport { TransformChain, type TransformChainFields } from \"./transform.js\";\nexport {\n createExtractionChain,\n createExtractionChainFromZod,\n} from \"./openai_functions/extraction.js\";\nexport {\n type TaggingChainOptions,\n createTaggingChain,\n createTaggingChainFromZod,\n} from \"./openai_functions/tagging.js\";\nexport {\n type OpenAPIChainOptions,\n createOpenAPIChain,\n convertOpenAPISpecToOpenAIFunctions,\n} from \"./openai_functions/openapi.js\";\n\nexport {\n type OpenAIModerationChainInput,\n OpenAIModerationChain,\n} from \"./openai_moderation.js\";\n"],"mappings":""}
@@ -0,0 +1,107 @@
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
+ const require_base = require('./base.cjs');
3
+ const __langchain_core_utils_env = require_rolldown_runtime.__toESM(require("@langchain/core/utils/env"));
4
+ const __langchain_openai = require_rolldown_runtime.__toESM(require("@langchain/openai"));
5
+ const __langchain_core_utils_async_caller = require_rolldown_runtime.__toESM(require("@langchain/core/utils/async_caller"));
6
+
7
+ //#region src/chains/openai_moderation.ts
8
+ /**
9
+ * Class representing a chain for moderating text using the OpenAI
10
+ * Moderation API. It extends the BaseChain class and implements the
11
+ * OpenAIModerationChainInput interface.
12
+ * @example
13
+ * ```typescript
14
+ * const moderation = new OpenAIModerationChain({ throwError: true });
15
+ *
16
+ * const badString = "Bad naughty words from user";
17
+ *
18
+ * try {
19
+ * const { output: moderatedContent, results } = await moderation.call({
20
+ * input: badString,
21
+ * });
22
+ *
23
+ * if (results[0].category_scores["harassment/threatening"] > 0.01) {
24
+ * throw new Error("Harassment detected!");
25
+ * }
26
+ *
27
+ * const model = new OpenAI({ temperature: 0 });
28
+ * const promptTemplate = "Hello, how are you today {person}?";
29
+ * const prompt = new PromptTemplate({
30
+ * template: promptTemplate,
31
+ * inputVariables: ["person"],
32
+ * });
33
+ * const chain = new LLMChain({ llm: model, prompt });
34
+ * const response = await chain.call({ person: moderatedContent });
35
+ * console.log({ response });
36
+ * } catch (error) {
37
+ * console.error("Naughty words detected!");
38
+ * }
39
+ * ```
40
+ */
41
+ var OpenAIModerationChain = class extends require_base.BaseChain {
42
+ static lc_name() {
43
+ return "OpenAIModerationChain";
44
+ }
45
+ get lc_secrets() {
46
+ return { openAIApiKey: "OPENAI_API_KEY" };
47
+ }
48
+ inputKey = "input";
49
+ outputKey = "output";
50
+ openAIApiKey;
51
+ openAIOrganization;
52
+ clientConfig;
53
+ client;
54
+ throwError;
55
+ caller;
56
+ constructor(fields) {
57
+ super(fields);
58
+ this.throwError = fields?.throwError ?? false;
59
+ this.openAIApiKey = fields?.apiKey ?? fields?.openAIApiKey ?? (0, __langchain_core_utils_env.getEnvironmentVariable)("OPENAI_API_KEY");
60
+ if (!this.openAIApiKey) throw new Error("OpenAI API key not found");
61
+ this.openAIOrganization = fields?.openAIOrganization;
62
+ this.clientConfig = {
63
+ ...fields?.configuration,
64
+ apiKey: this.openAIApiKey,
65
+ organization: this.openAIOrganization
66
+ };
67
+ this.client = new __langchain_openai.OpenAIClient(this.clientConfig);
68
+ this.caller = new __langchain_core_utils_async_caller.AsyncCaller(fields ?? {});
69
+ }
70
+ _moderate(text, results) {
71
+ if (results.flagged) {
72
+ const errorStr = "Text was found that violates OpenAI's content policy.";
73
+ if (this.throwError) throw new Error(errorStr);
74
+ else return errorStr;
75
+ }
76
+ return text;
77
+ }
78
+ async _call(values) {
79
+ const text = values[this.inputKey];
80
+ const moderationRequest = { input: text };
81
+ let mod;
82
+ try {
83
+ mod = await this.caller.call(() => this.client.moderations.create(moderationRequest));
84
+ } catch (error) {
85
+ if (error instanceof Error) throw error;
86
+ else throw new Error(error);
87
+ }
88
+ const output = this._moderate(text, mod.results[0]);
89
+ return {
90
+ [this.outputKey]: output,
91
+ results: mod.results
92
+ };
93
+ }
94
+ _chainType() {
95
+ return "moderation_chain";
96
+ }
97
+ get inputKeys() {
98
+ return [this.inputKey];
99
+ }
100
+ get outputKeys() {
101
+ return [this.outputKey];
102
+ }
103
+ };
104
+
105
+ //#endregion
106
+ exports.OpenAIModerationChain = OpenAIModerationChain;
107
+ //# sourceMappingURL=openai_moderation.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openai_moderation.cjs","names":["BaseChain","fields?: OpenAIModerationChainInput","OpenAIClient","AsyncCaller","text: string","results: OpenAIClient.Moderation","values: ChainValues","moderationRequest: OpenAIClient.ModerationCreateParams"],"sources":["../../src/chains/openai_moderation.ts"],"sourcesContent":["import { type ClientOptions, OpenAIClient } from \"@langchain/openai\";\nimport { ChainValues } from \"@langchain/core/utils/types\";\nimport {\n AsyncCaller,\n AsyncCallerParams,\n} from \"@langchain/core/utils/async_caller\";\nimport { getEnvironmentVariable } from \"@langchain/core/utils/env\";\nimport { BaseChain, ChainInputs } from \"./base.js\";\n\n/**\n * Interface for the input parameters of the OpenAIModerationChain class.\n */\nexport interface OpenAIModerationChainInput\n extends ChainInputs,\n AsyncCallerParams {\n apiKey?: string;\n /** @deprecated Use \"apiKey\" instead. */\n openAIApiKey?: string;\n openAIOrganization?: string;\n throwError?: boolean;\n configuration?: ClientOptions;\n}\n\n/**\n * Class representing a chain for moderating text using the OpenAI\n * Moderation API. It extends the BaseChain class and implements the\n * OpenAIModerationChainInput interface.\n * @example\n * ```typescript\n * const moderation = new OpenAIModerationChain({ throwError: true });\n *\n * const badString = \"Bad naughty words from user\";\n *\n * try {\n * const { output: moderatedContent, results } = await moderation.call({\n * input: badString,\n * });\n *\n * if (results[0].category_scores[\"harassment/threatening\"] > 0.01) {\n * throw new Error(\"Harassment detected!\");\n * }\n *\n * const model = new OpenAI({ temperature: 0 });\n * const promptTemplate = \"Hello, how are you today {person}?\";\n * const prompt = new PromptTemplate({\n * template: promptTemplate,\n * inputVariables: [\"person\"],\n * });\n * const chain = new LLMChain({ llm: model, prompt });\n * const response = await chain.call({ person: moderatedContent });\n * console.log({ response });\n * } catch (error) {\n * console.error(\"Naughty words detected!\");\n * }\n * ```\n */\nexport class OpenAIModerationChain\n extends BaseChain\n implements OpenAIModerationChainInput\n{\n static lc_name() {\n return \"OpenAIModerationChain\";\n }\n\n get lc_secrets(): { [key: string]: string } | undefined {\n return {\n openAIApiKey: \"OPENAI_API_KEY\",\n };\n }\n\n inputKey = \"input\";\n\n outputKey = \"output\";\n\n openAIApiKey?: string;\n\n openAIOrganization?: string;\n\n clientConfig: ClientOptions;\n\n client: OpenAIClient;\n\n throwError: boolean;\n\n caller: AsyncCaller;\n\n constructor(fields?: OpenAIModerationChainInput) {\n super(fields);\n this.throwError = fields?.throwError ?? false;\n this.openAIApiKey =\n fields?.apiKey ??\n fields?.openAIApiKey ??\n getEnvironmentVariable(\"OPENAI_API_KEY\");\n\n if (!this.openAIApiKey) {\n throw new Error(\"OpenAI API key not found\");\n }\n\n this.openAIOrganization = fields?.openAIOrganization;\n\n this.clientConfig = {\n ...fields?.configuration,\n apiKey: this.openAIApiKey,\n organization: this.openAIOrganization,\n };\n\n this.client = new OpenAIClient(this.clientConfig);\n\n this.caller = new AsyncCaller(fields ?? {});\n }\n\n _moderate(text: string, results: OpenAIClient.Moderation): string {\n if (results.flagged) {\n const errorStr = \"Text was found that violates OpenAI's content policy.\";\n if (this.throwError) {\n throw new Error(errorStr);\n } else {\n return errorStr;\n }\n }\n return text;\n }\n\n async _call(values: ChainValues): Promise<ChainValues> {\n const text = values[this.inputKey];\n const moderationRequest: OpenAIClient.ModerationCreateParams = {\n input: text,\n };\n let mod;\n try {\n mod = await this.caller.call(() =>\n this.client.moderations.create(moderationRequest)\n );\n } catch (error) {\n // eslint-disable-next-line no-instanceof/no-instanceof\n if (error instanceof Error) {\n throw error;\n } else {\n throw new Error(error as string);\n }\n }\n const output = this._moderate(text, mod.results[0]);\n return {\n [this.outputKey]: output,\n results: mod.results,\n };\n }\n\n _chainType() {\n return \"moderation_chain\";\n }\n\n get inputKeys(): string[] {\n return [this.inputKey];\n }\n\n get outputKeys(): string[] {\n return [this.outputKey];\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwDA,IAAa,wBAAb,cACUA,uBAEV;CACE,OAAO,UAAU;AACf,SAAO;CACR;CAED,IAAI,aAAoD;AACtD,SAAO,EACL,cAAc,iBACf;CACF;CAED,WAAW;CAEX,YAAY;CAEZ;CAEA;CAEA;CAEA;CAEA;CAEA;CAEA,YAAYC,QAAqC;EAC/C,MAAM,OAAO;EACb,KAAK,aAAa,QAAQ,cAAc;EACxC,KAAK,eACH,QAAQ,UACR,QAAQ,uEACe,iBAAiB;AAE1C,MAAI,CAAC,KAAK,aACR,OAAM,IAAI,MAAM;EAGlB,KAAK,qBAAqB,QAAQ;EAElC,KAAK,eAAe;GAClB,GAAG,QAAQ;GACX,QAAQ,KAAK;GACb,cAAc,KAAK;EACpB;EAED,KAAK,SAAS,IAAIC,gCAAa,KAAK;EAEpC,KAAK,SAAS,IAAIC,gDAAY,UAAU,CAAE;CAC3C;CAED,UAAUC,MAAcC,SAA0C;AAChE,MAAI,QAAQ,SAAS;GACnB,MAAM,WAAW;AACjB,OAAI,KAAK,WACP,OAAM,IAAI,MAAM;OAEhB,QAAO;EAEV;AACD,SAAO;CACR;CAED,MAAM,MAAMC,QAA2C;EACrD,MAAM,OAAO,OAAO,KAAK;EACzB,MAAMC,oBAAyD,EAC7D,OAAO,KACR;EACD,IAAI;AACJ,MAAI;GACF,MAAM,MAAM,KAAK,OAAO,KAAK,MAC3B,KAAK,OAAO,YAAY,OAAO,kBAAkB,CAClD;EACF,SAAQ,OAAO;AAEd,OAAI,iBAAiB,MACnB,OAAM;OAEN,OAAM,IAAI,MAAM;EAEnB;EACD,MAAM,SAAS,KAAK,UAAU,MAAM,IAAI,QAAQ,GAAG;AACnD,SAAO;IACJ,KAAK,YAAY;GAClB,SAAS,IAAI;EACd;CACF;CAED,aAAa;AACX,SAAO;CACR;CAED,IAAI,YAAsB;AACxB,SAAO,CAAC,KAAK,QAAS;CACvB;CAED,IAAI,aAAuB;AACzB,SAAO,CAAC,KAAK,SAAU;CACxB;AACF"}
@@ -0,0 +1,74 @@
1
+ import { BaseChain, ChainInputs } from "./base.cjs";
2
+ import { ChainValues } from "@langchain/core/utils/types";
3
+ import { ClientOptions, OpenAIClient } from "@langchain/openai";
4
+ import { AsyncCaller, AsyncCallerParams } from "@langchain/core/utils/async_caller";
5
+
6
+ //#region src/chains/openai_moderation.d.ts
7
+
8
+ /**
9
+ * Interface for the input parameters of the OpenAIModerationChain class.
10
+ */
11
+ interface OpenAIModerationChainInput extends ChainInputs, AsyncCallerParams {
12
+ apiKey?: string;
13
+ /** @deprecated Use "apiKey" instead. */
14
+ openAIApiKey?: string;
15
+ openAIOrganization?: string;
16
+ throwError?: boolean;
17
+ configuration?: ClientOptions;
18
+ }
19
+ /**
20
+ * Class representing a chain for moderating text using the OpenAI
21
+ * Moderation API. It extends the BaseChain class and implements the
22
+ * OpenAIModerationChainInput interface.
23
+ * @example
24
+ * ```typescript
25
+ * const moderation = new OpenAIModerationChain({ throwError: true });
26
+ *
27
+ * const badString = "Bad naughty words from user";
28
+ *
29
+ * try {
30
+ * const { output: moderatedContent, results } = await moderation.call({
31
+ * input: badString,
32
+ * });
33
+ *
34
+ * if (results[0].category_scores["harassment/threatening"] > 0.01) {
35
+ * throw new Error("Harassment detected!");
36
+ * }
37
+ *
38
+ * const model = new OpenAI({ temperature: 0 });
39
+ * const promptTemplate = "Hello, how are you today {person}?";
40
+ * const prompt = new PromptTemplate({
41
+ * template: promptTemplate,
42
+ * inputVariables: ["person"],
43
+ * });
44
+ * const chain = new LLMChain({ llm: model, prompt });
45
+ * const response = await chain.call({ person: moderatedContent });
46
+ * console.log({ response });
47
+ * } catch (error) {
48
+ * console.error("Naughty words detected!");
49
+ * }
50
+ * ```
51
+ */
52
+ declare class OpenAIModerationChain extends BaseChain implements OpenAIModerationChainInput {
53
+ static lc_name(): string;
54
+ get lc_secrets(): {
55
+ [key: string]: string;
56
+ } | undefined;
57
+ inputKey: string;
58
+ outputKey: string;
59
+ openAIApiKey?: string;
60
+ openAIOrganization?: string;
61
+ clientConfig: ClientOptions;
62
+ client: OpenAIClient;
63
+ throwError: boolean;
64
+ caller: AsyncCaller;
65
+ constructor(fields?: OpenAIModerationChainInput);
66
+ _moderate(text: string, results: OpenAIClient.Moderation): string;
67
+ _call(values: ChainValues): Promise<ChainValues>;
68
+ _chainType(): string;
69
+ get inputKeys(): string[];
70
+ get outputKeys(): string[];
71
+ }
72
+ //#endregion
73
+ export { OpenAIModerationChain, OpenAIModerationChainInput };
74
+ //# sourceMappingURL=openai_moderation.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openai_moderation.d.cts","names":["ClientOptions","OpenAIClient","ChainValues","AsyncCaller","AsyncCallerParams","BaseChain","ChainInputs","OpenAIModerationChainInput","OpenAIModerationChain","Moderation","Promise"],"sources":["../../src/chains/openai_moderation.d.ts"],"sourcesContent":["import { type ClientOptions, OpenAIClient } from \"@langchain/openai\";\nimport { ChainValues } from \"@langchain/core/utils/types\";\nimport { AsyncCaller, AsyncCallerParams } from \"@langchain/core/utils/async_caller\";\nimport { BaseChain, ChainInputs } from \"./base.js\";\n/**\n * Interface for the input parameters of the OpenAIModerationChain class.\n */\nexport interface OpenAIModerationChainInput extends ChainInputs, AsyncCallerParams {\n apiKey?: string;\n /** @deprecated Use \"apiKey\" instead. */\n openAIApiKey?: string;\n openAIOrganization?: string;\n throwError?: boolean;\n configuration?: ClientOptions;\n}\n/**\n * Class representing a chain for moderating text using the OpenAI\n * Moderation API. It extends the BaseChain class and implements the\n * OpenAIModerationChainInput interface.\n * @example\n * ```typescript\n * const moderation = new OpenAIModerationChain({ throwError: true });\n *\n * const badString = \"Bad naughty words from user\";\n *\n * try {\n * const { output: moderatedContent, results } = await moderation.call({\n * input: badString,\n * });\n *\n * if (results[0].category_scores[\"harassment/threatening\"] > 0.01) {\n * throw new Error(\"Harassment detected!\");\n * }\n *\n * const model = new OpenAI({ temperature: 0 });\n * const promptTemplate = \"Hello, how are you today {person}?\";\n * const prompt = new PromptTemplate({\n * template: promptTemplate,\n * inputVariables: [\"person\"],\n * });\n * const chain = new LLMChain({ llm: model, prompt });\n * const response = await chain.call({ person: moderatedContent });\n * console.log({ response });\n * } catch (error) {\n * console.error(\"Naughty words detected!\");\n * }\n * ```\n */\nexport declare class OpenAIModerationChain extends BaseChain implements OpenAIModerationChainInput {\n static lc_name(): string;\n get lc_secrets(): {\n [key: string]: string;\n } | undefined;\n inputKey: string;\n outputKey: string;\n openAIApiKey?: string;\n openAIOrganization?: string;\n clientConfig: ClientOptions;\n client: OpenAIClient;\n throwError: boolean;\n caller: AsyncCaller;\n constructor(fields?: OpenAIModerationChainInput);\n _moderate(text: string, results: OpenAIClient.Moderation): string;\n _call(values: ChainValues): Promise<ChainValues>;\n _chainType(): string;\n get inputKeys(): string[];\n get outputKeys(): string[];\n}\n"],"mappings":";;;;;;;;;AAOA;AAA2C,UAA1BO,0BAAAA,SAAmCD,WAAT,EAAsBF,iBAAtB,CAAA;EAAA,MAMvBJ,CAAAA,EAAAA,MAAAA;EAAa;EAN8B,YAAEI,CAAAA,EAAAA,MAAAA;EAAiB,kBAAA,CAAA,EAAA,MAAA;EAyC7DI,UAAAA,CAAAA,EAAAA,OAAAA;EAAqB,aAAA,CAAA,EAnCtBR,aAmCsB;;;;;;;;;;;AAAwD;;;;;;;;;;;;;;;;;;;;;;;;cAA7EQ,qBAAAA,SAA8BH,SAAAA,YAAqBE;;;;;;;;;gBAStDP;UACNC;;UAEAE;uBACaI;mCACYN,YAAAA,CAAaQ;gBAChCP,cAAcQ,QAAQR"}
@@ -0,0 +1,74 @@
1
+ import { BaseChain, ChainInputs } from "./base.js";
2
+ import { ChainValues } from "@langchain/core/utils/types";
3
+ import { ClientOptions, OpenAIClient } from "@langchain/openai";
4
+ import { AsyncCaller, AsyncCallerParams } from "@langchain/core/utils/async_caller";
5
+
6
+ //#region src/chains/openai_moderation.d.ts
7
+
8
+ /**
9
+ * Interface for the input parameters of the OpenAIModerationChain class.
10
+ */
11
+ interface OpenAIModerationChainInput extends ChainInputs, AsyncCallerParams {
12
+ apiKey?: string;
13
+ /** @deprecated Use "apiKey" instead. */
14
+ openAIApiKey?: string;
15
+ openAIOrganization?: string;
16
+ throwError?: boolean;
17
+ configuration?: ClientOptions;
18
+ }
19
+ /**
20
+ * Class representing a chain for moderating text using the OpenAI
21
+ * Moderation API. It extends the BaseChain class and implements the
22
+ * OpenAIModerationChainInput interface.
23
+ * @example
24
+ * ```typescript
25
+ * const moderation = new OpenAIModerationChain({ throwError: true });
26
+ *
27
+ * const badString = "Bad naughty words from user";
28
+ *
29
+ * try {
30
+ * const { output: moderatedContent, results } = await moderation.call({
31
+ * input: badString,
32
+ * });
33
+ *
34
+ * if (results[0].category_scores["harassment/threatening"] > 0.01) {
35
+ * throw new Error("Harassment detected!");
36
+ * }
37
+ *
38
+ * const model = new OpenAI({ temperature: 0 });
39
+ * const promptTemplate = "Hello, how are you today {person}?";
40
+ * const prompt = new PromptTemplate({
41
+ * template: promptTemplate,
42
+ * inputVariables: ["person"],
43
+ * });
44
+ * const chain = new LLMChain({ llm: model, prompt });
45
+ * const response = await chain.call({ person: moderatedContent });
46
+ * console.log({ response });
47
+ * } catch (error) {
48
+ * console.error("Naughty words detected!");
49
+ * }
50
+ * ```
51
+ */
52
+ declare class OpenAIModerationChain extends BaseChain implements OpenAIModerationChainInput {
53
+ static lc_name(): string;
54
+ get lc_secrets(): {
55
+ [key: string]: string;
56
+ } | undefined;
57
+ inputKey: string;
58
+ outputKey: string;
59
+ openAIApiKey?: string;
60
+ openAIOrganization?: string;
61
+ clientConfig: ClientOptions;
62
+ client: OpenAIClient;
63
+ throwError: boolean;
64
+ caller: AsyncCaller;
65
+ constructor(fields?: OpenAIModerationChainInput);
66
+ _moderate(text: string, results: OpenAIClient.Moderation): string;
67
+ _call(values: ChainValues): Promise<ChainValues>;
68
+ _chainType(): string;
69
+ get inputKeys(): string[];
70
+ get outputKeys(): string[];
71
+ }
72
+ //#endregion
73
+ export { OpenAIModerationChain, OpenAIModerationChainInput };
74
+ //# sourceMappingURL=openai_moderation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openai_moderation.d.ts","names":["ClientOptions","OpenAIClient","ChainValues","AsyncCaller","AsyncCallerParams","BaseChain","ChainInputs","OpenAIModerationChainInput","OpenAIModerationChain","Moderation","Promise"],"sources":["../../src/chains/openai_moderation.d.ts"],"sourcesContent":["import { type ClientOptions, OpenAIClient } from \"@langchain/openai\";\nimport { ChainValues } from \"@langchain/core/utils/types\";\nimport { AsyncCaller, AsyncCallerParams } from \"@langchain/core/utils/async_caller\";\nimport { BaseChain, ChainInputs } from \"./base.js\";\n/**\n * Interface for the input parameters of the OpenAIModerationChain class.\n */\nexport interface OpenAIModerationChainInput extends ChainInputs, AsyncCallerParams {\n apiKey?: string;\n /** @deprecated Use \"apiKey\" instead. */\n openAIApiKey?: string;\n openAIOrganization?: string;\n throwError?: boolean;\n configuration?: ClientOptions;\n}\n/**\n * Class representing a chain for moderating text using the OpenAI\n * Moderation API. It extends the BaseChain class and implements the\n * OpenAIModerationChainInput interface.\n * @example\n * ```typescript\n * const moderation = new OpenAIModerationChain({ throwError: true });\n *\n * const badString = \"Bad naughty words from user\";\n *\n * try {\n * const { output: moderatedContent, results } = await moderation.call({\n * input: badString,\n * });\n *\n * if (results[0].category_scores[\"harassment/threatening\"] > 0.01) {\n * throw new Error(\"Harassment detected!\");\n * }\n *\n * const model = new OpenAI({ temperature: 0 });\n * const promptTemplate = \"Hello, how are you today {person}?\";\n * const prompt = new PromptTemplate({\n * template: promptTemplate,\n * inputVariables: [\"person\"],\n * });\n * const chain = new LLMChain({ llm: model, prompt });\n * const response = await chain.call({ person: moderatedContent });\n * console.log({ response });\n * } catch (error) {\n * console.error(\"Naughty words detected!\");\n * }\n * ```\n */\nexport declare class OpenAIModerationChain extends BaseChain implements OpenAIModerationChainInput {\n static lc_name(): string;\n get lc_secrets(): {\n [key: string]: string;\n } | undefined;\n inputKey: string;\n outputKey: string;\n openAIApiKey?: string;\n openAIOrganization?: string;\n clientConfig: ClientOptions;\n client: OpenAIClient;\n throwError: boolean;\n caller: AsyncCaller;\n constructor(fields?: OpenAIModerationChainInput);\n _moderate(text: string, results: OpenAIClient.Moderation): string;\n _call(values: ChainValues): Promise<ChainValues>;\n _chainType(): string;\n get inputKeys(): string[];\n get outputKeys(): string[];\n}\n"],"mappings":";;;;;;;;;AAOA;AAA2C,UAA1BO,0BAAAA,SAAmCD,WAAT,EAAsBF,iBAAtB,CAAA;EAAA,MAMvBJ,CAAAA,EAAAA,MAAAA;EAAa;EAN8B,YAAEI,CAAAA,EAAAA,MAAAA;EAAiB,kBAAA,CAAA,EAAA,MAAA;EAyC7DI,UAAAA,CAAAA,EAAAA,OAAAA;EAAqB,aAAA,CAAA,EAnCtBR,aAmCsB;;;;;;;;;;;AAAwD;;;;;;;;;;;;;;;;;;;;;;;;cAA7EQ,qBAAAA,SAA8BH,SAAAA,YAAqBE;;;;;;;;;gBAStDP;UACNC;;UAEAE;uBACaI;mCACYN,YAAAA,CAAaQ;gBAChCP,cAAcQ,QAAQR"}
@@ -0,0 +1,106 @@
1
+ import { BaseChain } from "./base.js";
2
+ import { getEnvironmentVariable } from "@langchain/core/utils/env";
3
+ import { OpenAIClient } from "@langchain/openai";
4
+ import { AsyncCaller } from "@langchain/core/utils/async_caller";
5
+
6
+ //#region src/chains/openai_moderation.ts
7
+ /**
8
+ * Class representing a chain for moderating text using the OpenAI
9
+ * Moderation API. It extends the BaseChain class and implements the
10
+ * OpenAIModerationChainInput interface.
11
+ * @example
12
+ * ```typescript
13
+ * const moderation = new OpenAIModerationChain({ throwError: true });
14
+ *
15
+ * const badString = "Bad naughty words from user";
16
+ *
17
+ * try {
18
+ * const { output: moderatedContent, results } = await moderation.call({
19
+ * input: badString,
20
+ * });
21
+ *
22
+ * if (results[0].category_scores["harassment/threatening"] > 0.01) {
23
+ * throw new Error("Harassment detected!");
24
+ * }
25
+ *
26
+ * const model = new OpenAI({ temperature: 0 });
27
+ * const promptTemplate = "Hello, how are you today {person}?";
28
+ * const prompt = new PromptTemplate({
29
+ * template: promptTemplate,
30
+ * inputVariables: ["person"],
31
+ * });
32
+ * const chain = new LLMChain({ llm: model, prompt });
33
+ * const response = await chain.call({ person: moderatedContent });
34
+ * console.log({ response });
35
+ * } catch (error) {
36
+ * console.error("Naughty words detected!");
37
+ * }
38
+ * ```
39
+ */
40
+ var OpenAIModerationChain = class extends BaseChain {
41
+ static lc_name() {
42
+ return "OpenAIModerationChain";
43
+ }
44
+ get lc_secrets() {
45
+ return { openAIApiKey: "OPENAI_API_KEY" };
46
+ }
47
+ inputKey = "input";
48
+ outputKey = "output";
49
+ openAIApiKey;
50
+ openAIOrganization;
51
+ clientConfig;
52
+ client;
53
+ throwError;
54
+ caller;
55
+ constructor(fields) {
56
+ super(fields);
57
+ this.throwError = fields?.throwError ?? false;
58
+ this.openAIApiKey = fields?.apiKey ?? fields?.openAIApiKey ?? getEnvironmentVariable("OPENAI_API_KEY");
59
+ if (!this.openAIApiKey) throw new Error("OpenAI API key not found");
60
+ this.openAIOrganization = fields?.openAIOrganization;
61
+ this.clientConfig = {
62
+ ...fields?.configuration,
63
+ apiKey: this.openAIApiKey,
64
+ organization: this.openAIOrganization
65
+ };
66
+ this.client = new OpenAIClient(this.clientConfig);
67
+ this.caller = new AsyncCaller(fields ?? {});
68
+ }
69
+ _moderate(text, results) {
70
+ if (results.flagged) {
71
+ const errorStr = "Text was found that violates OpenAI's content policy.";
72
+ if (this.throwError) throw new Error(errorStr);
73
+ else return errorStr;
74
+ }
75
+ return text;
76
+ }
77
+ async _call(values) {
78
+ const text = values[this.inputKey];
79
+ const moderationRequest = { input: text };
80
+ let mod;
81
+ try {
82
+ mod = await this.caller.call(() => this.client.moderations.create(moderationRequest));
83
+ } catch (error) {
84
+ if (error instanceof Error) throw error;
85
+ else throw new Error(error);
86
+ }
87
+ const output = this._moderate(text, mod.results[0]);
88
+ return {
89
+ [this.outputKey]: output,
90
+ results: mod.results
91
+ };
92
+ }
93
+ _chainType() {
94
+ return "moderation_chain";
95
+ }
96
+ get inputKeys() {
97
+ return [this.inputKey];
98
+ }
99
+ get outputKeys() {
100
+ return [this.outputKey];
101
+ }
102
+ };
103
+
104
+ //#endregion
105
+ export { OpenAIModerationChain };
106
+ //# sourceMappingURL=openai_moderation.js.map