langchain 0.0.146 → 0.0.147

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/dist/base_language/index.cjs +2 -2
  2. package/dist/base_language/index.d.ts +2 -1
  3. package/dist/base_language/index.js +1 -1
  4. package/dist/chains/base.d.ts +1 -1
  5. package/dist/chains/openai_functions/openapi.cjs +32 -27
  6. package/dist/chains/openai_functions/openapi.d.ts +9 -0
  7. package/dist/chains/openai_functions/openapi.js +31 -27
  8. package/dist/chat_models/base.d.ts +1 -1
  9. package/dist/chat_models/openai.cjs +1 -1
  10. package/dist/chat_models/openai.js +1 -1
  11. package/dist/experimental/llms/bittensor.cjs +141 -0
  12. package/dist/experimental/llms/bittensor.d.ts +33 -0
  13. package/dist/experimental/llms/bittensor.js +137 -0
  14. package/dist/hub.d.ts +1 -1
  15. package/dist/llms/base.d.ts +1 -1
  16. package/dist/llms/openai-chat.cjs +1 -1
  17. package/dist/llms/openai-chat.js +1 -1
  18. package/dist/llms/openai.cjs +1 -1
  19. package/dist/llms/openai.js +1 -1
  20. package/dist/load/import_constants.cjs +1 -0
  21. package/dist/load/import_constants.js +1 -0
  22. package/dist/load/import_map.cjs +1 -1
  23. package/dist/load/import_map.d.ts +1 -1
  24. package/dist/load/import_map.js +1 -1
  25. package/dist/load/index.cjs +2 -1
  26. package/dist/load/index.js +2 -1
  27. package/dist/prompts/base.cjs +2 -2
  28. package/dist/prompts/base.d.ts +1 -1
  29. package/dist/prompts/base.js +1 -1
  30. package/dist/prompts/chat.cjs +2 -2
  31. package/dist/prompts/chat.d.ts +1 -1
  32. package/dist/prompts/chat.js +1 -1
  33. package/dist/schema/document.cjs +2 -2
  34. package/dist/schema/document.d.ts +1 -1
  35. package/dist/schema/document.js +1 -1
  36. package/dist/schema/output_parser.cjs +2 -2
  37. package/dist/schema/output_parser.d.ts +2 -1
  38. package/dist/schema/output_parser.js +1 -1
  39. package/dist/schema/retriever.cjs +2 -2
  40. package/dist/schema/retriever.d.ts +2 -1
  41. package/dist/schema/retriever.js +1 -1
  42. package/dist/schema/runnable/config.cjs +8 -0
  43. package/dist/schema/runnable/config.d.ts +3 -0
  44. package/dist/schema/runnable/config.js +4 -0
  45. package/dist/schema/{runnable.cjs → runnable/index.cjs} +290 -101
  46. package/dist/schema/{runnable.d.ts → runnable/index.d.ts} +127 -41
  47. package/dist/schema/{runnable.js → runnable/index.js} +284 -99
  48. package/dist/tools/base.d.ts +1 -1
  49. package/dist/util/async_caller.cjs +35 -25
  50. package/dist/util/async_caller.d.ts +8 -0
  51. package/dist/util/async_caller.js +35 -25
  52. package/dist/vectorstores/pinecone.cjs +30 -22
  53. package/dist/vectorstores/pinecone.d.ts +3 -1
  54. package/dist/vectorstores/pinecone.js +30 -22
  55. package/dist/vectorstores/vectara.cjs +20 -23
  56. package/dist/vectorstores/vectara.d.ts +9 -2
  57. package/dist/vectorstores/vectara.js +20 -23
  58. package/experimental/llms/bittensor.cjs +1 -0
  59. package/experimental/llms/bittensor.d.ts +1 -0
  60. package/experimental/llms/bittensor.js +1 -0
  61. package/package.json +9 -1
  62. package/schema/runnable.cjs +1 -1
  63. package/schema/runnable.d.ts +1 -1
  64. package/schema/runnable.js +1 -1
