UNPKG

@langchain/core

Version:
1 lines 7.47 kB
{"version":3,"file":"log_stream.d.cts","names":["Operation","JSONPatchOperation","BaseTracer","Run","BaseCallbackHandler","BaseCallbackHandlerInput","CallbackHandlerPrefersStreaming","HandleLLMNewTokenCallbackFields","IterableReadableStream","StreamEvent","StreamEventData","LogEntry","Record","RunState","RunLogPatch","RunLog","SchemaFormat","LogStreamCallbackHandlerInput","isLogStreamHandler","LogStreamCallbackHandler","TransformStream","WritableStreamDefaultWriter","Symbol","asyncIterator","Promise","T","AsyncGenerator"],"sources":["../../src/tracers/log_stream.d.ts"],"sourcesContent":["import { type Operation as JSONPatchOperation } from \"../utils/fast-json-patch/index.js\";\nimport { BaseTracer, type Run } from \"./base.js\";\nimport { BaseCallbackHandler, BaseCallbackHandlerInput, CallbackHandlerPrefersStreaming, HandleLLMNewTokenCallbackFields } from \"../callbacks/base.js\";\nimport { IterableReadableStream } from \"../utils/stream.js\";\nimport type { StreamEvent, StreamEventData } from \"./event_stream.js\";\nexport type { StreamEvent, StreamEventData };\n/**\n * Interface that represents the structure of a log entry in the\n * `LogStreamCallbackHandler`.\n */\nexport type LogEntry = {\n /** ID of the sub-run. */\n id: string;\n /** Name of the object being run. */\n name: string;\n /** Type of the object being run, eg. prompt, chain, llm, etc. */\n type: string;\n /** List of tags for the run. */\n tags: string[];\n /** Key-value pairs of metadata for the run. */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n metadata: Record<string, any>;\n /** ISO-8601 timestamp of when the run started. */\n start_time: string;\n /** List of general output chunks streamed by this run. */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n streamed_output: any[];\n /** List of LLM tokens streamed by this run, if applicable. */\n streamed_output_str: string[];\n /** Inputs to this run. Not available currently via streamLog. */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n inputs?: any;\n /** Final output of this run. Only available after the run has finished successfully. */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n final_output?: any;\n /** ISO-8601 timestamp of when the run ended. Only available after the run has finished. */\n end_time?: string;\n};\nexport type RunState = {\n /** ID of the sub-run. */\n id: string;\n /** List of output chunks streamed by Runnable.stream() */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n streamed_output: any[];\n /** Final output of the run, usually the result of aggregating streamed_output. Only available after the run has finished successfully. */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n final_output?: any;\n /**\n * List of sub-runs contained in this run, if any, in the order they were started.\n * If filters were supplied, this list will contain only the runs that matched the filters.\n */\n logs: Record<string, LogEntry>;\n /** Name of the object being run. */\n name: string;\n /** Type of the object being run, eg. prompt, chain, llm, etc. */\n type: string;\n};\n/**\n * List of jsonpatch JSONPatchOperations, which describe how to create the run state\n * from an empty dict. This is the minimal representation of the log, designed to\n * be serialized as JSON and sent over the wire to reconstruct the log on the other\n * side. Reconstruction of the state can be done with any jsonpatch-compliant library,\n * see https://jsonpatch.com for more information.\n */\nexport declare class RunLogPatch {\n ops: JSONPatchOperation[];\n constructor(fields: {\n ops?: JSONPatchOperation[];\n });\n concat(other: RunLogPatch): RunLog;\n}\nexport declare class RunLog extends RunLogPatch {\n state: RunState;\n constructor(fields: {\n ops?: JSONPatchOperation[];\n state: RunState;\n });\n concat(other: RunLogPatch): RunLog;\n static fromRunLogPatch(patch: RunLogPatch): RunLog;\n}\nexport type SchemaFormat = \"original\" | \"streaming_events\";\nexport interface LogStreamCallbackHandlerInput extends BaseCallbackHandlerInput {\n autoClose?: boolean;\n includeNames?: string[];\n includeTypes?: string[];\n includeTags?: string[];\n excludeNames?: string[];\n excludeTypes?: string[];\n excludeTags?: string[];\n _schemaFormat?: SchemaFormat;\n}\nexport declare const isLogStreamHandler: (handler: BaseCallbackHandler) => handler is LogStreamCallbackHandler;\n/**\n * Class that extends the `BaseTracer` class from the\n * `langchain.callbacks.tracers.base` module. It represents a callback\n * handler that logs the execution of runs and emits `RunLog` instances to a\n * `RunLogStream`.\n */\nexport declare class LogStreamCallbackHandler extends BaseTracer implements CallbackHandlerPrefersStreaming {\n protected autoClose: boolean;\n protected includeNames?: string[];\n protected includeTypes?: string[];\n protected includeTags?: string[];\n protected excludeNames?: string[];\n protected excludeTypes?: string[];\n protected excludeTags?: string[];\n protected _schemaFormat: SchemaFormat;\n protected rootId?: string;\n private keyMapByRunId;\n private counterMapByRunName;\n protected transformStream: TransformStream;\n writer: WritableStreamDefaultWriter;\n receiveStream: IterableReadableStream<RunLogPatch>;\n name: string;\n lc_prefer_streaming: boolean;\n constructor(fields?: LogStreamCallbackHandlerInput);\n [Symbol.asyncIterator](): IterableReadableStream<RunLogPatch>;\n protected persistRun(_run: Run): Promise<void>;\n _includeRun(run: Run): boolean;\n tapOutputIterable<T>(runId: string, output: AsyncGenerator<T>): AsyncGenerator<T>;\n onRunCreate(run: Run): Promise<void>;\n onRunUpdate(run: Run): Promise<void>;\n onLLMNewToken(run: Run, token: string, kwargs?: HandleLLMNewTokenCallbackFields): Promise<void>;\n}\n"],"mappings":";;;;;;;;;AAUA;AA4BA;;AAayBW,KAzCbA,QAAAA,GAyCaA;EAAQ;EAAjB,EAAA,EAAA,MAAA;EAaKG;EAAW,IAAA,EAAA,MAAA;EAAA;EACL,IAEbb,EAAAA,MAAAA;EAAkB;EAEH,IAAGc,EAAAA,MAAAA,EAAAA;EAAM;EAEjBA;EAAM,QAAA,EAlDbH,MAkDa,CAAA,MAAA,EAAA,GAAA,CAAA;EAAA;EACR,UAELX,EAAAA,MAAAA;EAAkB;EACT;EAEM,eAAGc,EAAAA,GAAAA,EAAAA;EAAM;EACO,mBAAGA,EAAAA,MAAAA,EAAAA;EAAM;EAPP;EASnCC,MAAAA,CAAAA,EAAAA,GAAAA;EACKC;EAA6B;EAAA,YAQ1BD,CAAAA,EAAAA,GAAAA;EAAY;EAR+C,QAAA,CAAA,EAAA,MAAA;AAU/E,CAAA;AAA8G,KArDlGH,QAAAA,GAqDkG;EAAA;EAAxC,EAAA,EAAgBM,MAAAA;EAAwB;EAOzFA;EAAwB,eAAA,EAAA,GAAA,EAAA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