@langchain/core
Version:
Core LangChain.js abstractions and schemas
1 lines • 6.96 kB
Source Map (JSON)
{"version":3,"file":"log_stream.d.ts","names":["Operation","JSONPatchOperation","BaseTracer","Run","BaseCallbackHandler","BaseCallbackHandlerInput","CallbackHandlerPrefersStreaming","HandleLLMNewTokenCallbackFields","IterableReadableStream","StreamEvent","StreamEventData","LogEntry","Record","RunState","RunLogPatch","RunLog","SchemaFormat","LogStreamCallbackHandlerInput","isLogStreamHandler","LogStreamCallbackHandler","T","TransformStream","WritableStreamDefaultWriter","Symbol","asyncIterator","Promise","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 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 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 inputs?: any;\n /** Final output of this run. Only available after the run has finished successfully. */\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 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 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//# sourceMappingURL=log_stream.d.ts.map"],"mappings":";;;;;;;;;AAUA;AAwBA;AAwBA;AACSC,KAjDGU,QAAAA,GAiDHV;EAEKA;EAEIa,EAAAA,EAAAA,MAAAA;EAAcC;EAAM,IAAA,EAAA,MAAA;EAEjBA;EACVF,IAAAA,EAAAA,MAAAA;EAEGZ;EACCY,IAAAA,EAAAA,MAAAA,EAAAA;EAEGC;EAAcC,QAAAA,EAnDlBH,MAmDkBG,CAAAA,MAAAA,EAAAA,GAAAA,CAAAA;EACED;EAAcC,UAAAA,EAAAA,MAAAA;EAPZD;EAAW,eAAA,EAAA,GAAA,EAAA;EASnCE;EACKC,mBAAAA,EAAAA,MAAAA,EAAAA;EAUIC;EAOAC,MAAAA,CAAAA,EAAAA,GAAAA;EAQQH;EAIEK,YAAAA,CAAAA,EAAAA,GAAAA;EACnBC;EAC8BR,QAAAA,CAAAA,EAAAA,MAAAA;CAAvBN;AAGMS,KA3EbJ,QAAAA,GA2EaI;EAC4BH;EAAvBN,EAAAA,EAAAA,MAAAA;EAAzBe;EAC0BpB,eAAAA,EAAAA,GAAAA,EAAAA;EAAMsB;EAChBtB,YAAAA,CAAAA,EAAAA,GAAAA;EAC0CiB;;;;EAC1CjB,IAAAA,EArEXS,MAqEWT,CAAAA,MAAAA,EArEIQ,QAqEJR,CAAAA;EAAMsB;EACNtB,I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