@@ -138,7 +138,8 @@ async function reviver(value) {
138
138
  module[name] ??
139
139
  // look for an export with a lc_name property matching the class name
140
140
  // this is necessary for classes that are minified
141
- Object.values(module).find((v) => typeof v === "function" && (0, serializable_js_1.get_lc_unique_name)(v) === name);
141
+ Object.values(module).find((v) => typeof v === "function" &&
142
+ (0, serializable_js_1.get_lc_unique_name)(v) === name);
142
143
  if (typeof builder !== "function") {
143
144
  throw new Error(`Invalid identifer: ${pathStr} -> ${str}`);
144
145
  }
@@ -112,7 +112,8 @@ async function reviver(value) {
112
112
  module[name] ??
113
113
  // look for an export with a lc_name property matching the class name
114
114
  // this is necessary for classes that are minified
115
- Object.values(module).find((v) => typeof v === "function" && get_lc_unique_name(v) === name);
115
+ Object.values(module).find((v) => typeof v === "function" &&
116
+ get_lc_unique_name(v) === name);
116
117
  if (typeof builder !== "function") {
117
118
  throw new Error(`Invalid identifer: ${pathStr} -> ${str}`);
118
119
  }
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
5
5
  exports.BaseExampleSelector = exports.BaseStringPromptTemplate = exports.BasePromptTemplate = exports.StringPromptValue = void 0;
6
6
  const index_js_1 = require("../schema/index.cjs");
7
7
  const serializable_js_1 = require("../load/serializable.cjs");
8
- const runnable_js_1 = require("../schema/runnable.cjs");
8
+ const index_js_2 = require("../schema/runnable/index.cjs");
9
9
  /**
10
10
  * Represents a prompt value as a string. It extends the BasePromptValue
11
11
  * class and overrides the toString and toChatMessages methods.
@@ -39,7 +39,7 @@ exports.StringPromptValue = StringPromptValue;
39
39
  * Base class for prompt templates. Exposes a format method that returns a
40
40
  * string prompt given a set of input values.
41
41
  */
42
- class BasePromptTemplate extends runnable_js_1.Runnable {
42
+ class BasePromptTemplate extends index_js_2.Runnable {
43
43
  get lc_attributes() {
44
44
  return {
45
45
  partialVariables: undefined, // python doesn't support this yet
@@ -3,7 +3,7 @@ import { BaseOutputParser } from "../schema/output_parser.js";
3
3
  import { Serializable } from "../load/serializable.js";
4
4
  import { SerializedBasePromptTemplate } from "./serde.js";
5
5
  import { SerializedFields } from "../load/map_keys.js";
6
- import { Runnable } from "../schema/runnable.js";
6
+ import { Runnable } from "../schema/runnable/index.js";
7
7
  import { BaseCallbackConfig } from "../callbacks/manager.js";
8
8
  export type TypedPromptInputValues<RunInput> = InputValues<Extract<keyof RunInput, string> | (string & Record<never, never>)>;
9
9
  /**
@@ -2,7 +2,7 @@
2
2
  // Replace with "string" when we are comfortable with a breaking change.
3
3
  import { BasePromptValue, HumanMessage, } from "../schema/index.js";
4
4
  import { Serializable } from "../load/serializable.js";
5
- import { Runnable } from "../schema/runnable.js";
5
+ import { Runnable } from "../schema/runnable/index.js";
6
6
  /**
7
7
  * Represents a prompt value as a string. It extends the BasePromptValue
8
8
  * class and overrides the toString and toChatMessages methods.
@@ -4,7 +4,7 @@
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
5
  exports.ChatPromptTemplate = exports.SystemMessagePromptTemplate = exports.AIMessagePromptTemplate = exports.HumanMessagePromptTemplate = exports.ChatMessagePromptTemplate = exports.BaseChatPromptTemplate = exports.BaseMessageStringPromptTemplate = exports.MessagesPlaceholder = exports.ChatPromptValue = exports.BaseMessagePromptTemplate = void 0;
6
6
  const index_js_1 = require("../schema/index.cjs");
7
- const runnable_js_1 = require("../schema/runnable.cjs");
7
+ const index_js_2 = require("../schema/runnable/index.cjs");
8
8
  const base_js_1 = require("./base.cjs");
9
9
  const prompt_js_1 = require("./prompt.cjs");
10
10
  /**
@@ -12,7 +12,7 @@ const prompt_js_1 = require("./prompt.cjs");
12
12
  * templates. It defines how to format messages for different roles in a
13
13
  * conversation.
14
14
  */
15
- class BaseMessagePromptTemplate extends runnable_js_1.Runnable {
15
+ class BaseMessagePromptTemplate extends index_js_2.Runnable {
16
16
  constructor() {
17
17
  super(...arguments);
18
18
  Object.defineProperty(this, "lc_namespace", {
@@ -1,6 +1,6 @@
1
1
  import { BaseCallbackConfig } from "../callbacks/manager.js";
2
2
  import { BaseMessage, BaseMessageLike, BasePromptValue, InputValues, PartialValues } from "../schema/index.js";
3
- import { Runnable } from "../schema/runnable.js";
3
+ import { Runnable } from "../schema/runnable/index.js";
4
4
  import { BasePromptTemplate, BasePromptTemplateInput, BaseStringPromptTemplate, TypedPromptInputValues } from "./base.js";
5
5
  /**
6
6
  * Abstract class that serves as a base for creating message prompt
@@ -1,7 +1,7 @@
1
1
  // Default generic "any" values are for backwards compatibility.
2
2
  // Replace with "string" when we are comfortable with a breaking change.
3
3
  import { AIMessage, BaseMessage, BasePromptValue, ChatMessage, HumanMessage, SystemMessage, coerceMessageLikeToMessage, isBaseMessage, } from "../schema/index.js";
4
- import { Runnable } from "../schema/runnable.js";
4
+ import { Runnable } from "../schema/runnable/index.js";
5
5
  import { BasePromptTemplate, } from "./base.js";
6
6
  import { PromptTemplate } from "./prompt.js";
7
7
  /**
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MappingDocumentTransformer = exports.BaseDocumentTransformer = void 0;
4
- const runnable_js_1 = require("./runnable.cjs");
4
+ const index_js_1 = require("./runnable/index.cjs");
5
5
  /**
6
6
  * Abstract base class for document transformation systems.
7
7
  *
@@ -12,7 +12,7 @@ const runnable_js_1 = require("./runnable.cjs");
12
12
  * One example of this is a text splitter that splits a large document into
13
13
  * many smaller documents.
14
14
  */
15
- class BaseDocumentTransformer extends runnable_js_1.Runnable {
15
+ class BaseDocumentTransformer extends index_js_1.Runnable {
16
16
  constructor() {
17
17
  super(...arguments);
18
18
  Object.defineProperty(this, "lc_namespace", {
@@ -1,6 +1,6 @@
1
1
  import { BaseCallbackConfig } from "../callbacks/manager.js";
2
2
  import { Document } from "../document.js";
3
- import { Runnable } from "./runnable.js";
3
+ import { Runnable } from "./runnable/index.js";
4
4
  /**
5
5
  * Abstract base class for document transformation systems.
6
6
  *
@@ -1,4 +1,4 @@
1
- import { Runnable } from "./runnable.js";
1
+ import { Runnable } from "./runnable/index.js";
2
2
  /**
3
3
  * Abstract base class for document transformation systems.
4
4
  *
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.OutputParserException = exports.BytesOutputParser = exports.StringOutputParser = exports.BaseTransformOutputParser = exports.BaseOutputParser = exports.BaseLLMOutputParser = void 0;
4
- const runnable_js_1 = require("./runnable.cjs");
4
+ const index_js_1 = require("./runnable/index.cjs");
5
5
  /**
6
6
  * Abstract base class for parsing the output of a Large Language Model
7
7
  * (LLM) call. It provides methods for parsing the result of an LLM call
8
8
  * and invoking the parser with a given input.
9
9
  */
10
- class BaseLLMOutputParser extends runnable_js_1.Runnable {
10
+ class BaseLLMOutputParser extends index_js_1.Runnable {
11
11
  /**
12
12
  * Parses the result of an LLM call with a given prompt. By default, it
13
13
  * simply calls `parseResult`.
@@ -1,6 +1,7 @@
1
1
  import { BaseCallbackConfig, Callbacks } from "../callbacks/manager.js";
2
2
  import { BasePromptValue, Generation, ChatGeneration, BaseMessage } from "./index.js";
3
- import { Runnable, RunnableConfig } from "./runnable.js";
3
+ import { Runnable } from "./runnable/index.js";
4
+ import { RunnableConfig } from "./runnable/config.js";
4
5
  /**
5
6
  * Options for formatting instructions.
6
7
  */
@@ -1,4 +1,4 @@
1
- import { Runnable } from "./runnable.js";
1
+ import { Runnable } from "./runnable/index.js";
2
2
  /**
3
3
  * Abstract base class for parsing the output of a Large Language Model
4
4
  * (LLM) call. It provides methods for parsing the result of an LLM call
@@ -2,13 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BaseRetriever = void 0;
4
4
  const manager_js_1 = require("../callbacks/manager.cjs");
5
- const runnable_js_1 = require("./runnable.cjs");
5
+ const index_js_1 = require("./runnable/index.cjs");
6
6
  /**
7
7
  * Abstract base class for a Document retrieval system. A retrieval system
8
8
  * is defined as something that can take string queries and return the
9
9
  * most 'relevant' Documents from some source.
10
10
  */
11
- class BaseRetriever extends runnable_js_1.Runnable {
11
+ class BaseRetriever extends index_js_1.Runnable {
12
12
  constructor(fields) {
13
13
  super(fields);
14
14
  Object.defineProperty(this, "callbacks", {
@@ -1,6 +1,7 @@
1
1
  import { BaseCallbackConfig, CallbackManagerForRetrieverRun, Callbacks } from "../callbacks/manager.js";
2
2
  import { Document } from "../document.js";
3
- import { Runnable, RunnableConfig } from "./runnable.js";
3
+ import { Runnable } from "./runnable/index.js";
4
+ import { RunnableConfig } from "./runnable/config.js";
4
5
  /**
5
6
  * Base Retriever class. All indexes should extend this class.
6
7
  */
@@ -1,5 +1,5 @@
1
1
  import { CallbackManager, parseCallbackConfigArg, } from "../callbacks/manager.js";
2
- import { Runnable } from "./runnable.js";
2
+ import { Runnable } from "./runnable/index.js";
3
3
  /**
4
4
  * Abstract base class for a Document retrieval system. A retrieval system
5
5
  * is defined as something that can take string queries and return the
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getCallbackMangerForConfig = void 0;
4
+ const manager_js_1 = require("../../callbacks/manager.cjs");
5
+ async function getCallbackMangerForConfig(config) {
6
+ return manager_js_1.CallbackManager.configure(config?.callbacks, undefined, config?.tags, undefined, config?.metadata);
7
+ }
8
+ exports.getCallbackMangerForConfig = getCallbackMangerForConfig;
@@ -0,0 +1,3 @@
1
+ import { BaseCallbackConfig, CallbackManager } from "../../callbacks/manager.js";
2
+ export type RunnableConfig = BaseCallbackConfig;
3
+ export declare function getCallbackMangerForConfig(config?: RunnableConfig): Promise<CallbackManager | undefined>;
@@ -0,0 +1,4 @@
1
+ import { CallbackManager, } from "../../callbacks/manager.js";
2
+ export async function getCallbackMangerForConfig(config) {
3
+ return CallbackManager.configure(config?.callbacks, undefined, config?.tags, undefined, config?.metadata);
4
+ }