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/messages/modifier.ts
import { BaseMessage, BaseMessageFields, MessageType } from "./base.js"; export interface RemoveMessageFields extends Omit<BaseMessageFields, "content"> { /** * The ID of the message to remove. */ id: string; } /** * Message responsible for deleting other messages. */ export class RemoveMessage extends ...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/messages/human.ts
import { BaseMessage, BaseMessageChunk, mergeContent, _mergeDicts, type MessageType, } from "./base.js"; /** * Represents a human message in a conversation. */ export class HumanMessage extends BaseMessage { static lc_name() { return "HumanMessage"; } _getType(): MessageType { return "human"...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/messages/tool.ts
import { BaseMessage, BaseMessageChunk, type BaseMessageFields, mergeContent, _mergeDicts, type MessageType, _mergeObj, _mergeStatus, } from "./base.js"; export interface ToolMessageFieldsWithToolCallId extends BaseMessageFields { /** * Artifact of the Tool execution which is not meant to be sent ...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/messages/transformers.ts
import { BaseDocumentTransformer } from "../documents/transformers.js"; import { BaseLanguageModel } from "../language_models/base.js"; import { Runnable, RunnableLambda } from "../runnables/base.js"; import { AIMessage, AIMessageChunk, AIMessageChunkFields } from "./ai.js"; import { BaseMessage, MessageType, Bas...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/messages/chat.ts
import { BaseMessage, BaseMessageChunk, type BaseMessageFields, mergeContent, _mergeDicts, type MessageType, } from "./base.js"; export interface ChatMessageFieldsWithRole extends BaseMessageFields { role: string; } /** * Represents a chat message in a conversation. */ export class ChatMessage exten...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/messages/function.ts
import { BaseMessage, BaseMessageChunk, type BaseMessageFields, mergeContent, _mergeDicts, type MessageType, } from "./base.js"; export interface FunctionMessageFieldsWithName extends BaseMessageFields { name: string; } /** * Represents a function message in a conversation. */ export class FunctionMes...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/messages/system.ts
import { BaseMessage, BaseMessageChunk, mergeContent, _mergeDicts, type MessageType, } from "./base.js"; /** * Represents a system message in a conversation. */ export class SystemMessage extends BaseMessage { static lc_name() { return "SystemMessage"; } _getType(): MessageType { return "sys...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/messages/index.ts
export * from "./ai.js"; export * from "./base.js"; export * from "./chat.js"; export * from "./function.js"; export * from "./human.js"; export * from "./system.js"; export * from "./utils.js"; export * from "./transformers.js"; export * from "./modifier.js"; // TODO: Use a star export when we deprecate the // existin...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/messages/ai.ts
import { parsePartialJson } from "../utils/json.js"; import { BaseMessage, BaseMessageChunk, mergeContent, _mergeDicts, type MessageType, BaseMessageFields, _mergeLists, } from "./base.js"; import { InvalidToolCall, ToolCall, ToolCallChunk, defaultToolCallParser, } from "./tool.js"; export type A...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/messages/base.ts
import { Serializable, SerializedConstructor } from "../load/serializable.js"; import { StringWithAutocomplete } from "../utils/types/index.js"; export interface StoredMessageData { content: string; role: string | undefined; name: string | undefined; tool_call_id: string | undefined; // eslint-disable-next-l...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/messages/utils.ts
import { addLangChainErrorFields } from "../errors/index.js"; import { SerializedConstructor } from "../load/serializable.js"; import { _isToolCall } from "../tools/utils.js"; import { AIMessage, AIMessageChunk, AIMessageChunkFields } from "./ai.js"; import { BaseMessageLike, BaseMessage, isBaseMessage, StoredM...
0
lc_public_repos/langchainjs/langchain-core/src/messages
lc_public_repos/langchainjs/langchain-core/src/messages/tests/message_utils.test.ts
import { it, describe, test, expect } from "@jest/globals"; import { filterMessages, mergeMessageRuns, trimMessages, } from "../transformers.js"; import { AIMessage } from "../ai.js"; import { ChatMessage } from "../chat.js"; import { HumanMessage } from "../human.js"; import { SystemMessage } from "../system.js"...
0
lc_public_repos/langchainjs/langchain-core/src/messages
lc_public_repos/langchainjs/langchain-core/src/messages/tests/base_message.test.ts
import { test, describe, it, expect } from "@jest/globals"; import { ChatPromptTemplate } from "../../prompts/chat.js"; import { HumanMessage, AIMessage, ToolMessage, ToolMessageChunk, AIMessageChunk, coerceMessageLikeToMessage, SystemMessage, } from "../index.js"; import { load } from "../../load/index.j...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/tests/caches.test.ts
import { test, expect } from "@jest/globals"; import { InMemoryCache } from "../caches/base.js"; test("InMemoryCache", async () => { const cache = new InMemoryCache(); await cache.update("foo", "bar", [{ text: "baz" }]); expect(await cache.lookup("foo", "bar")).toEqual([{ text: "baz" }]); });
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/tests/document.test.ts
import { test, expect } from "@jest/globals"; import { Document } from "../documents/document.js"; test("Document should handle empty pageContent", () => { const doc = new Document({ pageContent: "" }); expect(doc.pageContent).toEqual(""); });
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/tests/context.test.ts
import { test, expect } from "@jest/globals"; import { RunnableLambda } from "../runnables/base.js"; import { getContextVariable, setContextVariable } from "../context.js"; test("Getting and setting context variables within nested runnables", async () => { const nested = RunnableLambda.from(() => { expect(getCon...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/language_models/llms.ts
import { AIMessage, type BaseMessage, getBufferString, } from "../messages/index.js"; import type { BasePromptValueInterface } from "../prompt_values.js"; import { type LLMResult, RUN_KEY, type Generation, GenerationChunk, } from "../outputs.js"; import { type BaseCallbackConfig, CallbackManager, ty...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/language_models/chat_models.ts
import { z } from "zod"; import { zodToJsonSchema } from "zod-to-json-schema"; import { AIMessage, type BaseMessage, BaseMessageChunk, type BaseMessageLike, HumanMessage, coerceMessageLikeToMessage, AIMessageChunk, isAIMessageChunk, } from "../messages/index.js"; import type { BasePromptValueInterface }...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/language_models/base.ts
import type { Tiktoken, TiktokenModel } from "js-tiktoken/lite"; import { z } from "zod"; import { type BaseCache, InMemoryCache } from "../caches/base.js"; import { type BasePromptValueInterface, StringPromptValue, ChatPromptValue, } from "../prompt_values.js"; import { type BaseMessage, type BaseMessageLik...
0
lc_public_repos/langchainjs/langchain-core/src/language_models
lc_public_repos/langchainjs/langchain-core/src/language_models/tests/llms.test.ts
/* eslint-disable no-promise-executor-return */ import { test, expect } from "@jest/globals"; import { FakeLLM, FakeStreamingLLM } from "../../utils/testing/index.js"; import { HumanMessagePromptTemplate } from "../../prompts/chat.js"; test("Test FakeLLM uses callbacks", async () => { const model = new FakeLLM({});...
0
lc_public_repos/langchainjs/langchain-core/src/language_models
lc_public_repos/langchainjs/langchain-core/src/language_models/tests/count_tokens.test.ts
import { test, expect } from "@jest/globals"; import { calculateMaxTokens, getModelContextSize } from "../base.js"; test("properly calculates correct max tokens", async () => { expect( await calculateMaxTokens({ prompt: "", modelName: "gpt-3.5-turbo-16k" }) ).toBe(16384); expect( await calculateMaxTokens...
0
lc_public_repos/langchainjs/langchain-core/src/language_models
lc_public_repos/langchainjs/langchain-core/src/language_models/tests/chat_models.test.ts
/* eslint-disable no-promise-executor-return */ import { test, expect } from "@jest/globals"; import { z } from "zod"; import { zodToJsonSchema } from "zod-to-json-schema"; import { FakeChatModel, FakeListChatModel } from "../../utils/testing/index.js"; import { HumanMessage } from "../../messages/human.js"; import { ...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/retrievers/index.ts
import { BaseCallbackConfig, CallbackManager, CallbackManagerForRetrieverRun, Callbacks, parseCallbackConfigArg, } from "../callbacks/manager.js"; import type { DocumentInterface } from "../documents/document.js"; import { Runnable, type RunnableInterface } from "../runnables/base.js"; import { RunnableConfig...
0
lc_public_repos/langchainjs/langchain-core/src/retrievers
lc_public_repos/langchainjs/langchain-core/src/retrievers/document_compressors/base.ts
import { Callbacks } from "../../callbacks/manager.js"; import { DocumentInterface } from "../../documents/document.js"; /** * Base Document Compression class. All compressors should extend this class. */ export abstract class BaseDocumentCompressor { /** * Abstract method that must be implemented by any class ...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/utils/chunk_array.ts
export const chunkArray = <T>(arr: T[], chunkSize: number) => arr.reduce((chunks, elem, index) => { const chunkIndex = Math.floor(index / chunkSize); const chunk = chunks[chunkIndex] || []; // eslint-disable-next-line no-param-reassign chunks[chunkIndex] = chunk.concat([elem]); return chunks; },...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/utils/tiktoken.ts
import { Tiktoken, TiktokenEncoding, TiktokenModel, getEncodingNameForModel, } from "js-tiktoken/lite"; import { AsyncCaller } from "./async_caller.js"; const cache: Record<string, Promise<Tiktoken>> = {}; const caller = /* #__PURE__ */ new AsyncCaller({}); export async function getEncoding(encoding: Tiktoke...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/utils/async_caller.ts
import pRetry from "p-retry"; import PQueueMod from "p-queue"; const STATUS_NO_RETRY = [ 400, // Bad Request 401, // Unauthorized 402, // Payment Required 403, // Forbidden 404, // Not Found 405, // Method Not Allowed 406, // Not Acceptable 407, // Proxy Authentication Required 409, // Conflict ]; /...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/utils/event_source_parse.ts
/* eslint-disable prefer-template */ /* eslint-disable default-case */ /* eslint-disable no-plusplus */ // Adapted from https://github.com/gfortaine/fetch-event-source/blob/main/src/parse.ts // due to a packaging issue in the original. // MIT License import { IterableReadableStream } from "./stream.js"; export const E...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/utils/signal.ts
export async function raceWithSignal<T>( promise: Promise<T>, signal?: AbortSignal ): Promise<T> { if (signal === undefined) { return promise; } let listener: () => void; return Promise.race([ promise.catch<T>((err) => { if (!signal?.aborted) { throw err; } else { return ...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/utils/env.ts
// Inlined from https://github.com/flexdinesh/browser-or-node declare global { const Deno: | { version: { deno: string; }; env: { get: (name: string) => string | undefined; }; } | undefined; } export const isBrowser = () => typeof window !== "undefi...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/utils/json_patch.ts
export { compare, type Operation, applyPatch, } from "./fast-json-patch/index.js";
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/utils/hash.ts
export { insecureHash } from "./js-sha1/hash.js";
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/utils/json_schema.ts
export { deepCompareStrict, Validator } from "./@cfworker/json-schema/index.js";
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/utils/math.ts
import { cosine } from "./ml-distance/similarities.js"; import { innerProduct as innerProductDistance } from "./ml-distance/distances.js"; import { euclidean } from "./ml-distance-euclidean/euclidean.js"; type VectorFunction = (xVector: number[], yVector: number[]) => number; /** * Apply a row-wise function between ...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/utils/callbacks.ts
import { getEnvironmentVariable } from "./env.js"; export const isTracingEnabled = (tracingEnabled?: boolean): boolean => { if (tracingEnabled !== undefined) { return tracingEnabled; } const envVars = [ "LANGSMITH_TRACING_V2", "LANGCHAIN_TRACING_V2", "LANGSMITH_TRACING", "LANGCHAIN_TRACING", ...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/utils/stream.ts
import { pickRunnableConfigKeys } from "../runnables/config.js"; import { AsyncLocalStorageProviderSingleton } from "../singletons/index.js"; import type { IterableReadableStreamInterface } from "../types/stream.js"; import { raceWithSignal } from "./signal.js"; // Re-exported for backwards compatibility // Do NOT imp...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/utils/json.ts
export function parseJsonMarkdown(s: string, parser = parsePartialJson) { // eslint-disable-next-line no-param-reassign s = s.trim(); const match = /```(json)?(.*)```/s.exec(s); if (!match) { return parser(s); } else { return parser(match[2]); } } // Adapted from https://github.com/KillianLucas/ope...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/utils/function_calling.ts
import { zodToJsonSchema } from "zod-to-json-schema"; import { StructuredToolInterface, StructuredToolParams, } from "../tools/index.js"; import { FunctionDefinition, ToolDefinition } from "../language_models/base.js"; import { Runnable, RunnableToolLike } from "../runnables/base.js"; import { isZodSchema } from "....
0
lc_public_repos/langchainjs/langchain-core/src/utils
lc_public_repos/langchainjs/langchain-core/src/utils/types/is_zod_schema.ts
import { type z } from "zod"; /** * Given either a Zod schema, or plain object, determine if the input is a Zod schema. * * @param {z.ZodType<RunOutput> | Record<string, any>} input * @returns {boolean} Whether or not the provided input is a Zod schema. */ export function isZodSchema< // eslint-disable-next-lin...
0
lc_public_repos/langchainjs/langchain-core/src/utils
lc_public_repos/langchainjs/langchain-core/src/utils/types/index.ts
export * from "./is_zod_schema.js"; /** * Represents a string value with autocompleted, but not required, suggestions. */ export type StringWithAutocomplete<T> = T | (string & Record<never, never>); // eslint-disable-next-line @typescript-eslint/no-explicit-any export type InputValues<K extends string = string> = ...
0
lc_public_repos/langchainjs/langchain-core/src/utils/@cfworker
lc_public_repos/langchainjs/langchain-core/src/utils/@cfworker/json-schema/LICENSE.md
MIT License Copyright (c) 2020 Jeremy Danyow Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, dis...
0
lc_public_repos/langchainjs/langchain-core/src/utils/@cfworker
lc_public_repos/langchainjs/langchain-core/src/utils/@cfworker/json-schema/README.md
# @cfworker/json-schema ![](https://badgen.net/bundlephobia/minzip/@cfworker/json-schema) ![](https://badgen.net/bundlephobia/min/@cfworker/json-schema) ![](https://badgen.net/bundlephobia/dependency-count/@cfworker/json-schema) ![](https://badgen.net/bundlephobia/tree-shaking/@cfworker/json-schema) ![](https://badgen...
0
lc_public_repos/langchainjs/langchain-core/src/utils/@cfworker
lc_public_repos/langchainjs/langchain-core/src/utils/@cfworker/json-schema/index.ts
export * from "./src/index.js";
0
lc_public_repos/langchainjs/langchain-core/src/utils/@cfworker
lc_public_repos/langchainjs/langchain-core/src/utils/@cfworker/json-schema/package.json
{ "name": "@cfworker/json-schema", "type": "module", "version": "1.12.5", "description": "A JSON schema validator that will run on Cloudflare workers. Supports drafts 4, 7, 2019-09, and 2020-12.", "keywords": [ "json-schema", "jsonschema", "json", "schema", "cloudflare", "worker", ...
0
lc_public_repos/langchainjs/langchain-core/src/utils/@cfworker/json-schema
lc_public_repos/langchainjs/langchain-core/src/utils/@cfworker/json-schema/src/ucs2-length.ts
/** * Get UCS-2 length of a string * https://mathiasbynens.be/notes/javascript-encoding * https://github.com/bestiejs/punycode.js - punycode.ucs2.decode */ export function ucs2length(s: string) { let result = 0; let length = s.length; let index = 0; let charCode: number; while (index < length) { resul...
0
lc_public_repos/langchainjs/langchain-core/src/utils/@cfworker/json-schema
lc_public_repos/langchainjs/langchain-core/src/utils/@cfworker/json-schema/src/types.ts
export type SchemaDraft = "4" | "7" | "2019-09" | "2020-12"; export const enum OutputFormat { Flag = 1 << 0, Basic = 1 << 1, Detailed = 1 << 2, } export type InstanceType = | "array" | "boolean" | "integer" | "null" | "number" | "object" | "string"; export interface Schema { $id?: string; $an...
0
lc_public_repos/langchainjs/langchain-core/src/utils/@cfworker/json-schema
lc_public_repos/langchainjs/langchain-core/src/utils/@cfworker/json-schema/src/dereference.ts
import { encodePointer } from "./pointer.js"; import { Schema } from "./types.js"; export const schemaKeyword: Record<string, boolean> = { additionalItems: true, unevaluatedItems: true, items: true, contains: true, additionalProperties: true, unevaluatedProperties: true, propertyNames: true, not: true,...
0
lc_public_repos/langchainjs/langchain-core/src/utils/@cfworker/json-schema
lc_public_repos/langchainjs/langchain-core/src/utils/@cfworker/json-schema/src/validate.ts
import { deepCompareStrict } from "./deep-compare-strict.js"; import { dereference } from "./dereference.js"; import { fastFormat } from "./format.js"; import { encodePointer } from "./pointer.js"; import { InstanceType, OutputUnit, Schema, SchemaDraft, ValidationResult, } from "./types.js"; import { ucs2leng...
0
lc_public_repos/langchainjs/langchain-core/src/utils/@cfworker/json-schema
lc_public_repos/langchainjs/langchain-core/src/utils/@cfworker/json-schema/src/deep-compare-strict.ts
export function deepCompareStrict(a: any, b: any): boolean { const typeofa = typeof a; if (typeofa !== typeof b) { return false; } if (Array.isArray(a)) { if (!Array.isArray(b)) { return false; } const length = a.length; if (length !== b.length) { return false; } for (let...
0
lc_public_repos/langchainjs/langchain-core/src/utils/@cfworker/json-schema
lc_public_repos/langchainjs/langchain-core/src/utils/@cfworker/json-schema/src/format.ts
// based on https://github.com/epoberezkin/ajv/blob/master/lib/compile/formats.js const DATE = /^(\d\d\d\d)-(\d\d)-(\d\d)$/; const DAYS = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; const TIME = /^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i; const HOSTNAME = /^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-...
0
lc_public_repos/langchainjs/langchain-core/src/utils/@cfworker/json-schema
lc_public_repos/langchainjs/langchain-core/src/utils/@cfworker/json-schema/src/pointer.ts
export function encodePointer(p: string): string { return encodeURI(escapePointer(p)); } export function escapePointer(p: string): string { return p.replace(/~/g, "~0").replace(/\//g, "~1"); }
0
lc_public_repos/langchainjs/langchain-core/src/utils/@cfworker/json-schema
lc_public_repos/langchainjs/langchain-core/src/utils/@cfworker/json-schema/src/index.ts
export * from "./deep-compare-strict.js"; export * from "./dereference.js"; export * from "./format.js"; export * from "./pointer.js"; export * from "./types.js"; export * from "./ucs2-length.js"; export * from "./validate.js"; export * from "./validator.js";
0
lc_public_repos/langchainjs/langchain-core/src/utils/@cfworker/json-schema
lc_public_repos/langchainjs/langchain-core/src/utils/@cfworker/json-schema/src/validator.ts
import { dereference } from "./dereference.js"; import { Schema, SchemaDraft } from "./types.js"; import { validate } from "./validate.js"; export class Validator { private readonly lookup: ReturnType<typeof dereference>; constructor( private readonly schema: Schema | boolean, private readonly draft: Sche...
0
lc_public_repos/langchainjs/langchain-core/src/utils
lc_public_repos/langchainjs/langchain-core/src/utils/fast-json-patch/LICENSE.md
(The MIT License) Copyright (c) 2013, 2014, 2020 Joachim Wester Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, ...
0
lc_public_repos/langchainjs/langchain-core/src/utils
lc_public_repos/langchainjs/langchain-core/src/utils/fast-json-patch/index.ts
export * from "./src/core.js"; export * from "./src/duplex.js"; export { PatchError as JsonPatchError, _deepClone as deepClone, escapePathComponent, unescapePathComponent, } from "./src/helpers.js"; /** * Default export for backwards compat */ import * as core from "./src/core.js"; import { PatchError as ...
0
lc_public_repos/langchainjs/langchain-core/src/utils/fast-json-patch
lc_public_repos/langchainjs/langchain-core/src/utils/fast-json-patch/src/helpers.ts
// @ts-nocheck // Inlined because of ESM import issues /*! * https://github.com/Starcounter-Jack/JSON-Patch * (c) 2017-2022 Joachim Wester * MIT licensed */ const _hasOwnProperty = Object.prototype.hasOwnProperty; export function hasOwnProperty(obj, key) { return _hasOwnProperty.call(obj, key); } export functi...
0
lc_public_repos/langchainjs/langchain-core/src/utils/fast-json-patch
lc_public_repos/langchainjs/langchain-core/src/utils/fast-json-patch/src/duplex.ts
// @ts-nocheck // Inlined because of ESM import issues /*! * https://github.com/Starcounter-Jack/JSON-Patch * (c) 2013-2021 Joachim Wester * MIT license */ import { _deepClone, _objectKeys, escapePathComponent, hasOwnProperty, } from "./helpers.js"; import { applyPatch, Operation } from "./core.js"; expo...
0
lc_public_repos/langchainjs/langchain-core/src/utils/fast-json-patch
lc_public_repos/langchainjs/langchain-core/src/utils/fast-json-patch/src/core.ts
// @ts-nocheck // Inlined because of ESM import issues /*! * https://github.com/Starcounter-Jack/JSON-Patch * (c) 2013-2021 Joachim Wester * MIT license */ declare var require: any; import { PatchError, _deepClone, isInteger, unescapePathComponent, hasUndefined, } from "./helpers.js"; export const Jso...
0
lc_public_repos/langchainjs/langchain-core/src/utils
lc_public_repos/langchainjs/langchain-core/src/utils/js-sha1/LICENSE.md
Copyright 2014-2017 Chen, Yi-Cyuan Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, su...
0
lc_public_repos/langchainjs/langchain-core/src/utils
lc_public_repos/langchainjs/langchain-core/src/utils/js-sha1/hash.ts
// @ts-nocheck // Inlined to deal with portability issues with importing crypto module /* * [js-sha1]{@link https://github.com/emn178/js-sha1} * * @version 0.6.0 * @author Chen, Yi-Cyuan [emn178@gmail.com] * @copyright Chen, Yi-Cyuan 2014-2017 * @license MIT */ /*jslint bitwise: true */ "use strict"; var root...
0
lc_public_repos/langchainjs/langchain-core/src/utils
lc_public_repos/langchainjs/langchain-core/src/utils/sax-js/LICENSE.md
The ISC License Copyright (c) 2010-2023 Isaac Z. Schlueter and Contributors Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS...
0
lc_public_repos/langchainjs/langchain-core/src/utils
lc_public_repos/langchainjs/langchain-core/src/utils/sax-js/sax.ts
// @ts-nocheck // Inlined to deal with portability issues // Originally from: https://github.com/isaacs/sax-js const initializeSax = function () { const sax: any = {}; sax.parser = function (strict, opt) { return new SAXParser(strict, opt); }; sax.SAXParser = SAXParser; sax.SAXStream = SAXStream; sax....
0
lc_public_repos/langchainjs/langchain-core/src/utils
lc_public_repos/langchainjs/langchain-core/src/utils/tests/enviroment.test.ts
import { test, expect } from "@jest/globals"; import { getRuntimeEnvironment } from "../env.js"; test("test getRuntimeEnvironment", async () => { const runtimeEnvironment = await getRuntimeEnvironment(); console.log(runtimeEnvironment); expect(runtimeEnvironment.runtime).toEqual("node"); });
0
lc_public_repos/langchainjs/langchain-core/src/utils
lc_public_repos/langchainjs/langchain-core/src/utils/tests/polyfill_stream.test.ts
import "web-streams-polyfill/polyfill"; import { test, expect } from "@jest/globals"; import { FakeStreamingLLM } from "../testing/index.js"; import { StringOutputParser } from "../../output_parsers/string.js"; test("Stream the entire way through", async () => { const llm = new FakeStreamingLLM({}); const stream =...
0
lc_public_repos/langchainjs/langchain-core/src/utils
lc_public_repos/langchainjs/langchain-core/src/utils/tests/math_utils.test.ts
import { test, expect } from "@jest/globals"; import { Matrix } from "ml-matrix"; import { cosineSimilarity, euclideanDistance, innerProduct, maximalMarginalRelevance, normalize, } from "../math.js"; test("Test cosine similarity zero", async () => { const X = Matrix.rand(3, 3).to2DArray(); const Y = Matr...
0
lc_public_repos/langchainjs/langchain-core/src/utils
lc_public_repos/langchainjs/langchain-core/src/utils/tests/async_caller.test.ts
import { test, expect, jest } from "@jest/globals"; import { AsyncCaller } from "../async_caller.js"; test("AsyncCaller passes on arguments and returns return value", async () => { const caller = new AsyncCaller({}); const callable = jest.fn((arg1, arg2) => Promise.resolve([arg2, arg1])); const resultDirect = a...
0
lc_public_repos/langchainjs/langchain-core/src/utils
lc_public_repos/langchainjs/langchain-core/src/utils/tests/function_calling.test.ts
import { z } from "zod"; import { test, expect } from "@jest/globals"; import { convertToOpenAIFunction, convertToOpenAITool, } from "../function_calling.js"; import { FakeTool } from "../testing/index.js"; test("Can convert tool to OpenAI Functions format", async () => { const tool = new FakeTool({ name: "f...
0
lc_public_repos/langchainjs/langchain-core/src/utils
lc_public_repos/langchainjs/langchain-core/src/utils/testing/index.ts
/* eslint-disable no-promise-executor-return */ /* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-unused-vars */ import { z } from "zod"; import { BaseCallbackConfig, CallbackManagerForLLMRun, CallbackManagerForToolRun, } from "../../callbacks/manager.js"; import { ...
0
lc_public_repos/langchainjs/langchain-core/src/utils/testing
lc_public_repos/langchainjs/langchain-core/src/utils/testing/tests/chatfake.test.ts
import { describe, test, expect, jest } from "@jest/globals"; import { HumanMessage } from "../../../messages/index.js"; import { StringOutputParser } from "../../../output_parsers/string.js"; import { FakeListChatModel } from "../index.js"; describe("Test FakeListChatLLM", () => { test("Should exist", async () => {...
0
lc_public_repos/langchainjs/langchain-core/src/utils
lc_public_repos/langchainjs/langchain-core/src/utils/ml-distance/LICENSE
The MIT License (MIT) Copyright (c) 2014 ml.js Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, d...
0
lc_public_repos/langchainjs/langchain-core/src/utils
lc_public_repos/langchainjs/langchain-core/src/utils/ml-distance/similarities.ts
/** * Returns the average of cosine distances between vectors a and b * @param a - first vector * @param b - second vector * */ export function cosine(a: number[], b: number[]): number { let p = 0; let p2 = 0; let q2 = 0; for (let i = 0; i < a.length; i++) { p += a[i] * b[i]; p2 += a[i] * a[i]; ...
0
lc_public_repos/langchainjs/langchain-core/src/utils
lc_public_repos/langchainjs/langchain-core/src/utils/ml-distance/distances.ts
/** *Returns the Inner Product similarity between vectors a and b * @link [Inner Product Similarity algorithm](https://www.naun.org/main/NAUN/ijmmas/mmmas-49.pdf) * @param a - first vector * @param b - second vector * */ export function innerProduct(a: number[], b: number[]): number { let ans = 0; for (let i ...
0
lc_public_repos/langchainjs/langchain-core/src/utils
lc_public_repos/langchainjs/langchain-core/src/utils/ml-distance-euclidean/LICENSE
The MIT License (MIT) Copyright (c) 2015 ml.js Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, d...
0
lc_public_repos/langchainjs/langchain-core/src/utils
lc_public_repos/langchainjs/langchain-core/src/utils/ml-distance-euclidean/euclidean.ts
export function squaredEuclidean(p: number[], q: number[]) { let d = 0; for (let i = 0; i < p.length; i++) { d += (p[i] - q[i]) * (p[i] - q[i]); } return d; } export function euclidean(p: number[], q: number[]) { return Math.sqrt(squaredEuclidean(p, q)); }
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/singletons/tracer.ts
import { Client } from "langsmith"; import { getEnvironmentVariable } from "../utils/env.js"; let client: Client; export const getDefaultLangChainClientSingleton = () => { if (client === undefined) { const clientParams = getEnvironmentVariable("LANGCHAIN_CALLBACKS_BACKGROUND") === "false" ? { ...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/singletons/callbacks.ts
/* eslint-disable @typescript-eslint/no-explicit-any */ import PQueueMod from "p-queue"; import { getGlobalAsyncLocalStorageInstance } from "./async_local_storage/globals.js"; let queue: typeof import("p-queue")["default"]["prototype"]; /** * Creates a queue using the p-queue library. The queue is configured to * ...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/singletons/index.ts
/* eslint-disable @typescript-eslint/no-explicit-any */ import { type AsyncLocalStorageInterface, AsyncLocalStorageProviderSingleton, _CONTEXT_VARIABLES_KEY, MockAsyncLocalStorage, } from "./async_local_storage/index.js"; export { type AsyncLocalStorageInterface, AsyncLocalStorageProviderSingleton, _CONT...
0
lc_public_repos/langchainjs/langchain-core/src/singletons
lc_public_repos/langchainjs/langchain-core/src/singletons/async_local_storage/globals.ts
/* eslint-disable @typescript-eslint/no-explicit-any */ export interface AsyncLocalStorageInterface { getStore: () => any | undefined; run: <T>(store: any, callback: () => T) => T; enterWith: (store: any) => void; } export const TRACING_ALS_KEY = Symbol.for("ls:tracing_async_local_storage"); export const setG...
0
lc_public_repos/langchainjs/langchain-core/src/singletons
lc_public_repos/langchainjs/langchain-core/src/singletons/async_local_storage/index.ts
/* eslint-disable @typescript-eslint/no-explicit-any */ import { RunTree } from "langsmith"; import { AsyncLocalStorageInterface, getGlobalAsyncLocalStorageInstance, setGlobalAsyncLocalStorageInstance, } from "./globals.js"; import { CallbackManager } from "../../callbacks/manager.js"; import { LangChainTracer } ...
0
lc_public_repos/langchainjs/langchain-core/src/singletons
lc_public_repos/langchainjs/langchain-core/src/singletons/tests/async_local_storage.test.ts
import { test, expect } from "@jest/globals"; import { v4 } from "uuid"; import { AsyncLocalStorage } from "node:async_hooks"; import { AsyncLocalStorageProviderSingleton } from "../index.js"; import { RunnableLambda } from "../../runnables/base.js"; import { FakeListChatModel } from "../../utils/testing/index.js"; imp...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/document_loaders/langsmith.ts
import { KVMap } from "langsmith/schemas"; import { Client } from "langsmith"; import { Document, DocumentInterface } from "../documents/document.js"; import { AsyncCallerParams } from "../utils/async_caller.js"; import { BaseDocumentLoader } from "./base.js"; // TODO: Replace with import from `langsmith` once exposed...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/document_loaders/base.ts
import { Document } from "../documents/document.js"; import { BaseDocumentTransformer } from "../documents/transformers.js"; /** * Interface that defines the methods for loading and splitting documents. */ export interface DocumentLoader { load(): Promise<Document[]>; loadAndSplit(textSplitter?: BaseDocumentTran...
0
lc_public_repos/langchainjs/langchain-core/src/document_loaders
lc_public_repos/langchainjs/langchain-core/src/document_loaders/tests/langsmith.int.test.ts
/* eslint-disable no-process-env */ import { test, expect } from "@jest/globals"; import { Client } from "langsmith"; import { LangSmithLoader } from "../langsmith.js"; const DATASET_NAME = "brace-test-dataset"; const DATASET_ID = "9a3b36f7-a297-40a5-944d-6613853b6330"; test("LangSmithLoader can load with client pass...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/documents/transformers.ts
import { Runnable } from "../runnables/base.js"; import type { BaseCallbackConfig } from "../callbacks/manager.js"; import type { DocumentInterface } from "./document.js"; /** * Abstract base class for document transformation systems. * * A document transformation system takes an array of Documents and returns an ...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/documents/document.ts
export interface DocumentInput< // eslint-disable-next-line @typescript-eslint/no-explicit-any Metadata extends Record<string, any> = Record<string, any> > { pageContent: string; metadata?: Metadata; /** * An optional identifier for the document. * * Ideally this should be unique across the documen...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/documents/index.ts
export * from "./document.js"; export * from "./transformers.js";
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/indexing/record_manager.ts
import { Serializable } from "../load/serializable.js"; // Arbitrary value, used for generating namespaced UUIDs. export const UUIDV5_NAMESPACE = "10f90ea3-90a4-4962-bf75-83a0f3c1c62a"; export type UpdateOptions = { groupIds?: (string | null)[]; timeAtLeast?: number; }; export type ListKeyOptions = { before?: ...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/indexing/index.ts
export * from "./record_manager.js"; export * from "./base.js";
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/indexing/base.ts
import { v5 as uuidv5 } from "uuid"; import { VectorStore } from "../vectorstores.js"; import { RecordManagerInterface, UUIDV5_NAMESPACE } from "./record_manager.js"; import { insecureHash } from "../utils/hash.js"; import { DocumentInterface, Document } from "../documents/document.js"; import { BaseDocumentLoader } fr...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/callbacks/promises.ts
import { awaitAllCallbacks, consumeCallback } from "../singletons/callbacks.js"; export { awaitAllCallbacks, consumeCallback };
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/callbacks/manager.ts
import { v4 as uuidv4 } from "uuid"; import { AgentAction, AgentFinish } from "../agents.js"; import type { ChainValues } from "../utils/types/index.js"; import { LLMResult } from "../outputs.js"; import { BaseCallbackHandler, CallbackHandlerMethods, HandleLLMNewTokenCallbackFields, NewTokenIndices, } from "./b...
0
lc_public_repos/langchainjs/langchain-core/src
lc_public_repos/langchainjs/langchain-core/src/callbacks/base.ts
import * as uuid from "uuid"; import type { ChainValues } from "../utils/types/index.js"; import type { BaseMessage } from "../messages/base.js"; import type { AgentAction, AgentFinish } from "../agents.js"; import type { ChatGenerationChunk, GenerationChunk, LLMResult, } from "../outputs.js"; import { Serializ...
0
lc_public_repos/langchainjs/langchain-core/src/callbacks
lc_public_repos/langchainjs/langchain-core/src/callbacks/dispatch/web.ts
import { type RunnableConfig, getCallbackManagerForConfig, } from "../../runnables/config.js"; /** * Dispatch a custom event. Requires an explicit config object. * @param name The name of the custom event. * @param payload The data for the custom event. * Ideally should be JSON serializable to avoid serializ...
0
lc_public_repos/langchainjs/langchain-core/src/callbacks
lc_public_repos/langchainjs/langchain-core/src/callbacks/dispatch/index.ts
/* __LC_ALLOW_ENTRYPOINT_SIDE_EFFECTS__ */ import { AsyncLocalStorage } from "node:async_hooks"; import { dispatchCustomEvent as dispatchCustomEventWeb } from "./web.js"; import { type RunnableConfig, ensureConfig } from "../../runnables/config.js"; import { AsyncLocalStorageProviderSingleton } from "../../singletons/...
0
lc_public_repos/langchainjs/langchain-core/src/callbacks
lc_public_repos/langchainjs/langchain-core/src/callbacks/tests/manager.int.test.ts
/* eslint-disable no-process-env */ import { test, expect } from "@jest/globals"; import { PromptTemplate } from "../../prompts/prompt.js"; import { FakeLLM } from "../../utils/testing/index.js"; import { CallbackManager, traceAsGroup, TraceGroup } from "../manager.js"; import { StringOutputParser } from "../../output...
0
lc_public_repos/langchainjs/langchain-core/src/callbacks
lc_public_repos/langchainjs/langchain-core/src/callbacks/tests/callbacks.test.ts
/* eslint-disable no-promise-executor-return */ import { test, expect } from "@jest/globals"; import * as uuid from "uuid"; import { AsyncLocalStorage } from "node:async_hooks"; import { CallbackManager } from "../manager.js"; import { BaseCallbackHandler, type BaseCallbackHandlerInput } from "../base.js"; import type ...
0
lc_public_repos/langchainjs/langchain-core/src/callbacks
lc_public_repos/langchainjs/langchain-core/src/callbacks/tests/run_collector.test.ts
import { v4 as uuidv4, validate } from "uuid"; import { Run } from "langsmith/schemas"; import { describe, it, expect } from "@jest/globals"; import { ChatPromptTemplate, HumanMessagePromptTemplate, SystemMessagePromptTemplate, } from "../../prompts/chat.js"; import { BaseLLM } from "../../language_models/llms.js...
0
lc_public_repos/langchainjs/langchain-core
lc_public_repos/langchainjs/langchain-core/scripts/jest-setup-after-env.js
import { awaitAllCallbacks } from "../src/callbacks/promises.js"; afterAll(awaitAllCallbacks);
0
lc_public_repos/langchainjs/libs
lc_public_repos/langchainjs/libs/langchain-azure-dynamic-sessions/tsconfig.json
{ "extends": "@tsconfig/recommended", "compilerOptions": { "outDir": "../dist", "rootDir": "./src", "target": "ES2021", "lib": ["ES2021", "ES2022.Object", "DOM"], "module": "ES2020", "moduleResolution": "nodenext", "esModuleInterop": true, "declaration": true, "noImplicitReturns"...
0
lc_public_repos/langchainjs/libs
lc_public_repos/langchainjs/libs/langchain-azure-dynamic-sessions/LICENSE
The MIT License Copyright (c) 2023 LangChain Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, dis...