index
int64
0
0
repo_id
stringclasses
596 values
file_path
stringlengths
31
168
content
stringlengths
1
6.2M
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/tracers/event_stream.ts
import { BaseTracer, type Run } from "./base.js"; import { BaseCallbackHandler, BaseCallbackHandlerInput, } from "../callbacks/base.js"; import { IterableReadableStream } from "../utils/stream.js"; import { AIMessageChunk } from "../messages/ai.js"; import { ChatGeneration, Generation, GenerationChunk } from "../ou...
0
lc_public_repos/langchainjs/langchain-core/src/tracers
lc_public_repos/langchainjs/langchain-core/src/tracers/tests/langsmith_interop.test.ts
/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable no-process-env */ /* eslint-disable no-promise-executor-return */ import { jest, test, beforeEach, afterEach, afterAll, expect, } from "@jest/globals"; import { traceable } from "langsmith/traceable"; import { Client } from "langsmit...
0
lc_public_repos/langchainjs/langchain-core/src/tracers
lc_public_repos/langchainjs/langchain-core/src/tracers/tests/tracer.test.ts
import { test, expect, jest } from "@jest/globals"; import * as uuid from "uuid"; import { Serialized } from "../../load/serializable.js"; import { Document } from "../../documents/document.js"; import { Run } from "../base.js"; import { HumanMessage } from "../../messages/index.js"; import { FakeTracer } from "../../u...
0
lc_public_repos/langchainjs/langchain-core/src/tracers
lc_public_repos/langchainjs/langchain-core/src/tracers/tests/langchain_tracer.int.test.ts
/* eslint-disable no-process-env */ import * as uuid from "uuid"; import { test, expect } from "@jest/globals"; import { LangChainTracer, Run } from "../tracer_langchain.js"; import { Serialized } from "../../load/serializable.js"; import { HumanMessage } from "../../messages/index.js"; const serialized: Serialized =...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/structured_query/index.ts
export * from "./base.js"; export * from "./functional.js"; export * from "./ir.js"; export * from "./utils.js";
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/structured_query/base.ts
import { VectorStore } from "../vectorstores.js"; import { Comparator, Comparators, Comparison, Operation, Operator, Operators, StructuredQuery, Visitor, VisitorComparisonResult, VisitorOperationResult, VisitorResult, VisitorStructuredQueryResult, } from "./ir.js"; import { isFilterEmpty, castVa...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/structured_query/ir.ts
import { VectorStore } from "../vectorstores.js"; /** * Represents logical AND operator. */ export type AND = "and"; /** * Represents logical OR operator. */ export type OR = "or"; /** * Represents logical NOT operator. */ export type NOT = "not"; /** * Represents a logical operator which can be AND, OR, or NO...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/structured_query/utils.ts
/** * Checks if the provided argument is an object and not an array. */ // eslint-disable-next-line @typescript-eslint/no-explicit-any export function isObject(obj: any): obj is object { return obj && typeof obj === "object" && !Array.isArray(obj); } /** * Checks if a provided filter is empty. The filter can be a...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/structured_query/functional.ts
import { Document } from "../documents/document.js"; import { Comparator, Comparators, Comparison, Operation, Operator, Operators, StructuredQuery, } from "./ir.js"; import { BaseTranslator } from "./base.js"; import { castValue, isFilterEmpty } from "./utils.js"; /** * A type alias for an object that m...
0
lc_public_repos/langchainjs/langchain-core/src/structured_query
lc_public_repos/langchainjs/langchain-core/src/structured_query/tests/utils.test.ts
/* eslint-disable no-process-env */ import { test, expect } from "@jest/globals"; import { castValue, isFloat, isInt, isString } from "../utils.js"; test("Casting values correctly", () => { const stringString = [ "string", "test", "this is a string", " ", "\n\n\n\n\n\n", `asdf zxcv...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/errors/index.ts
/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable no-param-reassign */ export type LangChainErrorCodes = | "INVALID_PROMPT_INPUT" | "INVALID_TOOL_RESULTS" | "MESSAGE_COERCION_FAILURE" | "MODEL_AUTHENTICATION" | "MODEL_NOT_FOUND" | "MODEL_RATE_LIMIT" | "OUTPUT_PARSING_FAILURE"; ex...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/example_selectors/conditional.ts
import type { BaseChatModel } from "../language_models/chat_models.js"; import type { BasePromptTemplate } from "../prompts/base.js"; import type { BaseLanguageModelInterface } from "../language_models/base.js"; import type { BaseLLM } from "../language_models/llms.js"; import type { PartialValues } from "../utils/type...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/example_selectors/length_based.ts
import { Example } from "../prompts/base.js"; import { BaseExampleSelector } from "./base.js"; import { PromptTemplate } from "../prompts/prompt.js"; /** * Calculates the length of a text based on the number of words and lines. */ function getLengthBased(text: string): number { return text.split(/\n| /).length; } ...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/example_selectors/index.ts
export * from "./base.js"; export * from "./conditional.js"; export * from "./length_based.js"; export * from "./semantic_similarity.js";
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/example_selectors/base.ts
import { Serializable } from "../load/serializable.js"; import type { Example } from "../prompts/base.js"; /** * Base class for example selectors. */ export abstract class BaseExampleSelector extends Serializable { lc_namespace = ["langchain_core", "example_selectors", "base"]; /** * Adds an example to the e...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/example_selectors/semantic_similarity.ts
import type { Embeddings } from "../embeddings.js"; import type { VectorStoreInterface, VectorStoreRetrieverInterface, VectorStore, } from "../vectorstores.js"; import type { Example } from "../prompts/base.js"; import { Document } from "../documents/document.js"; import { BaseExampleSelector } from "./base.js"; ...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/runnables/wrappers.ts
import { IterableReadableStream } from "../utils/stream.js"; export function convertToHttpEventStream(stream: AsyncGenerator) { const encoder = new TextEncoder(); const finalStream = new ReadableStream<Uint8Array>({ async start(controller) { for await (const chunk of stream) { controller.enqueue(...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/runnables/branch.ts
import { Runnable, RunnableLike, _coerceToDict, _coerceToRunnable, } from "./base.js"; import { RunnableConfig, getCallbackManagerForConfig, patchConfig, } from "./config.js"; import { CallbackManagerForChainRun } from "../callbacks/manager.js"; import { concat } from "../utils/stream.js"; /** * Type fo...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/runnables/history.ts
import { BaseChatMessageHistory, BaseListChatMessageHistory, } from "../chat_history.js"; import { AIMessage, BaseMessage, HumanMessage, isBaseMessage, } from "../messages/index.js"; import { Run } from "../tracers/base.js"; import { Runnable, RunnableBinding, type RunnableBindingArgs, RunnableLambd...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/runnables/types.ts
import type { z } from "zod"; import type { SerializableInterface } from "../load/serializable.js"; import type { BaseCallbackConfig } from "../callbacks/manager.js"; import type { IterableReadableStreamInterface } from "../types/stream.js"; export type RunnableBatchOptions = { /** @deprecated Pass in via the standa...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/runnables/iter.ts
import type { RunnableConfig } from "../runnables/types.js"; import { AsyncLocalStorageProviderSingleton } from "../singletons/index.js"; import { pickRunnableConfigKeys } from "./config.js"; export function isIterableIterator( thing: unknown ): thing is IterableIterator<unknown> { return ( typeof thing === "o...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/runnables/router.ts
import { Runnable, type RunnableBatchOptions } from "./base.js"; import { IterableReadableStream } from "../utils/stream.js"; import { ensureConfig, type RunnableConfig } from "./config.js"; export type RouterInput = { key: string; // eslint-disable-next-line @typescript-eslint/no-explicit-any input: any; }; /*...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/runnables/config.ts
import { CallbackManager, ensureHandler } from "../callbacks/manager.js"; import { AsyncLocalStorageProviderSingleton } from "../singletons/index.js"; import { RunnableConfig } from "./types.js"; export const DEFAULT_RECURSION_LIMIT = 25; export { type RunnableConfig }; export async function getCallbackManagerForCon...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/runnables/index.ts
export { type RunnableFunc, type RunnableLike, type RunnableRetryFailedAttemptHandler, Runnable, type RunnableBindingArgs, RunnableBinding, RunnableEach, RunnableRetry, RunnableSequence, RunnableMap, RunnableParallel, RunnableLambda, RunnableWithFallbacks, RunnableAssign, RunnablePick, _...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/runnables/graph_mermaid.ts
import { Edge, Node } from "./types.js"; function _escapeNodeLabel(nodeLabel: string): string { // Escapes the node label for Mermaid syntax. return nodeLabel.replace(/[^a-zA-Z-_0-9]/g, "_"); } const MARKDOWN_SPECIAL_CHARS = ["*", "_", "`"]; function _generateMermaidGraphStyles( nodeColors: Record<string, stri...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/runnables/base.ts
import { z } from "zod"; import pRetry from "p-retry"; import { v4 as uuidv4 } from "uuid"; import { type TraceableFunction, isTraceableFunction, } from "langsmith/singletons/traceable"; import type { RunnableInterface, RunnableBatchOptions, RunnableConfig, } from "./types.js"; import { CallbackManagerForCha...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/runnables/graph.ts
import { zodToJsonSchema } from "zod-to-json-schema"; import { v4 as uuidv4, validate as isUuid } from "uuid"; import type { RunnableInterface, RunnableIOSchema, Node, Edge, } from "./types.js"; import { isRunnableInterface } from "./utils.js"; import { drawMermaid, drawMermaidPng } from "./graph_mermaid.js"; ...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/runnables/utils.ts
import { StreamEvent } from "../tracers/event_stream.js"; import type { RunnableInterface } from "./types.js"; // eslint-disable-next-line @typescript-eslint/no-explicit-any export function isRunnableInterface(thing: any): thing is RunnableInterface { return thing ? thing.lc_runnable : false; } /** * Utility to fi...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/runnables/remote.ts
import { Runnable, RunnableBatchOptions, _coerceToDict } from "./base.js"; import { getCallbackManagerForConfig, type RunnableConfig } from "./config.js"; import { Document } from "../documents/index.js"; import { CallbackManagerForChainRun } from "../callbacks/manager.js"; import { ChatPromptValue, StringPromptValue }...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/runnables/passthrough.ts
import { concat } from "../utils/stream.js"; import { Runnable, RunnableAssign, RunnableMap, RunnableMapLike, } from "./base.js"; import { ensureConfig, type RunnableConfig } from "./config.js"; // eslint-disable-next-line @typescript-eslint/no-explicit-any type RunnablePassthroughFunc<RunInput = any> = | ((...
0
lc_public_repos/langchainjs/langchain-core/src/runnables
lc_public_repos/langchainjs/langchain-core/src/runnables/tests/runnable_passthrough.test.ts
import { test, expect } from "@jest/globals"; import { PromptTemplate } from "../../prompts/prompt.js"; import { FakeChatModel } from "../../utils/testing/index.js"; import { RunnablePassthrough } from "../passthrough.js"; import { JsonOutputParser } from "../../output_parsers/json.js"; import { RunnableSequence } from...
0
lc_public_repos/langchainjs/langchain-core/src/runnables
lc_public_repos/langchainjs/langchain-core/src/runnables/tests/runnable_stream_log.test.ts
/* eslint-disable no-promise-executor-return */ /* eslint-disable @typescript-eslint/no-explicit-any */ import { test, expect } from "@jest/globals"; import { ChatPromptTemplate, HumanMessagePromptTemplate, PromptTemplate, SystemMessagePromptTemplate, } from "../../prompts/index.js"; import { Document } from "...
0
lc_public_repos/langchainjs/langchain-core/src/runnables
lc_public_repos/langchainjs/langchain-core/src/runnables/tests/runnable_with_fallbacks.test.ts
/* eslint-disable no-promise-executor-return */ /* eslint-disable @typescript-eslint/no-explicit-any */ import { test, expect } from "@jest/globals"; import { FakeLLM, FakeStreamingLLM } from "../../utils/testing/index.js"; test("RunnableWithFallbacks", async () => { const llm = new FakeLLM({ thrownErrorString: ...
0
lc_public_repos/langchainjs/langchain-core/src/runnables
lc_public_repos/langchainjs/langchain-core/src/runnables/tests/runnable_remote.int.test.ts
import { test, expect } from "@jest/globals"; import { HumanMessage } from "../../messages/index.js"; import { applyPatch } from "../../utils/json_patch.js"; import { RemoteRunnable } from "../remote.js"; test("invoke hosted langserve", async () => { const remote = new RemoteRunnable({ url: `https://chat-langcha...
0
lc_public_repos/langchainjs/langchain-core/src/runnables
lc_public_repos/langchainjs/langchain-core/src/runnables/tests/runnable_interface.test.ts
/* eslint-disable no-promise-executor-return */ /* eslint-disable @typescript-eslint/no-explicit-any */ import { test, expect } from "@jest/globals"; import { StringOutputParser } from "../../output_parsers/string.js"; import { PromptTemplate } from "../../prompts/prompt.js"; import { RunnableSequence } from "../base....
0
lc_public_repos/langchainjs/langchain-core/src/runnables
lc_public_repos/langchainjs/langchain-core/src/runnables/tests/runnable_remote.test.ts
/* eslint-disable no-promise-executor-return */ /* eslint-disable @typescript-eslint/no-explicit-any */ import { jest, test, expect, describe, beforeEach, afterEach, } from "@jest/globals"; import { AIMessage, AIMessageChunk, HumanMessage, SystemMessage, } from "../../messages/index.js"; import { R...
0
lc_public_repos/langchainjs/langchain-core/src/runnables
lc_public_repos/langchainjs/langchain-core/src/runnables/tests/runnable_map.test.ts
/* eslint-disable no-promise-executor-return */ /* eslint-disable @typescript-eslint/no-explicit-any */ import { test, expect } from "@jest/globals"; import { StringOutputParser } from "../../output_parsers/string.js"; import { ChatPromptTemplate, SystemMessagePromptTemplate, HumanMessagePromptTemplate, } from "...
0
lc_public_repos/langchainjs/langchain-core/src/runnables
lc_public_repos/langchainjs/langchain-core/src/runnables/tests/runnable_tools.test.ts
import { z } from "zod"; import { test, expect } from "@jest/globals"; import { RunnableLambda, RunnableToolLike } from "../base.js"; import { FakeRetriever } from "../../utils/testing/index.js"; import { Document } from "../../documents/document.js"; test("Runnable asTool works", async () => { const schema = z.obje...
0
lc_public_repos/langchainjs/langchain-core/src/runnables
lc_public_repos/langchainjs/langchain-core/src/runnables/tests/runnable_stream_events.test.ts
/* eslint-disable no-promise-executor-return */ /* eslint-disable no-process-env */ /* eslint-disable @typescript-eslint/no-explicit-any */ import { test, expect, afterEach } from "@jest/globals"; import { z } from "zod"; import { RunnableLambda, RunnableMap, RunnablePassthrough, RunnablePick, } from "../index...
0
lc_public_repos/langchainjs/langchain-core/src/runnables
lc_public_repos/langchainjs/langchain-core/src/runnables/tests/runnable_tracing.int.test.ts
import { Client } from "langsmith"; import { test } from "@jest/globals"; import { LangChainTracer } from "../../tracers/tracer_langchain.js"; import { BaseOutputParser, FormatInstructionsOptions, } from "../../output_parsers/base.js"; import { FakeChatModel } from "../../utils/testing/index.js"; import { getEnviro...
0
lc_public_repos/langchainjs/langchain-core/src/runnables
lc_public_repos/langchainjs/langchain-core/src/runnables/tests/runnable_graph.test.ts
/* eslint-disable no-promise-executor-return */ /* eslint-disable @typescript-eslint/no-explicit-any */ import { test, expect } from "@jest/globals"; import { StringOutputParser } from "../../output_parsers/string.js"; import { FakeLLM } from "../../utils/testing/index.js"; import { PromptTemplate } from "../../prompts...
0
lc_public_repos/langchainjs/langchain-core/src/runnables
lc_public_repos/langchainjs/langchain-core/src/runnables/tests/runnable.test.ts
/* eslint-disable no-promise-executor-return */ /* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-unused-vars */ import { Run } from "langsmith"; import { v4 as uuidv4 } from "uuid"; import { jest, test, expect, describe } from "@jest/globals"; import { createChatMessageCh...
0
lc_public_repos/langchainjs/langchain-core/src/runnables
lc_public_repos/langchainjs/langchain-core/src/runnables/tests/runnable_branch.test.ts
/* eslint-disable no-promise-executor-return */ /* eslint-disable @typescript-eslint/no-explicit-any */ import { test, expect } from "@jest/globals"; import { RunnableBranch } from "../branch.js"; import { ChatPromptTemplate } from "../../prompts/chat.js"; import { FakeStreamingLLM } from "../../utils/testing/index.js...
0
lc_public_repos/langchainjs/langchain-core/src/runnables
lc_public_repos/langchainjs/langchain-core/src/runnables/tests/runnable_binding.test.ts
/* eslint-disable no-promise-executor-return */ /* eslint-disable @typescript-eslint/no-explicit-any */ import { test, expect } from "@jest/globals"; import { StringOutputParser } from "../../output_parsers/string.js"; import { FakeChatModel, FakeStreamingLLM } from "../../utils/testing/index.js"; test("Bind kwargs to...
0
lc_public_repos/langchainjs/langchain-core/src/runnables
lc_public_repos/langchainjs/langchain-core/src/runnables/tests/runnable_history.test.ts
import { test, expect } from "@jest/globals"; import { AIMessage, AIMessageChunk, BaseMessage, HumanMessage, } from "../../messages/index.js"; import { RunnableLambda } from "../base.js"; import { RunnableConfig } from "../config.js"; import { RunnableWithMessageHistory } from "../history.js"; import { BaseCh...
0
lc_public_repos/langchainjs/langchain-core/src/runnables
lc_public_repos/langchainjs/langchain-core/src/runnables/tests/runnable_stream_events_v2.test.ts
/* eslint-disable no-promise-executor-return */ /* eslint-disable no-process-env */ /* eslint-disable @typescript-eslint/no-explicit-any */ import { test, expect, afterEach } from "@jest/globals"; import { z } from "zod"; import { AsyncLocalStorage } from "node:async_hooks"; import { RunnableLambda, RunnableMap, ...
0
lc_public_repos/langchainjs/langchain-core/src/runnables
lc_public_repos/langchainjs/langchain-core/src/runnables/tests/signal.test.ts
/* eslint-disable no-promise-executor-return */ /* eslint-disable @typescript-eslint/no-explicit-any */ import { test, describe, expect } from "@jest/globals"; import { Runnable, RunnableLambda, RunnableMap, RunnablePassthrough, RunnableSequence, RunnableWithMessageHistory, } from "../index.js"; import { ...
0
lc_public_repos/langchainjs/langchain-core/src/runnables
lc_public_repos/langchainjs/langchain-core/src/runnables/tests/runnable_retry.test.ts
/* eslint-disable no-promise-executor-return */ /* eslint-disable @typescript-eslint/no-explicit-any */ import { test, expect } from "@jest/globals"; import { RunnableLambda } from "../base.js"; test("RunnableRetry invoke", async () => { let attemptCount = 0; const runnable = new RunnableLambda({ func: (_thin...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/types/type-utils.ts
// Utility for marking only some keys of an interface as optional // Compare to Partial<T> which marks all keys as optional export type Optional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/types/stream.ts
// Make this a type to override ReadableStream's async iterator type in case // the popular web-streams-polyfill is imported - the supplied types // in that case don't quite match. export type IterableReadableStreamInterface<T> = ReadableStream<T> & AsyncIterable<T>;
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/load/serializable.ts
import { type SerializedFields, keyToJson, mapKeys } from "./map_keys.js"; export interface BaseSerialized<T extends string> { lc: number; type: T; id: string[]; name?: string; // eslint-disable-next-line @typescript-eslint/no-explicit-any graph?: Record<string, any>; } export interface SerializedConstruc...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/load/import_constants.ts
// Auto-generated by `scripts/create-entrypoints.js`. Do not edit manually. export const optionalImportEntrypoints: string[] = [];
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/load/map_keys.ts
import snakeCase from "decamelize"; import camelCase from "camelcase"; export interface SerializedFields { // eslint-disable-next-line @typescript-eslint/no-explicit-any [key: string]: any; } export interface SerializedKeyAlias { [key: string]: string; } export function keyToJson(key: string, map?: SerializedK...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/load/import_type.ts
// Auto-generated by `scripts/create-entrypoints.js`. Do not edit manually. export interface OptionalImportMap {} export interface SecretMap { }
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/load/import_map.ts
// Auto-generated by `scripts/create-entrypoints.js`. Do not edit manually. export * as agents from "../agents.js"; export * as caches from "../caches/base.js"; export * as callbacks__base from "../callbacks/base.js"; export * as callbacks__manager from "../callbacks/manager.js"; export * as callbacks__promises from "...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/load/index.ts
import { Serializable, SerializedConstructor, SerializedNotImplemented, SerializedSecret, get_lc_unique_name, } from "./serializable.js"; import { optionalImportEntrypoints as defaultOptionalImportEntrypoints } from "./import_constants.js"; import * as coreImportMap from "./import_map.js"; import type { Optio...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/caches/base.ts
import { insecureHash } from "../utils/hash.js"; import type { Generation, ChatGeneration } from "../outputs.js"; import { mapStoredMessageToChatMessage } from "../messages/utils.js"; import { type StoredGeneration } from "../messages/base.js"; /** * This cache key should be consistent across all versions of LangChai...
0
lc_public_repos/langchainjs/langchain-core/src/caches
lc_public_repos/langchainjs/langchain-core/src/caches/tests/in_memory_cache.test.ts
import { test, expect } from "@jest/globals"; import { MessageContentComplex } from "../../messages/base.js"; import { InMemoryCache } from "../base.js"; test("InMemoryCache works", async () => { const cache = new InMemoryCache(); await cache.update("prompt", "key1", [ { text: "text1", }, ]); c...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/prompts/image.ts
import { MessageContent, MessageContentComplex } from "../messages/index.js"; import { ImagePromptValue, ImageContent } from "../prompt_values.js"; import type { InputValues, PartialValues } from "../utils/types/index.js"; import { BasePromptTemplate, BasePromptTemplateInput, TypedPromptInputValues, } from "./bas...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/prompts/chat.ts
// Default generic "any" values are for backwards compatibility. // Replace with "string" when we are comfortable with a breaking change. import type { BaseCallbackConfig } from "../callbacks/manager.js"; import { AIMessage, HumanMessage, SystemMessage, BaseMessage, ChatMessage, type BaseMessageLike, coe...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/prompts/string.ts
// Default generic "any" values are for backwards compatibility. // Replace with "string" when we are comfortable with a breaking change. import type { InputValues } from "../utils/types/index.js"; import { type StringPromptValueInterface, StringPromptValue, } from "../prompt_values.js"; import { BasePromptTemplat...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/prompts/structured.ts
import { ChatPromptValueInterface } from "../prompt_values.js"; import { RunnableLike, Runnable, type RunnableBinding, } from "../runnables/base.js"; import { RunnableConfig } from "../runnables/config.js"; import { InputValues } from "../utils/types/index.js"; import { BaseMessagePromptTemplateLike, ChatProm...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/prompts/template.ts
import mustache from "mustache"; import { MessageContent } from "../messages/index.js"; import type { InputValues } from "../utils/types/index.js"; import { addLangChainErrorFields } from "../errors/index.js"; function configureMustache() { // Use unescaped HTML // https://github.com/janl/mustache.js?tab=readme-ov...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/prompts/serde.ts
import { MessageContent } from "../messages/index.js"; import type { TemplateFormat } from "./template.js"; /** * Represents a serialized version of a prompt template. This type is used * to create dynamic prompts for language models. It contains an optional * `_type` field which, if present, is set to 'prompt'. It...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/prompts/index.ts
export * from "./base.js"; export * from "./chat.js"; export * from "./few_shot.js"; export * from "./pipeline.js"; export * from "./prompt.js"; export * from "./serde.js"; export * from "./string.js"; export * from "./template.js"; export * from "./image.js"; export * from "./structured.js";
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/prompts/few_shot.ts
import { BaseStringPromptTemplate } from "./string.js"; import type { BasePromptTemplateInput, TypedPromptInputValues, Example, } from "./base.js"; import type { BaseExampleSelector } from "../example_selectors/base.js"; import { type TemplateFormat, checkValidTemplate, renderTemplate, } from "./template.js...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/prompts/base.ts
// Default generic "any" values are for backwards compatibility. // Replace with "string" when we are comfortable with a breaking change. import type { InputValues, PartialValues, StringWithAutocomplete, } from "../utils/types/index.js"; import { type BasePromptValueInterface } from "../prompt_values.js"; import...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/prompts/pipeline.ts
import type { InputValues, PartialValues } from "../utils/types/index.js"; import type { SerializedBasePromptTemplate } from "./serde.js"; import { BasePromptTemplate, type BasePromptTemplateInput } from "./base.js"; import { ChatPromptTemplate } from "./chat.js"; /** * Type that includes the name of the prompt and t...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/prompts/prompt.ts
// Default generic "any" values are for backwards compatibility. // Replace with "string" when we are comfortable with a breaking change. import { BaseStringPromptTemplate } from "./string.js"; import type { BasePromptTemplateInput, TypedPromptInputValues, } from "./base.js"; import { checkValidTemplate, parse...
0
lc_public_repos/langchainjs/langchain-core/src/prompts
lc_public_repos/langchainjs/langchain-core/src/prompts/tests/prompt.mustache.test.ts
import { test, expect } from "@jest/globals"; import { PromptTemplate } from "../prompt.js"; import { parseTemplate } from "../template.js"; test("Single input variable.", async () => { const template = "This is a {{foo}} test."; const prompt = PromptTemplate.fromTemplate(template, { templateFormat: "mustache"...
0
lc_public_repos/langchainjs/langchain-core/src/prompts
lc_public_repos/langchainjs/langchain-core/src/prompts/tests/prompt.test.ts
import { expect, test } from "@jest/globals"; import { PromptTemplate } from "../prompt.js"; import { Document } from "../../documents/document.js"; test("Test using partial", async () => { const prompt = new PromptTemplate({ template: "{foo}{bar}", inputVariables: ["foo"], partialVariables: { bar: "baz"...
0
lc_public_repos/langchainjs/langchain-core/src/prompts
lc_public_repos/langchainjs/langchain-core/src/prompts/tests/pipeline.test.ts
import { expect, test } from "@jest/globals"; import { PromptTemplate } from "../prompt.js"; import { ChatPromptTemplate, HumanMessagePromptTemplate, MessagesPlaceholder, SystemMessagePromptTemplate, } from "../chat.js"; import { PipelinePromptTemplate } from "../pipeline.js"; test("Test pipeline input variabl...
0
lc_public_repos/langchainjs/langchain-core/src/prompts
lc_public_repos/langchainjs/langchain-core/src/prompts/tests/structured.test.ts
/* eslint-disable @typescript-eslint/no-explicit-any */ import { ZodType, ZodTypeDef } from "zod"; import { test, expect } from "@jest/globals"; import { StructuredOutputMethodParams, StructuredOutputMethodOptions, BaseLanguageModelInput, } from "../../language_models/base.js"; import { BaseMessage } from "../../...
0
lc_public_repos/langchainjs/langchain-core/src/prompts
lc_public_repos/langchainjs/langchain-core/src/prompts/tests/chat.test.ts
/* eslint-disable @typescript-eslint/no-explicit-any */ import { expect, test } from "@jest/globals"; import { AIMessagePromptTemplate, ChatPromptTemplate, ChatMessagePromptTemplate, HumanMessagePromptTemplate, SystemMessagePromptTemplate, MessagesPlaceholder, } from "../chat.js"; import { PromptTemplate }...
0
lc_public_repos/langchainjs/langchain-core/src/prompts
lc_public_repos/langchainjs/langchain-core/src/prompts/tests/chat.mustache.test.ts
import { test, expect } from "@jest/globals"; import { AIMessage } from "../../messages/ai.js"; import { HumanMessage } from "../../messages/human.js"; import { SystemMessage } from "../../messages/system.js"; import { ChatPromptTemplate, HumanMessagePromptTemplate } from "../chat.js"; test("Test creating a chat promp...
0
lc_public_repos/langchainjs/langchain-core/src/prompts
lc_public_repos/langchainjs/langchain-core/src/prompts/tests/few_shot.test.ts
import { expect, describe, test } from "@jest/globals"; import { FewShotChatMessagePromptTemplate, FewShotPromptTemplate, } from "../few_shot.js"; import { ChatPromptTemplate } from "../index.js"; import { PromptTemplate } from "../prompt.js"; import { LengthBasedExampleSelector } from "../../example_selectors/leng...
0
lc_public_repos/langchainjs/langchain-core/src/prompts
lc_public_repos/langchainjs/langchain-core/src/prompts/tests/template.test.ts
import { expect, test, describe } from "@jest/globals"; import { interpolateFString } from "../template.js"; describe.each([ ["{foo}", { foo: "bar" }, "bar"], ["pre{foo}post", { foo: "bar" }, "prebarpost"], ["{{pre{foo}post}}", { foo: "bar" }, "{prebarpost}"], ["text", {}, "text"], ["}}{{", {}, "}{"], ["{f...
0
lc_public_repos/langchainjs/langchain-core/src/prompts/tests
lc_public_repos/langchainjs/langchain-core/src/prompts/tests/__snapshots__/chat.test.ts.snap
// Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Multi-modal, multi part chat prompt works with instances of BaseMessage 1`] = ` [ { "id": [ "langchain_core", "messages", "SystemMessage", ], "kwargs": { "additional_kwargs": {}, "content": "You are an AI assistant named Bo...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/tools/index.ts
import { z } from "zod"; import { CallbackManager, CallbackManagerForToolRun, Callbacks, parseCallbackConfigArg, } from "../callbacks/manager.js"; import { BaseLangChain, type BaseLangChainParams, } from "../language_models/base.js"; import { ensureConfig, patchConfig, pickRunnableConfigKeys, type R...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/tools/utils.ts
import { ToolCall } from "../messages/tool.js"; export function _isToolCall(toolCall?: unknown): toolCall is ToolCall { return !!( toolCall && typeof toolCall === "object" && "type" in toolCall && toolCall.type === "tool_call" ); } /** * Custom error class used to handle exceptions related to too...
0
lc_public_repos/langchainjs/langchain-core/src/tools
lc_public_repos/langchainjs/langchain-core/src/tools/tests/tools.test.ts
import { test, expect } from "@jest/globals"; import { z } from "zod"; import { DynamicStructuredTool, tool } from "../index.js"; import { ToolMessage } from "../../messages/tool.js"; test("Tool should error if responseFormat is content_and_artifact but the function doesn't return a tuple", async () => { const weat...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/output_parsers/list.ts
import { BaseMessage } from "../messages/index.js"; import { OutputParserException } from "./base.js"; import { BaseTransformOutputParser } from "./transform.js"; /** * Class to parse the output of an LLM call to a list. * @augments BaseOutputParser */ export abstract class ListOutputParser extends BaseTransformOut...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/output_parsers/string.ts
import { BaseTransformOutputParser } from "./transform.js"; import { MessageContentComplex, MessageContentImageUrl, MessageContentText, } from "../messages/index.js"; /** * OutputParser that parses LLMResult into the top likely string. * @example * ```typescript * const promptTemplate = PromptTemplate.fromTe...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/output_parsers/structured.ts
import { z } from "zod"; import { zodToJsonSchema, JsonSchema7Type, JsonSchema7ArrayType, JsonSchema7ObjectType, JsonSchema7StringType, JsonSchema7NumberType, JsonSchema7NullableType, } from "zod-to-json-schema"; import { BaseOutputParser, FormatInstructionsOptions, OutputParserException, } from "./...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/output_parsers/xml.ts
import { BaseCumulativeTransformOutputParser, BaseCumulativeTransformOutputParserInput, } from "./transform.js"; import { Operation, compare } from "../utils/json_patch.js"; import { sax } from "../utils/sax-js/sax.js"; import { ChatGeneration, Generation } from "../outputs.js"; export const XML_FORMAT_INSTRUCTION...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/output_parsers/index.ts
export * from "./base.js"; export * from "./bytes.js"; export * from "./list.js"; export * from "./string.js"; export * from "./structured.js"; export * from "./transform.js"; export * from "./json.js"; export * from "./xml.js";
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/output_parsers/json.ts
import { BaseCumulativeTransformOutputParser } from "./transform.js"; import { Operation, compare } from "../utils/json_patch.js"; import { ChatGeneration, Generation } from "../outputs.js"; import { parseJsonMarkdown, parsePartialJson } from "../utils/json.js"; /** * Class for parsing the output of an LLM into a JSO...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/output_parsers/base.ts
import { Runnable } from "../runnables/index.js"; import type { RunnableConfig } from "../runnables/config.js"; import type { BasePromptValueInterface } from "../prompt_values.js"; import type { BaseMessage, MessageContentComplex } from "../messages/index.js"; import type { Callbacks } from "../callbacks/manager.js"; i...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/output_parsers/bytes.ts
import { BaseTransformOutputParser } from "./transform.js"; /** * OutputParser that parses LLMResult into the top likely string and * encodes it into bytes. */ export class BytesOutputParser extends BaseTransformOutputParser<Uint8Array> { static lc_name() { return "BytesOutputParser"; } lc_namespace = ["...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/output_parsers/transform.ts
import { BaseOutputParser } from "./base.js"; import { type BaseMessage, isBaseMessage, isBaseMessageChunk, } from "../messages/base.js"; import { convertToChunk } from "../messages/utils.js"; import type { BaseCallbackConfig } from "../callbacks/manager.js"; import { type Generation, type ChatGeneration, G...
0
lc_public_repos/langchainjs/langchain-core/src/output_parsers
lc_public_repos/langchainjs/langchain-core/src/output_parsers/tests/output_parser.test.ts
/* eslint-disable no-loop-func */ /* eslint-disable no-promise-executor-return */ import { test, expect } from "@jest/globals"; import { FakeStreamingLLM } from "../../utils/testing/index.js"; import { BytesOutputParser } from "../bytes.js"; import { CommaSeparatedListOutputParser, ListOutputParser, MarkdownList...
0
lc_public_repos/langchainjs/langchain-core/src/output_parsers
lc_public_repos/langchainjs/langchain-core/src/output_parsers/tests/json.test.ts
import { test, expect } from "@jest/globals"; import { ChatPromptTemplate } from "../../prompts/chat.js"; import { RunnableSequence } from "../../runnables/base.js"; import { RunnablePassthrough } from "../../runnables/passthrough.js"; import { FakeStreamingLLM } from "../../utils/testing/index.js"; import { JsonOutput...
0
lc_public_repos/langchainjs/langchain-core/src/output_parsers
lc_public_repos/langchainjs/langchain-core/src/output_parsers/tests/structured.test.ts
import { z } from "zod"; import { expect, test } from "@jest/globals"; import { OutputParserException } from "../base.js"; import { StructuredOutputParser } from "../structured.js"; test("StructuredOutputParser.fromNamesAndDescriptions", async () => { const parser = StructuredOutputParser.fromNamesAndDescriptions(...
0
lc_public_repos/langchainjs/langchain-core/src/output_parsers
lc_public_repos/langchainjs/langchain-core/src/output_parsers/tests/string.test.ts
import { describe, test, expect } from "@jest/globals"; import { StringOutputParser } from "../string.js"; import { AIMessage, BaseMessage, MessageContentComplex, } from "../../messages/index.js"; describe("StringOutputParser", () => { test("string input", async () => { const msg: string = "hello"; con...
0
lc_public_repos/langchainjs/langchain-core/src/output_parsers
lc_public_repos/langchainjs/langchain-core/src/output_parsers/tests/xml.test.ts
import { test, expect } from "@jest/globals"; import { FakeStreamingLLM } from "../../utils/testing/index.js"; import { XMLOutputParser } from "../xml.js"; const XML_EXAMPLE = `<?xml version="1.0" encoding="UTF-8"?> <userProfile> <userID>12345</userID> <email>john.doe@example.com</email> <roles> <role>Admin<...
0
lc_public_repos/langchainjs/langchain-core/src/output_parsers
lc_public_repos/langchainjs/langchain-core/src/output_parsers/openai_functions/json_output_functions_parsers.ts
import { JsonSchema7ObjectType } from "zod-to-json-schema"; import { Optional } from "../../types/type-utils.js"; import { Generation, ChatGeneration } from "../../outputs.js"; import { BaseLLMOutputParser } from "../base.js"; import { parsePartialJson } from "../json.js"; import { BaseCumulativeTransformOutputParser...
0
lc_public_repos/langchainjs/langchain-core/src/output_parsers
lc_public_repos/langchainjs/langchain-core/src/output_parsers/openai_functions/index.ts
export * from "./json_output_functions_parsers.js";
0
lc_public_repos/langchainjs/langchain-core/src/output_parsers
lc_public_repos/langchainjs/langchain-core/src/output_parsers/openai_tools/index.ts
export * from "./json_output_tools_parsers.js";
0
lc_public_repos/langchainjs/langchain-core/src/output_parsers
lc_public_repos/langchainjs/langchain-core/src/output_parsers/openai_tools/json_output_tools_parsers.ts
import { z } from "zod"; import { ChatGeneration, ChatGenerationChunk } from "../../outputs.js"; import { OutputParserException } from "../base.js"; import { parsePartialJson } from "../json.js"; import { InvalidToolCall, ToolCall } from "../../messages/tool.js"; import { BaseCumulativeTransformOutputParser, BaseCu...
0
lc_public_repos/langchainjs/langchain-core/src/output_parsers/openai_tools
lc_public_repos/langchainjs/langchain-core/src/output_parsers/openai_tools/tests/json_output_tools_parser.test.ts
/* eslint-disable @typescript-eslint/no-explicit-any */ import { test, expect } from "@jest/globals"; import { z } from "zod"; import { JsonOutputKeyToolsParser } from "../json_output_tools_parsers.js"; import { OutputParserException } from "../../base.js"; import { AIMessage, AIMessageChunk } from "../../../messages/a...