langchain 0.0.129 → 0.0.131
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.
- package/dist/agents/chat/index.cjs +3 -0
- package/dist/agents/chat/index.d.ts +1 -0
- package/dist/agents/chat/index.js +3 -0
- package/dist/agents/chat_convo/index.cjs +3 -0
- package/dist/agents/chat_convo/index.d.ts +1 -0
- package/dist/agents/chat_convo/index.js +3 -0
- package/dist/agents/executor.cjs +3 -0
- package/dist/agents/executor.d.ts +1 -0
- package/dist/agents/executor.js +3 -0
- package/dist/agents/mrkl/index.cjs +3 -0
- package/dist/agents/mrkl/index.d.ts +1 -0
- package/dist/agents/mrkl/index.js +3 -0
- package/dist/agents/openai/index.cjs +3 -0
- package/dist/agents/openai/index.d.ts +1 -0
- package/dist/agents/openai/index.js +3 -0
- package/dist/agents/structured_chat/index.cjs +3 -0
- package/dist/agents/structured_chat/index.d.ts +1 -0
- package/dist/agents/structured_chat/index.js +3 -0
- package/dist/callbacks/base.cjs +18 -0
- package/dist/callbacks/base.d.ts +15 -0
- package/dist/callbacks/base.js +19 -1
- package/dist/callbacks/manager.cjs +1 -1
- package/dist/callbacks/manager.js +1 -1
- package/dist/chains/analyze_documents_chain.cjs +3 -0
- package/dist/chains/analyze_documents_chain.d.ts +1 -0
- package/dist/chains/analyze_documents_chain.js +3 -0
- package/dist/chains/combine_docs_chain.cjs +9 -0
- package/dist/chains/combine_docs_chain.d.ts +3 -0
- package/dist/chains/combine_docs_chain.js +9 -0
- package/dist/chains/constitutional_ai/constitutional_chain.cjs +3 -0
- package/dist/chains/constitutional_ai/constitutional_chain.d.ts +1 -0
- package/dist/chains/constitutional_ai/constitutional_chain.js +3 -0
- package/dist/chains/conversation.cjs +3 -0
- package/dist/chains/conversation.d.ts +1 -0
- package/dist/chains/conversation.js +3 -0
- package/dist/chains/conversational_retrieval_chain.cjs +3 -0
- package/dist/chains/conversational_retrieval_chain.d.ts +1 -0
- package/dist/chains/conversational_retrieval_chain.js +3 -0
- package/dist/chains/llm_chain.cjs +3 -0
- package/dist/chains/llm_chain.d.ts +1 -0
- package/dist/chains/llm_chain.js +3 -0
- package/dist/chains/openai_functions/openapi.cjs +3 -0
- package/dist/chains/openai_functions/openapi.js +3 -0
- package/dist/chains/openai_moderation.cjs +3 -0
- package/dist/chains/openai_moderation.d.ts +1 -0
- package/dist/chains/openai_moderation.js +3 -0
- package/dist/chains/retrieval_qa.cjs +3 -0
- package/dist/chains/retrieval_qa.d.ts +1 -0
- package/dist/chains/retrieval_qa.js +3 -0
- package/dist/chains/router/multi_route.cjs +3 -0
- package/dist/chains/router/multi_route.d.ts +1 -0
- package/dist/chains/router/multi_route.js +3 -0
- package/dist/chains/sequential_chain.cjs +6 -0
- package/dist/chains/sequential_chain.d.ts +2 -0
- package/dist/chains/sequential_chain.js +6 -0
- package/dist/chains/sql_db/sql_db_chain.cjs +3 -0
- package/dist/chains/sql_db/sql_db_chain.d.ts +1 -0
- package/dist/chains/sql_db/sql_db_chain.js +3 -0
- package/dist/chains/transform.cjs +3 -0
- package/dist/chains/transform.d.ts +1 -0
- package/dist/chains/transform.js +3 -0
- package/dist/chains/vector_db_qa.cjs +3 -0
- package/dist/chains/vector_db_qa.d.ts +1 -0
- package/dist/chains/vector_db_qa.js +3 -0
- package/dist/chat_models/anthropic.cjs +3 -0
- package/dist/chat_models/anthropic.d.ts +1 -0
- package/dist/chat_models/anthropic.js +3 -0
- package/dist/chat_models/baiduwenxin.cjs +3 -13
- package/dist/chat_models/baiduwenxin.d.ts +1 -3
- package/dist/chat_models/baiduwenxin.js +3 -13
- package/dist/chat_models/googlepalm.cjs +9 -0
- package/dist/chat_models/googlepalm.d.ts +2 -0
- package/dist/chat_models/googlepalm.js +9 -0
- package/dist/chat_models/googlevertexai.cjs +9 -0
- package/dist/chat_models/googlevertexai.d.ts +2 -0
- package/dist/chat_models/googlevertexai.js +9 -0
- package/dist/chat_models/ollama.cjs +3 -0
- package/dist/chat_models/ollama.d.ts +1 -0
- package/dist/chat_models/ollama.js +3 -0
- package/dist/chat_models/openai.cjs +19 -5
- package/dist/chat_models/openai.d.ts +7 -5
- package/dist/chat_models/openai.js +19 -5
- package/dist/document_loaders/web/youtube.cjs +77 -0
- package/dist/document_loaders/web/youtube.d.ts +17 -0
- package/dist/document_loaders/web/youtube.js +73 -0
- package/dist/document_transformers/html_to_text.cjs +3 -0
- package/dist/document_transformers/html_to_text.d.ts +1 -0
- package/dist/document_transformers/html_to_text.js +3 -0
- package/dist/document_transformers/mozilla_readability.cjs +3 -0
- package/dist/document_transformers/mozilla_readability.d.ts +1 -0
- package/dist/document_transformers/mozilla_readability.js +3 -0
- package/dist/document_transformers/openai_functions.cjs +3 -0
- package/dist/document_transformers/openai_functions.d.ts +1 -0
- package/dist/document_transformers/openai_functions.js +3 -0
- package/dist/embeddings/cohere.cjs +16 -13
- package/dist/embeddings/cohere.js +16 -13
- package/dist/embeddings/googlevertexai.cjs +1 -1
- package/dist/embeddings/googlevertexai.js +1 -1
- package/dist/embeddings/openai.cjs +27 -21
- package/dist/embeddings/openai.js +27 -21
- package/dist/evaluation/qa/eval_chain.cjs +3 -0
- package/dist/evaluation/qa/eval_chain.d.ts +1 -0
- package/dist/evaluation/qa/eval_chain.js +3 -0
- package/dist/experimental/babyagi/agent.cjs +3 -0
- package/dist/experimental/babyagi/agent.d.ts +1 -0
- package/dist/experimental/babyagi/agent.js +3 -0
- package/dist/experimental/babyagi/task_creation.cjs +3 -0
- package/dist/experimental/babyagi/task_creation.d.ts +1 -0
- package/dist/experimental/babyagi/task_creation.js +3 -0
- package/dist/experimental/babyagi/task_execution.cjs +3 -0
- package/dist/experimental/babyagi/task_execution.d.ts +1 -0
- package/dist/experimental/babyagi/task_execution.js +3 -0
- package/dist/experimental/babyagi/task_prioritization.cjs +3 -0
- package/dist/experimental/babyagi/task_prioritization.d.ts +1 -0
- package/dist/experimental/babyagi/task_prioritization.js +3 -0
- package/dist/experimental/generative_agents/generative_agent.cjs +3 -0
- package/dist/experimental/generative_agents/generative_agent.d.ts +1 -0
- package/dist/experimental/generative_agents/generative_agent.js +3 -0
- package/dist/experimental/generative_agents/generative_agent_memory.cjs +3 -0
- package/dist/experimental/generative_agents/generative_agent_memory.d.ts +1 -0
- package/dist/experimental/generative_agents/generative_agent_memory.js +3 -0
- package/dist/experimental/plan_and_execute/agent_executor.cjs +3 -0
- package/dist/experimental/plan_and_execute/agent_executor.d.ts +1 -0
- package/dist/experimental/plan_and_execute/agent_executor.js +3 -0
- package/dist/llms/cohere.cjs +3 -0
- package/dist/llms/cohere.d.ts +1 -0
- package/dist/llms/cohere.js +3 -0
- package/dist/llms/ollama.cjs +3 -0
- package/dist/llms/ollama.d.ts +1 -0
- package/dist/llms/ollama.js +3 -0
- package/dist/llms/openai-chat.cjs +18 -4
- package/dist/llms/openai-chat.d.ts +6 -4
- package/dist/llms/openai-chat.js +18 -4
- package/dist/llms/openai.cjs +20 -6
- package/dist/llms/openai.d.ts +5 -3
- package/dist/llms/openai.js +20 -6
- package/dist/llms/replicate.cjs +3 -0
- package/dist/llms/replicate.d.ts +1 -0
- package/dist/llms/replicate.js +3 -0
- package/dist/load/import_constants.cjs +1 -0
- package/dist/load/import_constants.js +1 -0
- package/dist/load/index.cjs +7 -1
- package/dist/load/index.js +7 -1
- package/dist/load/serializable.cjs +42 -3
- package/dist/load/serializable.d.ts +16 -0
- package/dist/load/serializable.js +40 -2
- package/dist/output_parsers/combining.cjs +3 -0
- package/dist/output_parsers/combining.d.ts +1 -0
- package/dist/output_parsers/combining.js +3 -0
- package/dist/output_parsers/fix.cjs +3 -0
- package/dist/output_parsers/fix.d.ts +1 -0
- package/dist/output_parsers/fix.js +3 -0
- package/dist/output_parsers/list.cjs +3 -0
- package/dist/output_parsers/list.d.ts +1 -0
- package/dist/output_parsers/list.js +3 -0
- package/dist/output_parsers/noop.cjs +3 -0
- package/dist/output_parsers/noop.d.ts +1 -0
- package/dist/output_parsers/noop.js +3 -0
- package/dist/output_parsers/openai_functions.cjs +9 -0
- package/dist/output_parsers/openai_functions.d.ts +3 -0
- package/dist/output_parsers/openai_functions.js +9 -0
- package/dist/output_parsers/regex.cjs +3 -0
- package/dist/output_parsers/regex.d.ts +1 -0
- package/dist/output_parsers/regex.js +3 -0
- package/dist/output_parsers/structured.cjs +6 -0
- package/dist/output_parsers/structured.d.ts +2 -0
- package/dist/output_parsers/structured.js +6 -0
- package/dist/prompts/chat.cjs +21 -0
- package/dist/prompts/chat.d.ts +7 -0
- package/dist/prompts/chat.js +21 -0
- package/dist/prompts/pipeline.cjs +3 -0
- package/dist/prompts/pipeline.d.ts +1 -0
- package/dist/prompts/pipeline.js +3 -0
- package/dist/prompts/prompt.cjs +3 -0
- package/dist/prompts/prompt.d.ts +1 -0
- package/dist/prompts/prompt.js +3 -0
- package/dist/retrievers/amazon_kendra.cjs +3 -0
- package/dist/retrievers/amazon_kendra.d.ts +1 -0
- package/dist/retrievers/amazon_kendra.js +3 -0
- package/dist/retrievers/contextual_compression.cjs +3 -0
- package/dist/retrievers/contextual_compression.d.ts +1 -0
- package/dist/retrievers/contextual_compression.js +3 -0
- package/dist/retrievers/databerry.cjs +3 -0
- package/dist/retrievers/databerry.d.ts +1 -0
- package/dist/retrievers/databerry.js +3 -0
- package/dist/retrievers/hyde.cjs +3 -0
- package/dist/retrievers/hyde.d.ts +1 -0
- package/dist/retrievers/hyde.js +3 -0
- package/dist/retrievers/metal.cjs +3 -0
- package/dist/retrievers/metal.d.ts +1 -0
- package/dist/retrievers/metal.js +3 -0
- package/dist/retrievers/parent_document.cjs +3 -0
- package/dist/retrievers/parent_document.d.ts +1 -0
- package/dist/retrievers/parent_document.js +3 -0
- package/dist/retrievers/self_query/index.cjs +3 -0
- package/dist/retrievers/self_query/index.d.ts +1 -0
- package/dist/retrievers/self_query/index.js +3 -0
- package/dist/retrievers/self_query/supabase.cjs +28 -7
- package/dist/retrievers/self_query/supabase.d.ts +2 -2
- package/dist/retrievers/self_query/supabase.js +29 -8
- package/dist/retrievers/self_query/supabase_utils.cjs +177 -0
- package/dist/retrievers/self_query/supabase_utils.d.ts +24 -0
- package/dist/retrievers/self_query/supabase_utils.js +172 -0
- package/dist/retrievers/self_query/utils.cjs +19 -3
- package/dist/retrievers/self_query/utils.d.ts +3 -0
- package/dist/retrievers/self_query/utils.js +15 -2
- package/dist/retrievers/self_query/weaviate.cjs +3 -14
- package/dist/retrievers/self_query/weaviate.js +1 -12
- package/dist/retrievers/supabase.cjs +3 -0
- package/dist/retrievers/supabase.d.ts +1 -0
- package/dist/retrievers/supabase.js +3 -0
- package/dist/retrievers/time_weighted.cjs +3 -0
- package/dist/retrievers/time_weighted.d.ts +1 -0
- package/dist/retrievers/time_weighted.js +3 -0
- package/dist/retrievers/vespa.cjs +3 -0
- package/dist/retrievers/vespa.d.ts +1 -0
- package/dist/retrievers/vespa.js +3 -0
- package/dist/retrievers/zep.cjs +3 -0
- package/dist/retrievers/zep.d.ts +1 -0
- package/dist/retrievers/zep.js +3 -0
- package/dist/schema/index.cjs +32 -2
- package/dist/schema/index.d.ts +14 -0
- package/dist/schema/index.js +32 -2
- package/dist/schema/output_parser.cjs +6 -0
- package/dist/schema/output_parser.d.ts +2 -0
- package/dist/schema/output_parser.js +6 -0
- package/dist/schema/runnable.cjs +25 -7
- package/dist/schema/runnable.d.ts +6 -0
- package/dist/schema/runnable.js +25 -7
- package/dist/stores/message/utils.cjs +5 -0
- package/dist/stores/message/utils.js +6 -1
- package/dist/text_splitter.cjs +9 -0
- package/dist/text_splitter.d.ts +3 -0
- package/dist/text_splitter.js +9 -0
- package/dist/tools/IFTTTWebhook.cjs +3 -0
- package/dist/tools/IFTTTWebhook.d.ts +1 -0
- package/dist/tools/IFTTTWebhook.js +3 -0
- package/dist/tools/aiplugin.cjs +3 -0
- package/dist/tools/aiplugin.d.ts +1 -0
- package/dist/tools/aiplugin.js +3 -0
- package/dist/tools/aws_sfn.cjs +9 -0
- package/dist/tools/aws_sfn.d.ts +3 -0
- package/dist/tools/aws_sfn.js +9 -0
- package/dist/tools/bingserpapi.cjs +3 -0
- package/dist/tools/bingserpapi.d.ts +1 -0
- package/dist/tools/bingserpapi.js +3 -0
- package/dist/tools/brave_search.cjs +3 -0
- package/dist/tools/brave_search.d.ts +1 -0
- package/dist/tools/brave_search.js +3 -0
- package/dist/tools/calculator.cjs +3 -0
- package/dist/tools/calculator.d.ts +1 -0
- package/dist/tools/calculator.js +3 -0
- package/dist/tools/chain.cjs +3 -0
- package/dist/tools/chain.d.ts +1 -0
- package/dist/tools/chain.js +3 -0
- package/dist/tools/dadjokeapi.cjs +3 -0
- package/dist/tools/dadjokeapi.d.ts +1 -0
- package/dist/tools/dadjokeapi.js +3 -0
- package/dist/tools/dataforseo_api_search.cjs +3 -0
- package/dist/tools/dataforseo_api_search.d.ts +1 -0
- package/dist/tools/dataforseo_api_search.js +3 -0
- package/dist/tools/dynamic.cjs +6 -0
- package/dist/tools/dynamic.d.ts +2 -0
- package/dist/tools/dynamic.js +6 -0
- package/dist/tools/fs.cjs +6 -0
- package/dist/tools/fs.d.ts +2 -0
- package/dist/tools/fs.js +6 -0
- package/dist/tools/google_custom_search.cjs +3 -0
- package/dist/tools/google_custom_search.d.ts +1 -0
- package/dist/tools/google_custom_search.js +3 -0
- package/dist/tools/json.cjs +7 -1
- package/dist/tools/json.d.ts +2 -0
- package/dist/tools/json.js +7 -1
- package/dist/tools/requests.cjs +8 -2
- package/dist/tools/requests.d.ts +2 -0
- package/dist/tools/requests.js +8 -2
- package/dist/tools/searxng_search.cjs +3 -0
- package/dist/tools/searxng_search.d.ts +1 -0
- package/dist/tools/searxng_search.js +3 -0
- package/dist/tools/serpapi.cjs +3 -0
- package/dist/tools/serpapi.d.ts +1 -0
- package/dist/tools/serpapi.js +3 -0
- package/dist/tools/serper.cjs +3 -0
- package/dist/tools/serper.d.ts +1 -0
- package/dist/tools/serper.js +3 -0
- package/dist/tools/sql.cjs +12 -0
- package/dist/tools/sql.d.ts +4 -0
- package/dist/tools/sql.js +12 -0
- package/dist/tools/vectorstore.cjs +3 -0
- package/dist/tools/vectorstore.d.ts +1 -0
- package/dist/tools/vectorstore.js +3 -0
- package/dist/tools/webbrowser.cjs +3 -0
- package/dist/tools/webbrowser.d.ts +1 -0
- package/dist/tools/webbrowser.js +3 -0
- package/dist/tools/wikipedia_query_run.cjs +3 -0
- package/dist/tools/wikipedia_query_run.d.ts +1 -0
- package/dist/tools/wikipedia_query_run.js +3 -0
- package/dist/tools/zapier.cjs +3 -0
- package/dist/tools/zapier.d.ts +1 -0
- package/dist/tools/zapier.js +3 -0
- package/dist/vectorstores/base.cjs +3 -0
- package/dist/vectorstores/base.d.ts +1 -0
- package/dist/vectorstores/base.js +3 -0
- package/dist/vectorstores/elasticsearch.cjs +1 -0
- package/dist/vectorstores/elasticsearch.js +1 -0
- package/dist/vectorstores/hnswlib.cjs +19 -0
- package/dist/vectorstores/hnswlib.d.ts +3 -0
- package/dist/vectorstores/hnswlib.js +19 -0
- package/dist/vectorstores/myscale.cjs +1 -1
- package/dist/vectorstores/myscale.js +1 -1
- package/dist/vectorstores/supabase.d.ts +1 -2
- package/document_loaders/web/youtube.cjs +1 -0
- package/document_loaders/web/youtube.d.ts +1 -0
- package/document_loaders/web/youtube.js +1 -0
- package/package.json +27 -3
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Serializable = void 0;
|
|
3
|
+
exports.Serializable = exports.get_lc_unique_name = void 0;
|
|
4
4
|
const map_keys_js_1 = require("./map_keys.cjs");
|
|
5
5
|
function shallowCopy(obj) {
|
|
6
6
|
return Array.isArray(obj) ? [...obj] : { ...obj };
|
|
@@ -28,7 +28,46 @@ function replaceSecrets(root, secretsMap) {
|
|
|
28
28
|
}
|
|
29
29
|
return result;
|
|
30
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Get a unique name for the module, rather than parent class implementations.
|
|
33
|
+
* Should not be subclassed, subclass lc_name above instead.
|
|
34
|
+
*/
|
|
35
|
+
function get_lc_unique_name(
|
|
36
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
37
|
+
serializableClass) {
|
|
38
|
+
// "super" here would refer to the parent class of Serializable,
|
|
39
|
+
// when we want the parent class of the module actually calling this method.
|
|
40
|
+
const parentClass = Object.getPrototypeOf(serializableClass);
|
|
41
|
+
const lcNameIsSubclassed = typeof serializableClass.lc_name === "function" &&
|
|
42
|
+
(typeof parentClass.lc_name !== "function" ||
|
|
43
|
+
serializableClass.lc_name() !== parentClass.lc_name());
|
|
44
|
+
if (lcNameIsSubclassed) {
|
|
45
|
+
return serializableClass.lc_name();
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
return serializableClass.name;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports.get_lc_unique_name = get_lc_unique_name;
|
|
31
52
|
class Serializable {
|
|
53
|
+
/**
|
|
54
|
+
* The name of the serializable. Override to provide an alias or
|
|
55
|
+
* to preserve the serialized module name in minified environments.
|
|
56
|
+
*
|
|
57
|
+
* Implemented as a static method to support loading logic.
|
|
58
|
+
*/
|
|
59
|
+
static lc_name() {
|
|
60
|
+
return this.name;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* The final serialized identifier for the module.
|
|
64
|
+
*/
|
|
65
|
+
get lc_id() {
|
|
66
|
+
return [
|
|
67
|
+
...this.lc_namespace,
|
|
68
|
+
get_lc_unique_name(this.constructor),
|
|
69
|
+
];
|
|
70
|
+
}
|
|
32
71
|
/**
|
|
33
72
|
* A map of secrets, which will be omitted from serialization.
|
|
34
73
|
* Keys are paths to the secret in constructor args, e.g. "foo.bar.baz".
|
|
@@ -107,7 +146,7 @@ class Serializable {
|
|
|
107
146
|
return {
|
|
108
147
|
lc: 1,
|
|
109
148
|
type: "constructor",
|
|
110
|
-
id:
|
|
149
|
+
id: this.lc_id,
|
|
111
150
|
kwargs: (0, map_keys_js_1.mapKeys)(Object.keys(secrets).length ? replaceSecrets(kwargs, secrets) : kwargs, map_keys_js_1.keyToJson, aliases),
|
|
112
151
|
};
|
|
113
152
|
}
|
|
@@ -115,7 +154,7 @@ class Serializable {
|
|
|
115
154
|
return {
|
|
116
155
|
lc: 1,
|
|
117
156
|
type: "not_implemented",
|
|
118
|
-
id:
|
|
157
|
+
id: this.lc_id,
|
|
119
158
|
};
|
|
120
159
|
}
|
|
121
160
|
}
|
|
@@ -12,6 +12,11 @@ export interface SerializedSecret extends BaseSerialized<"secret"> {
|
|
|
12
12
|
export interface SerializedNotImplemented extends BaseSerialized<"not_implemented"> {
|
|
13
13
|
}
|
|
14
14
|
export type Serialized = SerializedConstructor | SerializedSecret | SerializedNotImplemented;
|
|
15
|
+
/**
|
|
16
|
+
* Get a unique name for the module, rather than parent class implementations.
|
|
17
|
+
* Should not be subclassed, subclass lc_name above instead.
|
|
18
|
+
*/
|
|
19
|
+
export declare function get_lc_unique_name(serializableClass: typeof Serializable): string;
|
|
15
20
|
export declare abstract class Serializable {
|
|
16
21
|
lc_serializable: boolean;
|
|
17
22
|
lc_kwargs: SerializedFields;
|
|
@@ -20,6 +25,17 @@ export declare abstract class Serializable {
|
|
|
20
25
|
* Usually should be the same as the entrypoint the class is exported from.
|
|
21
26
|
*/
|
|
22
27
|
abstract lc_namespace: string[];
|
|
28
|
+
/**
|
|
29
|
+
* The name of the serializable. Override to provide an alias or
|
|
30
|
+
* to preserve the serialized module name in minified environments.
|
|
31
|
+
*
|
|
32
|
+
* Implemented as a static method to support loading logic.
|
|
33
|
+
*/
|
|
34
|
+
static lc_name(): string;
|
|
35
|
+
/**
|
|
36
|
+
* The final serialized identifier for the module.
|
|
37
|
+
*/
|
|
38
|
+
get lc_id(): string[];
|
|
23
39
|
/**
|
|
24
40
|
* A map of secrets, which will be omitted from serialization.
|
|
25
41
|
* Keys are paths to the secret in constructor args, e.g. "foo.bar.baz".
|
|
@@ -25,7 +25,45 @@ function replaceSecrets(root, secretsMap) {
|
|
|
25
25
|
}
|
|
26
26
|
return result;
|
|
27
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* Get a unique name for the module, rather than parent class implementations.
|
|
30
|
+
* Should not be subclassed, subclass lc_name above instead.
|
|
31
|
+
*/
|
|
32
|
+
export function get_lc_unique_name(
|
|
33
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
34
|
+
serializableClass) {
|
|
35
|
+
// "super" here would refer to the parent class of Serializable,
|
|
36
|
+
// when we want the parent class of the module actually calling this method.
|
|
37
|
+
const parentClass = Object.getPrototypeOf(serializableClass);
|
|
38
|
+
const lcNameIsSubclassed = typeof serializableClass.lc_name === "function" &&
|
|
39
|
+
(typeof parentClass.lc_name !== "function" ||
|
|
40
|
+
serializableClass.lc_name() !== parentClass.lc_name());
|
|
41
|
+
if (lcNameIsSubclassed) {
|
|
42
|
+
return serializableClass.lc_name();
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
return serializableClass.name;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
28
48
|
export class Serializable {
|
|
49
|
+
/**
|
|
50
|
+
* The name of the serializable. Override to provide an alias or
|
|
51
|
+
* to preserve the serialized module name in minified environments.
|
|
52
|
+
*
|
|
53
|
+
* Implemented as a static method to support loading logic.
|
|
54
|
+
*/
|
|
55
|
+
static lc_name() {
|
|
56
|
+
return this.name;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* The final serialized identifier for the module.
|
|
60
|
+
*/
|
|
61
|
+
get lc_id() {
|
|
62
|
+
return [
|
|
63
|
+
...this.lc_namespace,
|
|
64
|
+
get_lc_unique_name(this.constructor),
|
|
65
|
+
];
|
|
66
|
+
}
|
|
29
67
|
/**
|
|
30
68
|
* A map of secrets, which will be omitted from serialization.
|
|
31
69
|
* Keys are paths to the secret in constructor args, e.g. "foo.bar.baz".
|
|
@@ -104,7 +142,7 @@ export class Serializable {
|
|
|
104
142
|
return {
|
|
105
143
|
lc: 1,
|
|
106
144
|
type: "constructor",
|
|
107
|
-
id:
|
|
145
|
+
id: this.lc_id,
|
|
108
146
|
kwargs: mapKeys(Object.keys(secrets).length ? replaceSecrets(kwargs, secrets) : kwargs, keyToJson, aliases),
|
|
109
147
|
};
|
|
110
148
|
}
|
|
@@ -112,7 +150,7 @@ export class Serializable {
|
|
|
112
150
|
return {
|
|
113
151
|
lc: 1,
|
|
114
152
|
type: "not_implemented",
|
|
115
|
-
id:
|
|
153
|
+
id: this.lc_id,
|
|
116
154
|
};
|
|
117
155
|
}
|
|
118
156
|
}
|
|
@@ -7,6 +7,9 @@ const output_parser_js_1 = require("../schema/output_parser.cjs");
|
|
|
7
7
|
* @augments BaseOutputParser
|
|
8
8
|
*/
|
|
9
9
|
class CombiningOutputParser extends output_parser_js_1.BaseOutputParser {
|
|
10
|
+
static lc_name() {
|
|
11
|
+
return "CombiningOutputParser";
|
|
12
|
+
}
|
|
10
13
|
constructor(fields, ...parsers) {
|
|
11
14
|
if (parsers.length > 0 || !("parsers" in fields)) {
|
|
12
15
|
// eslint-disable-next-line no-param-reassign
|
|
@@ -9,6 +9,7 @@ export interface CombiningOutputParserFields {
|
|
|
9
9
|
* @augments BaseOutputParser
|
|
10
10
|
*/
|
|
11
11
|
export declare class CombiningOutputParser extends BaseOutputParser<object> {
|
|
12
|
+
static lc_name(): string;
|
|
12
13
|
lc_namespace: string[];
|
|
13
14
|
lc_serializable: boolean;
|
|
14
15
|
parsers: BaseOutputParser[];
|
|
@@ -4,6 +4,9 @@ import { BaseOutputParser } from "../schema/output_parser.js";
|
|
|
4
4
|
* @augments BaseOutputParser
|
|
5
5
|
*/
|
|
6
6
|
export class CombiningOutputParser extends BaseOutputParser {
|
|
7
|
+
static lc_name() {
|
|
8
|
+
return "CombiningOutputParser";
|
|
9
|
+
}
|
|
7
10
|
constructor(fields, ...parsers) {
|
|
8
11
|
if (parsers.length > 0 || !("parsers" in fields)) {
|
|
9
12
|
// eslint-disable-next-line no-param-reassign
|
|
@@ -5,6 +5,9 @@ const output_parser_js_1 = require("../schema/output_parser.cjs");
|
|
|
5
5
|
const llm_chain_js_1 = require("../chains/llm_chain.cjs");
|
|
6
6
|
const prompts_js_1 = require("./prompts.cjs");
|
|
7
7
|
class OutputFixingParser extends output_parser_js_1.BaseOutputParser {
|
|
8
|
+
static lc_name() {
|
|
9
|
+
return "OutputFixingParser";
|
|
10
|
+
}
|
|
8
11
|
static fromLLM(llm, parser, fields) {
|
|
9
12
|
const prompt = fields?.prompt ?? prompts_js_1.NAIVE_FIX_PROMPT;
|
|
10
13
|
const chain = new llm_chain_js_1.LLMChain({ llm, prompt });
|
|
@@ -4,6 +4,7 @@ import { LLMChain } from "../chains/llm_chain.js";
|
|
|
4
4
|
import { BaseLanguageModel } from "../base_language/index.js";
|
|
5
5
|
import { Callbacks } from "../callbacks/manager.js";
|
|
6
6
|
export declare class OutputFixingParser<T> extends BaseOutputParser<T> {
|
|
7
|
+
static lc_name(): string;
|
|
7
8
|
lc_namespace: string[];
|
|
8
9
|
lc_serializable: boolean;
|
|
9
10
|
parser: BaseOutputParser<T>;
|
|
@@ -2,6 +2,9 @@ import { BaseOutputParser, OutputParserException, } from "../schema/output_parse
|
|
|
2
2
|
import { LLMChain } from "../chains/llm_chain.js";
|
|
3
3
|
import { NAIVE_FIX_PROMPT } from "./prompts.js";
|
|
4
4
|
export class OutputFixingParser extends BaseOutputParser {
|
|
5
|
+
static lc_name() {
|
|
6
|
+
return "OutputFixingParser";
|
|
7
|
+
}
|
|
5
8
|
static fromLLM(llm, parser, fields) {
|
|
6
9
|
const prompt = fields?.prompt ?? NAIVE_FIX_PROMPT;
|
|
7
10
|
const chain = new LLMChain({ llm, prompt });
|
|
@@ -10,6 +10,7 @@ export declare abstract class ListOutputParser extends BaseOutputParser<string[]
|
|
|
10
10
|
* @augments ListOutputParser
|
|
11
11
|
*/
|
|
12
12
|
export declare class CommaSeparatedListOutputParser extends ListOutputParser {
|
|
13
|
+
static lc_name(): string;
|
|
13
14
|
lc_namespace: string[];
|
|
14
15
|
lc_serializable: boolean;
|
|
15
16
|
parse(text: string): Promise<string[]>;
|
|
@@ -3,6 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.JsonKeyOutputFunctionsParser = exports.JsonOutputFunctionsParser = exports.OutputFunctionsParser = void 0;
|
|
4
4
|
const output_parser_js_1 = require("../schema/output_parser.cjs");
|
|
5
5
|
class OutputFunctionsParser extends output_parser_js_1.BaseLLMOutputParser {
|
|
6
|
+
static lc_name() {
|
|
7
|
+
return "OutputFunctionsParser";
|
|
8
|
+
}
|
|
6
9
|
constructor(config) {
|
|
7
10
|
super();
|
|
8
11
|
Object.defineProperty(this, "lc_namespace", {
|
|
@@ -47,6 +50,9 @@ class OutputFunctionsParser extends output_parser_js_1.BaseLLMOutputParser {
|
|
|
47
50
|
}
|
|
48
51
|
exports.OutputFunctionsParser = OutputFunctionsParser;
|
|
49
52
|
class JsonOutputFunctionsParser extends output_parser_js_1.BaseLLMOutputParser {
|
|
53
|
+
static lc_name() {
|
|
54
|
+
return "JsonOutputFunctionsParser";
|
|
55
|
+
}
|
|
50
56
|
constructor(config) {
|
|
51
57
|
super();
|
|
52
58
|
Object.defineProperty(this, "lc_namespace", {
|
|
@@ -91,6 +97,9 @@ class JsonOutputFunctionsParser extends output_parser_js_1.BaseLLMOutputParser {
|
|
|
91
97
|
}
|
|
92
98
|
exports.JsonOutputFunctionsParser = JsonOutputFunctionsParser;
|
|
93
99
|
class JsonKeyOutputFunctionsParser extends output_parser_js_1.BaseLLMOutputParser {
|
|
100
|
+
static lc_name() {
|
|
101
|
+
return "JsonKeyOutputFunctionsParser";
|
|
102
|
+
}
|
|
94
103
|
constructor(fields) {
|
|
95
104
|
super(fields);
|
|
96
105
|
Object.defineProperty(this, "lc_namespace", {
|
|
@@ -4,6 +4,7 @@ import { Optional } from "../types/type-utils.js";
|
|
|
4
4
|
import { BaseLLMOutputParser } from "../schema/output_parser.js";
|
|
5
5
|
export type FunctionParameters = Optional<JsonSchema7ObjectType, "additionalProperties">;
|
|
6
6
|
export declare class OutputFunctionsParser extends BaseLLMOutputParser<string> {
|
|
7
|
+
static lc_name(): string;
|
|
7
8
|
lc_namespace: string[];
|
|
8
9
|
lc_serializable: boolean;
|
|
9
10
|
argsOnly: boolean;
|
|
@@ -13,6 +14,7 @@ export declare class OutputFunctionsParser extends BaseLLMOutputParser<string> {
|
|
|
13
14
|
parseResult(generations: Generation[] | ChatGeneration[]): Promise<string>;
|
|
14
15
|
}
|
|
15
16
|
export declare class JsonOutputFunctionsParser extends BaseLLMOutputParser<object> {
|
|
17
|
+
static lc_name(): string;
|
|
16
18
|
lc_namespace: string[];
|
|
17
19
|
lc_serializable: boolean;
|
|
18
20
|
outputParser: OutputFunctionsParser;
|
|
@@ -23,6 +25,7 @@ export declare class JsonOutputFunctionsParser extends BaseLLMOutputParser<objec
|
|
|
23
25
|
parseResult(generations: Generation[] | ChatGeneration[]): Promise<object>;
|
|
24
26
|
}
|
|
25
27
|
export declare class JsonKeyOutputFunctionsParser<T = object> extends BaseLLMOutputParser<T> {
|
|
28
|
+
static lc_name(): string;
|
|
26
29
|
lc_namespace: string[];
|
|
27
30
|
lc_serializable: boolean;
|
|
28
31
|
outputParser: JsonOutputFunctionsParser;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { BaseLLMOutputParser } from "../schema/output_parser.js";
|
|
2
2
|
export class OutputFunctionsParser extends BaseLLMOutputParser {
|
|
3
|
+
static lc_name() {
|
|
4
|
+
return "OutputFunctionsParser";
|
|
5
|
+
}
|
|
3
6
|
constructor(config) {
|
|
4
7
|
super();
|
|
5
8
|
Object.defineProperty(this, "lc_namespace", {
|
|
@@ -43,6 +46,9 @@ export class OutputFunctionsParser extends BaseLLMOutputParser {
|
|
|
43
46
|
}
|
|
44
47
|
}
|
|
45
48
|
export class JsonOutputFunctionsParser extends BaseLLMOutputParser {
|
|
49
|
+
static lc_name() {
|
|
50
|
+
return "JsonOutputFunctionsParser";
|
|
51
|
+
}
|
|
46
52
|
constructor(config) {
|
|
47
53
|
super();
|
|
48
54
|
Object.defineProperty(this, "lc_namespace", {
|
|
@@ -86,6 +92,9 @@ export class JsonOutputFunctionsParser extends BaseLLMOutputParser {
|
|
|
86
92
|
}
|
|
87
93
|
}
|
|
88
94
|
export class JsonKeyOutputFunctionsParser extends BaseLLMOutputParser {
|
|
95
|
+
static lc_name() {
|
|
96
|
+
return "JsonKeyOutputFunctionsParser";
|
|
97
|
+
}
|
|
89
98
|
constructor(fields) {
|
|
90
99
|
super(fields);
|
|
91
100
|
Object.defineProperty(this, "lc_namespace", {
|
|
@@ -7,6 +7,9 @@ const output_parser_js_1 = require("../schema/output_parser.cjs");
|
|
|
7
7
|
* @augments BaseOutputParser
|
|
8
8
|
*/
|
|
9
9
|
class RegexParser extends output_parser_js_1.BaseOutputParser {
|
|
10
|
+
static lc_name() {
|
|
11
|
+
return "RegexParser";
|
|
12
|
+
}
|
|
10
13
|
get lc_attributes() {
|
|
11
14
|
return {
|
|
12
15
|
regex: this.lc_kwargs.regex,
|
|
@@ -14,6 +14,7 @@ export interface RegexParserFields {
|
|
|
14
14
|
* @augments BaseOutputParser
|
|
15
15
|
*/
|
|
16
16
|
export declare class RegexParser extends BaseOutputParser<Record<string, string>> {
|
|
17
|
+
static lc_name(): string;
|
|
17
18
|
lc_namespace: string[];
|
|
18
19
|
lc_serializable: boolean;
|
|
19
20
|
get lc_attributes(): SerializedFields | undefined;
|
|
@@ -4,6 +4,9 @@ import { BaseOutputParser, OutputParserException, } from "../schema/output_parse
|
|
|
4
4
|
* @augments BaseOutputParser
|
|
5
5
|
*/
|
|
6
6
|
export class RegexParser extends BaseOutputParser {
|
|
7
|
+
static lc_name() {
|
|
8
|
+
return "RegexParser";
|
|
9
|
+
}
|
|
7
10
|
get lc_attributes() {
|
|
8
11
|
return {
|
|
9
12
|
regex: this.lc_kwargs.regex,
|
|
@@ -5,6 +5,9 @@ const zod_1 = require("zod");
|
|
|
5
5
|
const zod_to_json_schema_1 = require("zod-to-json-schema");
|
|
6
6
|
const output_parser_js_1 = require("../schema/output_parser.cjs");
|
|
7
7
|
class StructuredOutputParser extends output_parser_js_1.BaseOutputParser {
|
|
8
|
+
static lc_name() {
|
|
9
|
+
return "StructuredOutputParser";
|
|
10
|
+
}
|
|
8
11
|
toJSON() {
|
|
9
12
|
return this.toJSONNotImplemented();
|
|
10
13
|
}
|
|
@@ -61,6 +64,9 @@ ${JSON.stringify((0, zod_to_json_schema_1.zodToJsonSchema)(this.schema))}
|
|
|
61
64
|
}
|
|
62
65
|
exports.StructuredOutputParser = StructuredOutputParser;
|
|
63
66
|
class JsonMarkdownStructuredOutputParser extends StructuredOutputParser {
|
|
67
|
+
static lc_name() {
|
|
68
|
+
return "JsonMarkdownStructuredOutputParser";
|
|
69
|
+
}
|
|
64
70
|
getFormatInstructions(options) {
|
|
65
71
|
const interpolationDepth = options?.interpolationDepth ?? 1;
|
|
66
72
|
if (interpolationDepth < 1) {
|
|
@@ -8,6 +8,7 @@ export interface JsonMarkdownFormatInstructionsOptions extends FormatInstruction
|
|
|
8
8
|
}
|
|
9
9
|
export declare class StructuredOutputParser<T extends z.ZodTypeAny> extends BaseOutputParser<z.infer<T>> {
|
|
10
10
|
schema: T;
|
|
11
|
+
static lc_name(): string;
|
|
11
12
|
lc_namespace: string[];
|
|
12
13
|
toJSON(): import("../load/serializable.js").SerializedNotImplemented;
|
|
13
14
|
constructor(schema: T);
|
|
@@ -25,6 +26,7 @@ export declare class StructuredOutputParser<T extends z.ZodTypeAny> extends Base
|
|
|
25
26
|
parse(text: string): Promise<z.infer<T>>;
|
|
26
27
|
}
|
|
27
28
|
export declare class JsonMarkdownStructuredOutputParser<T extends z.ZodTypeAny> extends StructuredOutputParser<T> {
|
|
29
|
+
static lc_name(): string;
|
|
28
30
|
getFormatInstructions(options?: JsonMarkdownFormatInstructionsOptions): string;
|
|
29
31
|
private _schemaToInstruction;
|
|
30
32
|
static fromZodSchema<T extends z.ZodTypeAny>(schema: T): JsonMarkdownStructuredOutputParser<T>;
|
|
@@ -2,6 +2,9 @@ import { z } from "zod";
|
|
|
2
2
|
import { zodToJsonSchema } from "zod-to-json-schema";
|
|
3
3
|
import { BaseOutputParser, OutputParserException, } from "../schema/output_parser.js";
|
|
4
4
|
export class StructuredOutputParser extends BaseOutputParser {
|
|
5
|
+
static lc_name() {
|
|
6
|
+
return "StructuredOutputParser";
|
|
7
|
+
}
|
|
5
8
|
toJSON() {
|
|
6
9
|
return this.toJSONNotImplemented();
|
|
7
10
|
}
|
|
@@ -57,6 +60,9 @@ ${JSON.stringify(zodToJsonSchema(this.schema))}
|
|
|
57
60
|
}
|
|
58
61
|
}
|
|
59
62
|
export class JsonMarkdownStructuredOutputParser extends StructuredOutputParser {
|
|
63
|
+
static lc_name() {
|
|
64
|
+
return "JsonMarkdownStructuredOutputParser";
|
|
65
|
+
}
|
|
60
66
|
getFormatInstructions(options) {
|
|
61
67
|
const interpolationDepth = options?.interpolationDepth ?? 1;
|
|
62
68
|
if (interpolationDepth < 1) {
|
package/dist/prompts/chat.cjs
CHANGED
|
@@ -29,6 +29,9 @@ class BaseMessagePromptTemplate extends runnable_js_1.Runnable {
|
|
|
29
29
|
}
|
|
30
30
|
exports.BaseMessagePromptTemplate = BaseMessagePromptTemplate;
|
|
31
31
|
class ChatPromptValue extends index_js_1.BasePromptValue {
|
|
32
|
+
static lc_name() {
|
|
33
|
+
return "ChatPromptValue";
|
|
34
|
+
}
|
|
32
35
|
constructor(fields) {
|
|
33
36
|
if (Array.isArray(fields)) {
|
|
34
37
|
// eslint-disable-next-line no-param-reassign
|
|
@@ -64,6 +67,9 @@ class ChatPromptValue extends index_js_1.BasePromptValue {
|
|
|
64
67
|
}
|
|
65
68
|
exports.ChatPromptValue = ChatPromptValue;
|
|
66
69
|
class MessagesPlaceholder extends BaseMessagePromptTemplate {
|
|
70
|
+
static lc_name() {
|
|
71
|
+
return "MessagesPlaceholder";
|
|
72
|
+
}
|
|
67
73
|
constructor(fields) {
|
|
68
74
|
if (typeof fields === "string") {
|
|
69
75
|
// eslint-disable-next-line no-param-reassign
|
|
@@ -123,6 +129,9 @@ class BaseChatPromptTemplate extends base_js_1.BasePromptTemplate {
|
|
|
123
129
|
}
|
|
124
130
|
exports.BaseChatPromptTemplate = BaseChatPromptTemplate;
|
|
125
131
|
class ChatMessagePromptTemplate extends BaseMessageStringPromptTemplate {
|
|
132
|
+
static lc_name() {
|
|
133
|
+
return "ChatMessagePromptTemplate";
|
|
134
|
+
}
|
|
126
135
|
constructor(fields, role) {
|
|
127
136
|
if (!("prompt" in fields)) {
|
|
128
137
|
// eslint-disable-next-line no-param-reassign, @typescript-eslint/no-non-null-assertion
|
|
@@ -146,6 +155,9 @@ class ChatMessagePromptTemplate extends BaseMessageStringPromptTemplate {
|
|
|
146
155
|
}
|
|
147
156
|
exports.ChatMessagePromptTemplate = ChatMessagePromptTemplate;
|
|
148
157
|
class HumanMessagePromptTemplate extends BaseMessageStringPromptTemplate {
|
|
158
|
+
static lc_name() {
|
|
159
|
+
return "HumanMessagePromptTemplate";
|
|
160
|
+
}
|
|
149
161
|
async format(values) {
|
|
150
162
|
return new index_js_1.HumanMessage(await this.prompt.format(values));
|
|
151
163
|
}
|
|
@@ -155,6 +167,9 @@ class HumanMessagePromptTemplate extends BaseMessageStringPromptTemplate {
|
|
|
155
167
|
}
|
|
156
168
|
exports.HumanMessagePromptTemplate = HumanMessagePromptTemplate;
|
|
157
169
|
class AIMessagePromptTemplate extends BaseMessageStringPromptTemplate {
|
|
170
|
+
static lc_name() {
|
|
171
|
+
return "AIMessagePromptTemplate";
|
|
172
|
+
}
|
|
158
173
|
async format(values) {
|
|
159
174
|
return new index_js_1.AIMessage(await this.prompt.format(values));
|
|
160
175
|
}
|
|
@@ -164,6 +179,9 @@ class AIMessagePromptTemplate extends BaseMessageStringPromptTemplate {
|
|
|
164
179
|
}
|
|
165
180
|
exports.AIMessagePromptTemplate = AIMessagePromptTemplate;
|
|
166
181
|
class SystemMessagePromptTemplate extends BaseMessageStringPromptTemplate {
|
|
182
|
+
static lc_name() {
|
|
183
|
+
return "SystemMessagePromptTemplate";
|
|
184
|
+
}
|
|
167
185
|
async format(values) {
|
|
168
186
|
return new index_js_1.SystemMessage(await this.prompt.format(values));
|
|
169
187
|
}
|
|
@@ -173,6 +191,9 @@ class SystemMessagePromptTemplate extends BaseMessageStringPromptTemplate {
|
|
|
173
191
|
}
|
|
174
192
|
exports.SystemMessagePromptTemplate = SystemMessagePromptTemplate;
|
|
175
193
|
class ChatPromptTemplate extends BaseChatPromptTemplate {
|
|
194
|
+
static lc_name() {
|
|
195
|
+
return "ChatPromptTemplate";
|
|
196
|
+
}
|
|
176
197
|
get lc_aliases() {
|
|
177
198
|
return {
|
|
178
199
|
promptMessages: "messages",
|
package/dist/prompts/chat.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export interface ChatPromptValueFields {
|
|
|
15
15
|
export declare class ChatPromptValue extends BasePromptValue {
|
|
16
16
|
lc_namespace: string[];
|
|
17
17
|
lc_serializable: boolean;
|
|
18
|
+
static lc_name(): string;
|
|
18
19
|
messages: BaseMessage[];
|
|
19
20
|
constructor(messages: BaseMessage[]);
|
|
20
21
|
constructor(fields: ChatPromptValueFields);
|
|
@@ -25,6 +26,7 @@ export interface MessagePlaceholderFields<T extends string> {
|
|
|
25
26
|
variableName: T;
|
|
26
27
|
}
|
|
27
28
|
export declare class MessagesPlaceholder<RunInput extends InputValues = any> extends BaseMessagePromptTemplate<RunInput> {
|
|
29
|
+
static lc_name(): string;
|
|
28
30
|
variableName: Extract<keyof RunInput, string>;
|
|
29
31
|
constructor(variableName: Extract<keyof RunInput, string>);
|
|
30
32
|
constructor(fields: MessagePlaceholderFields<Extract<keyof RunInput, string>>);
|
|
@@ -52,6 +54,7 @@ export interface ChatMessagePromptTemplateFields<T extends InputValues = any> ex
|
|
|
52
54
|
role: string;
|
|
53
55
|
}
|
|
54
56
|
export declare class ChatMessagePromptTemplate<RunInput extends InputValues = any> extends BaseMessageStringPromptTemplate<RunInput> {
|
|
57
|
+
static lc_name(): string;
|
|
55
58
|
role: string;
|
|
56
59
|
constructor(prompt: BaseStringPromptTemplate<InputValues<Extract<keyof RunInput, string>>>, role: string);
|
|
57
60
|
constructor(fields: ChatMessagePromptTemplateFields<InputValues<Extract<keyof RunInput, string>>>);
|
|
@@ -59,14 +62,17 @@ export declare class ChatMessagePromptTemplate<RunInput extends InputValues = an
|
|
|
59
62
|
static fromTemplate(template: string, role: string): ChatMessagePromptTemplate<any>;
|
|
60
63
|
}
|
|
61
64
|
export declare class HumanMessagePromptTemplate<RunInput extends InputValues = any> extends BaseMessageStringPromptTemplate<RunInput> {
|
|
65
|
+
static lc_name(): string;
|
|
62
66
|
format(values: RunInput): Promise<BaseMessage>;
|
|
63
67
|
static fromTemplate(template: string): HumanMessagePromptTemplate<any>;
|
|
64
68
|
}
|
|
65
69
|
export declare class AIMessagePromptTemplate<RunInput extends InputValues = any> extends BaseMessageStringPromptTemplate<RunInput> {
|
|
70
|
+
static lc_name(): string;
|
|
66
71
|
format(values: RunInput): Promise<BaseMessage>;
|
|
67
72
|
static fromTemplate(template: string): AIMessagePromptTemplate<any>;
|
|
68
73
|
}
|
|
69
74
|
export declare class SystemMessagePromptTemplate<RunInput extends InputValues = any> extends BaseMessageStringPromptTemplate<RunInput> {
|
|
75
|
+
static lc_name(): string;
|
|
70
76
|
format(values: RunInput): Promise<BaseMessage>;
|
|
71
77
|
static fromTemplate(template: string): SystemMessagePromptTemplate<any>;
|
|
72
78
|
}
|
|
@@ -83,6 +89,7 @@ export interface ChatPromptTemplateInput<RunInput extends InputValues = any, Par
|
|
|
83
89
|
validateTemplate?: boolean;
|
|
84
90
|
}
|
|
85
91
|
export declare class ChatPromptTemplate<RunInput extends InputValues = any, PartialVariableName extends string = any> extends BaseChatPromptTemplate<RunInput, PartialVariableName> implements ChatPromptTemplateInput<RunInput, PartialVariableName> {
|
|
92
|
+
static lc_name(): string;
|
|
86
93
|
get lc_aliases(): {
|
|
87
94
|
promptMessages: string;
|
|
88
95
|
};
|
package/dist/prompts/chat.js
CHANGED
|
@@ -25,6 +25,9 @@ export class BaseMessagePromptTemplate extends Runnable {
|
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
export class ChatPromptValue extends BasePromptValue {
|
|
28
|
+
static lc_name() {
|
|
29
|
+
return "ChatPromptValue";
|
|
30
|
+
}
|
|
28
31
|
constructor(fields) {
|
|
29
32
|
if (Array.isArray(fields)) {
|
|
30
33
|
// eslint-disable-next-line no-param-reassign
|
|
@@ -59,6 +62,9 @@ export class ChatPromptValue extends BasePromptValue {
|
|
|
59
62
|
}
|
|
60
63
|
}
|
|
61
64
|
export class MessagesPlaceholder extends BaseMessagePromptTemplate {
|
|
65
|
+
static lc_name() {
|
|
66
|
+
return "MessagesPlaceholder";
|
|
67
|
+
}
|
|
62
68
|
constructor(fields) {
|
|
63
69
|
if (typeof fields === "string") {
|
|
64
70
|
// eslint-disable-next-line no-param-reassign
|
|
@@ -115,6 +121,9 @@ export class BaseChatPromptTemplate extends BasePromptTemplate {
|
|
|
115
121
|
}
|
|
116
122
|
}
|
|
117
123
|
export class ChatMessagePromptTemplate extends BaseMessageStringPromptTemplate {
|
|
124
|
+
static lc_name() {
|
|
125
|
+
return "ChatMessagePromptTemplate";
|
|
126
|
+
}
|
|
118
127
|
constructor(fields, role) {
|
|
119
128
|
if (!("prompt" in fields)) {
|
|
120
129
|
// eslint-disable-next-line no-param-reassign, @typescript-eslint/no-non-null-assertion
|
|
@@ -137,6 +146,9 @@ export class ChatMessagePromptTemplate extends BaseMessageStringPromptTemplate {
|
|
|
137
146
|
}
|
|
138
147
|
}
|
|
139
148
|
export class HumanMessagePromptTemplate extends BaseMessageStringPromptTemplate {
|
|
149
|
+
static lc_name() {
|
|
150
|
+
return "HumanMessagePromptTemplate";
|
|
151
|
+
}
|
|
140
152
|
async format(values) {
|
|
141
153
|
return new HumanMessage(await this.prompt.format(values));
|
|
142
154
|
}
|
|
@@ -145,6 +157,9 @@ export class HumanMessagePromptTemplate extends BaseMessageStringPromptTemplate
|
|
|
145
157
|
}
|
|
146
158
|
}
|
|
147
159
|
export class AIMessagePromptTemplate extends BaseMessageStringPromptTemplate {
|
|
160
|
+
static lc_name() {
|
|
161
|
+
return "AIMessagePromptTemplate";
|
|
162
|
+
}
|
|
148
163
|
async format(values) {
|
|
149
164
|
return new AIMessage(await this.prompt.format(values));
|
|
150
165
|
}
|
|
@@ -153,6 +168,9 @@ export class AIMessagePromptTemplate extends BaseMessageStringPromptTemplate {
|
|
|
153
168
|
}
|
|
154
169
|
}
|
|
155
170
|
export class SystemMessagePromptTemplate extends BaseMessageStringPromptTemplate {
|
|
171
|
+
static lc_name() {
|
|
172
|
+
return "SystemMessagePromptTemplate";
|
|
173
|
+
}
|
|
156
174
|
async format(values) {
|
|
157
175
|
return new SystemMessage(await this.prompt.format(values));
|
|
158
176
|
}
|
|
@@ -161,6 +179,9 @@ export class SystemMessagePromptTemplate extends BaseMessageStringPromptTemplate
|
|
|
161
179
|
}
|
|
162
180
|
}
|
|
163
181
|
export class ChatPromptTemplate extends BaseChatPromptTemplate {
|
|
182
|
+
static lc_name() {
|
|
183
|
+
return "ChatPromptTemplate";
|
|
184
|
+
}
|
|
164
185
|
get lc_aliases() {
|
|
165
186
|
return {
|
|
166
187
|
promptMessages: "messages",
|
|
@@ -4,6 +4,9 @@ exports.PipelinePromptTemplate = void 0;
|
|
|
4
4
|
const base_js_1 = require("./base.cjs");
|
|
5
5
|
const chat_js_1 = require("./chat.cjs");
|
|
6
6
|
class PipelinePromptTemplate extends base_js_1.BasePromptTemplate {
|
|
7
|
+
static lc_name() {
|
|
8
|
+
return "PipelinePromptTemplate";
|
|
9
|
+
}
|
|
7
10
|
constructor(input) {
|
|
8
11
|
super({ ...input, inputVariables: [] });
|
|
9
12
|
Object.defineProperty(this, "pipelinePrompts", {
|