console.d.ts 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. import { BaseTracer, type Run } from "./base.js";
  2. /**
  3. * A tracer that logs all events to the console. It extends from the
  4. * `BaseTracer` class and overrides its methods to provide custom logging
  5. * functionality.
  6. * @example
  7. * ```typescript
  8. *
  9. * const llm = new ChatAnthropic({
  10. * temperature: 0,
  11. * tags: ["example", "callbacks", "constructor"],
  12. * callbacks: [new ConsoleCallbackHandler()],
  13. * });
  14. *
  15. * ```
  16. */
  17. export declare class ConsoleCallbackHandler extends BaseTracer {
  18. name: "console_callback_handler";
  19. /**
  20. * Method used to persist the run. In this case, it simply returns a
  21. * resolved promise as there's no persistence logic.
  22. * @param _run The run to persist.
  23. * @returns A resolved promise.
  24. */
  25. protected persistRun(_run: Run): Promise<void>;
  26. /**
  27. * Method used to get all the parent runs of a given run.
  28. * @param run The run whose parents are to be retrieved.
  29. * @returns An array of parent runs.
  30. */
  31. getParents(run: Run): Run[];
  32. /**
  33. * Method used to get a string representation of the run's lineage, which
  34. * is used in logging.
  35. * @param run The run whose lineage is to be retrieved.
  36. * @returns A string representation of the run's lineage.
  37. */
  38. getBreadcrumbs(run: Run): string;
  39. /**
  40. * Method used to log the start of a chain run.
  41. * @param run The chain run that has started.
  42. * @returns void
  43. */
  44. onChainStart(run: Run): void;
  45. /**
  46. * Method used to log the end of a chain run.
  47. * @param run The chain run that has ended.
  48. * @returns void
  49. */
  50. onChainEnd(run: Run): void;
  51. /**
  52. * Method used to log any errors of a chain run.
  53. * @param run The chain run that has errored.
  54. * @returns void
  55. */
  56. onChainError(run: Run): void;
  57. /**
  58. * Method used to log the start of an LLM run.
  59. * @param run The LLM run that has started.
  60. * @returns void
  61. */
  62. onLLMStart(run: Run): void;
  63. /**
  64. * Method used to log the end of an LLM run.
  65. * @param run The LLM run that has ended.
  66. * @returns void
  67. */
  68. onLLMEnd(run: Run): void;
  69. /**
  70. * Method used to log any errors of an LLM run.
  71. * @param run The LLM run that has errored.
  72. * @returns void
  73. */
  74. onLLMError(run: Run): void;
  75. /**
  76. * Method used to log the start of a tool run.
  77. * @param run The tool run that has started.
  78. * @returns void
  79. */
  80. onToolStart(run: Run): void;
  81. /**
  82. * Method used to log the end of a tool run.
  83. * @param run The tool run that has ended.
  84. * @returns void
  85. */
  86. onToolEnd(run: Run): void;
  87. /**
  88. * Method used to log any errors of a tool run.
  89. * @param run The tool run that has errored.
  90. * @returns void
  91. */
  92. onToolError(run: Run): void;
  93. /**
  94. * Method used to log the start of a retriever run.
  95. * @param run The retriever run that has started.
  96. * @returns void
  97. */
  98. onRetrieverStart(run: Run): void;
  99. /**
  100. * Method used to log the end of a retriever run.
  101. * @param run The retriever run that has ended.
  102. * @returns void
  103. */
  104. onRetrieverEnd(run: Run): void;
  105. /**
  106. * Method used to log any errors of a retriever run.
  107. * @param run The retriever run that has errored.
  108. * @returns void
  109. */
  110. onRetrieverError(run: Run): void;
  111. /**
  112. * Method used to log the action selected by the agent.
  113. * @param run The run in which the agent action occurred.
  114. * @returns void
  115. */
  116. onAgentAction(run: Run): void;
  117. }