langchain 0.0.198 → 0.0.200
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/index.cjs +3 -1
- package/dist/agents/index.d.ts +2 -2
- package/dist/agents/index.js +1 -1
- package/dist/agents/toolkits/conversational_retrieval/tool.cjs +1 -1
- package/dist/agents/toolkits/conversational_retrieval/tool.js +1 -1
- package/dist/chains/conversational_retrieval_chain.cjs +16 -2
- package/dist/chains/conversational_retrieval_chain.d.ts +2 -0
- package/dist/chains/conversational_retrieval_chain.js +16 -2
- package/dist/chat_models/fake.cjs +2 -114
- package/dist/chat_models/fake.d.ts +1 -52
- package/dist/chat_models/fake.js +1 -113
- package/dist/chat_models/llama_cpp.cjs +43 -21
- package/dist/chat_models/llama_cpp.d.ts +2 -1
- package/dist/chat_models/llama_cpp.js +44 -22
- package/dist/chat_models/minimax.d.ts +1 -1
- package/dist/document_loaders/fs/chatgpt.cjs +85 -0
- package/dist/document_loaders/fs/chatgpt.d.ts +8 -0
- package/dist/document_loaders/fs/chatgpt.js +81 -0
- package/dist/document_loaders/web/confluence.cjs +31 -7
- package/dist/document_loaders/web/confluence.d.ts +12 -5
- package/dist/document_loaders/web/confluence.js +31 -7
- package/dist/embeddings/gradient_ai.cjs +102 -0
- package/dist/embeddings/gradient_ai.d.ts +48 -0
- package/dist/embeddings/gradient_ai.js +98 -0
- package/dist/llms/gradient_ai.cjs +112 -0
- package/dist/llms/gradient_ai.d.ts +55 -0
- package/dist/llms/gradient_ai.js +108 -0
- package/dist/llms/llama_cpp.cjs +2 -1
- package/dist/llms/llama_cpp.d.ts +1 -1
- package/dist/llms/llama_cpp.js +2 -1
- package/dist/llms/watsonx_ai.cjs +154 -0
- package/dist/llms/watsonx_ai.d.ts +72 -0
- package/dist/llms/watsonx_ai.js +150 -0
- package/dist/load/import_constants.cjs +4 -0
- package/dist/load/import_constants.js +4 -0
- package/dist/load/import_map.cjs +4 -3
- package/dist/load/import_map.d.ts +1 -0
- package/dist/load/import_map.js +1 -0
- package/dist/memory/vector_store.cjs +1 -1
- package/dist/memory/vector_store.js +1 -1
- package/dist/tools/google_places.cjs +81 -0
- package/dist/tools/google_places.d.ts +21 -0
- package/dist/tools/google_places.js +77 -0
- package/dist/tools/webbrowser.cjs +1 -1
- package/dist/tools/webbrowser.js +1 -1
- package/dist/util/document.cjs +1 -1
- package/dist/util/document.d.ts +1 -1
- package/dist/util/document.js +1 -1
- package/dist/util/tiktoken.cjs +15 -24
- package/dist/util/tiktoken.d.ts +1 -9
- package/dist/util/tiktoken.js +1 -21
- package/dist/vectorstores/elasticsearch.cjs +16 -3
- package/dist/vectorstores/elasticsearch.d.ts +6 -2
- package/dist/vectorstores/elasticsearch.js +16 -3
- package/dist/vectorstores/prisma.cjs +1 -1
- package/dist/vectorstores/prisma.js +1 -1
- package/dist/vectorstores/weaviate.d.ts +1 -1
- package/dist/vectorstores/xata.cjs +3 -2
- package/dist/vectorstores/xata.js +3 -2
- package/document_loaders/fs/chatgpt.cjs +1 -0
- package/document_loaders/fs/chatgpt.d.ts +1 -0
- package/document_loaders/fs/chatgpt.js +1 -0
- package/embeddings/gradient_ai.cjs +1 -0
- package/embeddings/gradient_ai.d.ts +1 -0
- package/embeddings/gradient_ai.js +1 -0
- package/llms/gradient_ai.cjs +1 -0
- package/llms/gradient_ai.d.ts +1 -0
- package/llms/gradient_ai.js +1 -0
- package/llms/watsonx_ai.cjs +1 -0
- package/llms/watsonx_ai.d.ts +1 -0
- package/llms/watsonx_ai.js +1 -0
- package/package.json +58 -11
- package/tools/google_places.cjs +1 -0
- package/tools/google_places.d.ts +1 -0
- package/tools/google_places.js +1 -0
|
@@ -26,6 +26,7 @@ exports.optionalImportEntrypoints = [
|
|
|
26
26
|
"langchain/embeddings/googlevertexai",
|
|
27
27
|
"langchain/embeddings/googlepalm",
|
|
28
28
|
"langchain/embeddings/llama_cpp",
|
|
29
|
+
"langchain/embeddings/gradient_ai",
|
|
29
30
|
"langchain/llms/load",
|
|
30
31
|
"langchain/llms/cohere",
|
|
31
32
|
"langchain/llms/hf",
|
|
@@ -34,7 +35,9 @@ exports.optionalImportEntrypoints = [
|
|
|
34
35
|
"langchain/llms/googlevertexai",
|
|
35
36
|
"langchain/llms/googlevertexai/web",
|
|
36
37
|
"langchain/llms/googlepalm",
|
|
38
|
+
"langchain/llms/gradient_ai",
|
|
37
39
|
"langchain/llms/sagemaker_endpoint",
|
|
40
|
+
"langchain/llms/watsonx_ai",
|
|
38
41
|
"langchain/llms/bedrock",
|
|
39
42
|
"langchain/llms/bedrock/web",
|
|
40
43
|
"langchain/llms/llama_cpp",
|
|
@@ -100,6 +103,7 @@ exports.optionalImportEntrypoints = [
|
|
|
100
103
|
"langchain/document_loaders/web/youtube",
|
|
101
104
|
"langchain/document_loaders/fs/directory",
|
|
102
105
|
"langchain/document_loaders/fs/buffer",
|
|
106
|
+
"langchain/document_loaders/fs/chatgpt",
|
|
103
107
|
"langchain/document_loaders/fs/text",
|
|
104
108
|
"langchain/document_loaders/fs/json",
|
|
105
109
|
"langchain/document_loaders/fs/srt",
|
|
@@ -23,6 +23,7 @@ export const optionalImportEntrypoints = [
|
|
|
23
23
|
"langchain/embeddings/googlevertexai",
|
|
24
24
|
"langchain/embeddings/googlepalm",
|
|
25
25
|
"langchain/embeddings/llama_cpp",
|
|
26
|
+
"langchain/embeddings/gradient_ai",
|
|
26
27
|
"langchain/llms/load",
|
|
27
28
|
"langchain/llms/cohere",
|
|
28
29
|
"langchain/llms/hf",
|
|
@@ -31,7 +32,9 @@ export const optionalImportEntrypoints = [
|
|
|
31
32
|
"langchain/llms/googlevertexai",
|
|
32
33
|
"langchain/llms/googlevertexai/web",
|
|
33
34
|
"langchain/llms/googlepalm",
|
|
35
|
+
"langchain/llms/gradient_ai",
|
|
34
36
|
"langchain/llms/sagemaker_endpoint",
|
|
37
|
+
"langchain/llms/watsonx_ai",
|
|
35
38
|
"langchain/llms/bedrock",
|
|
36
39
|
"langchain/llms/bedrock/web",
|
|
37
40
|
"langchain/llms/llama_cpp",
|
|
@@ -97,6 +100,7 @@ export const optionalImportEntrypoints = [
|
|
|
97
100
|
"langchain/document_loaders/web/youtube",
|
|
98
101
|
"langchain/document_loaders/fs/directory",
|
|
99
102
|
"langchain/document_loaders/fs/buffer",
|
|
103
|
+
"langchain/document_loaders/fs/chatgpt",
|
|
100
104
|
"langchain/document_loaders/fs/text",
|
|
101
105
|
"langchain/document_loaders/fs/json",
|
|
102
106
|
"langchain/document_loaders/fs/srt",
|
package/dist/load/import_map.cjs
CHANGED
|
@@ -24,9 +24,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
return result;
|
|
25
25
|
};
|
|
26
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
-
exports.
|
|
28
|
-
exports.
|
|
29
|
-
exports.runnables__remote = exports.runnables = exports.evaluation = void 0;
|
|
27
|
+
exports.chat_models__openai = exports.chat_models__base = exports.document_transformers__openai_functions = exports.document_loaders__web__sort_xyz_blockchain = exports.document_loaders__web__serpapi = exports.document_loaders__web__searchapi = exports.document_loaders__base = exports.document = exports.memory = exports.text_splitter = exports.vectorstores__xata = exports.vectorstores__vectara = exports.vectorstores__prisma = exports.vectorstores__memory = exports.vectorstores__base = exports.prompts = exports.llms__fake = exports.llms__yandex = exports.llms__fireworks = exports.llms__ollama = exports.llms__cloudflare_workersai = exports.llms__aleph_alpha = exports.llms__ai21 = exports.llms__openai = exports.llms__base = exports.embeddings__voyage = exports.embeddings__minimax = exports.embeddings__openai = exports.embeddings__ollama = exports.embeddings__fake = exports.embeddings__cache_backed = exports.embeddings__base = exports.chains__openai_functions = exports.chains__combine_documents__reduce = exports.chains = exports.tools__google_places = exports.tools__render = exports.tools = exports.base_language = exports.agents__openai__output_parser = exports.agents__xml__output_parser = exports.agents__react__output_parser = exports.agents__format_scratchpad__log_to_message = exports.agents__format_scratchpad__xml = exports.agents__format_scratchpad__log = exports.agents__format_scratchpad__openai_tools = exports.agents__format_scratchpad = exports.agents__toolkits = exports.agents = exports.load__serializable = void 0;
|
|
28
|
+
exports.experimental__chat_models__ollama_functions = exports.experimental__chat_models__bittensor = exports.experimental__plan_and_execute = exports.experimental__generative_agents = exports.experimental__babyagi = exports.experimental__openai_files = exports.experimental__openai_assistant = exports.experimental__autogpt = exports.util__time = exports.util__math = exports.util__document = exports.storage__in_memory = exports.storage__encoder_backed = exports.stores__message__in_memory = exports.stores__file__in_memory = exports.stores__doc__in_memory = exports.cache = exports.retrievers__vespa = exports.retrievers__score_threshold = exports.retrievers__hyde = exports.retrievers__document_compressors__embeddings_filter = exports.retrievers__document_compressors__chain_extract = exports.retrievers__time_weighted = exports.retrievers__tavily_search_api = exports.retrievers__parent_document = exports.retrievers__multi_vector = exports.retrievers__multi_query = exports.retrievers__document_compressors = exports.retrievers__contextual_compression = exports.retrievers__databerry = exports.retrievers__chaindesk = exports.retrievers__remote = exports.output_parsers = exports.callbacks = exports.schema__storage = exports.schema__runnable = exports.schema__retriever = exports.schema__query_constructor = exports.schema__prompt_template = exports.schema__output_parser = exports.schema__document = exports.schema = exports.chat_models__fake = exports.chat_models__yandex = exports.chat_models__minimax = exports.chat_models__ollama = exports.chat_models__baiduwenxin = exports.chat_models__fireworks = exports.chat_models__cloudflare_workersai = exports.chat_models__anthropic = void 0;
|
|
29
|
+
exports.runnables__remote = exports.runnables = exports.evaluation = exports.experimental__chains__violation_of_expectations = void 0;
|
|
30
30
|
exports.load__serializable = __importStar(require("../load/serializable.cjs"));
|
|
31
31
|
exports.agents = __importStar(require("../agents/index.cjs"));
|
|
32
32
|
exports.agents__toolkits = __importStar(require("../agents/toolkits/index.cjs"));
|
|
@@ -41,6 +41,7 @@ exports.agents__openai__output_parser = __importStar(require("../agents/openai/o
|
|
|
41
41
|
exports.base_language = __importStar(require("../base_language/index.cjs"));
|
|
42
42
|
exports.tools = __importStar(require("../tools/index.cjs"));
|
|
43
43
|
exports.tools__render = __importStar(require("../tools/render.cjs"));
|
|
44
|
+
exports.tools__google_places = __importStar(require("../tools/google_places.cjs"));
|
|
44
45
|
exports.chains = __importStar(require("../chains/index.cjs"));
|
|
45
46
|
exports.chains__combine_documents__reduce = __importStar(require("../chains/combine_documents/reduce.cjs"));
|
|
46
47
|
exports.chains__openai_functions = __importStar(require("../chains/openai_functions/index.cjs"));
|
|
@@ -12,6 +12,7 @@ export * as agents__openai__output_parser from "../agents/openai/output_parser.j
|
|
|
12
12
|
export * as base_language from "../base_language/index.js";
|
|
13
13
|
export * as tools from "../tools/index.js";
|
|
14
14
|
export * as tools__render from "../tools/render.js";
|
|
15
|
+
export * as tools__google_places from "../tools/google_places.js";
|
|
15
16
|
export * as chains from "../chains/index.js";
|
|
16
17
|
export * as chains__combine_documents__reduce from "../chains/combine_documents/reduce.js";
|
|
17
18
|
export * as chains__openai_functions from "../chains/openai_functions/index.js";
|
package/dist/load/import_map.js
CHANGED
|
@@ -13,6 +13,7 @@ export * as agents__openai__output_parser from "../agents/openai/output_parser.j
|
|
|
13
13
|
export * as base_language from "../base_language/index.js";
|
|
14
14
|
export * as tools from "../tools/index.js";
|
|
15
15
|
export * as tools__render from "../tools/render.js";
|
|
16
|
+
export * as tools__google_places from "../tools/google_places.js";
|
|
16
17
|
export * as chains from "../chains/index.js";
|
|
17
18
|
export * as chains__combine_documents__reduce from "../chains/combine_documents/reduce.js";
|
|
18
19
|
export * as chains__openai_functions from "../chains/openai_functions/index.js";
|
|
@@ -83,7 +83,7 @@ class VectorStoreRetrieverMemory extends base_js_1.BaseMemory {
|
|
|
83
83
|
return {
|
|
84
84
|
[this.memoryKey]: this.returnDocs
|
|
85
85
|
? results
|
|
86
|
-
: (0, document_js_2.formatDocumentsAsString)(results
|
|
86
|
+
: (0, document_js_2.formatDocumentsAsString)(results),
|
|
87
87
|
};
|
|
88
88
|
}
|
|
89
89
|
/**
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GooglePlacesAPI = void 0;
|
|
4
|
+
const env_js_1 = require("../util/env.cjs");
|
|
5
|
+
const base_js_1 = require("./base.cjs");
|
|
6
|
+
/**
|
|
7
|
+
* Tool that queries the Google Places API
|
|
8
|
+
*/
|
|
9
|
+
class GooglePlacesAPI extends base_js_1.Tool {
|
|
10
|
+
static lc_name() {
|
|
11
|
+
return "GooglePlacesAPI";
|
|
12
|
+
}
|
|
13
|
+
get lc_secrets() {
|
|
14
|
+
return {
|
|
15
|
+
apiKey: "GOOGLE_PLACES_API_KEY",
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
constructor(fields) {
|
|
19
|
+
super(...arguments);
|
|
20
|
+
Object.defineProperty(this, "name", {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
configurable: true,
|
|
23
|
+
writable: true,
|
|
24
|
+
value: "google_places"
|
|
25
|
+
});
|
|
26
|
+
Object.defineProperty(this, "apiKey", {
|
|
27
|
+
enumerable: true,
|
|
28
|
+
configurable: true,
|
|
29
|
+
writable: true,
|
|
30
|
+
value: void 0
|
|
31
|
+
});
|
|
32
|
+
Object.defineProperty(this, "description", {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
configurable: true,
|
|
35
|
+
writable: true,
|
|
36
|
+
value: `A wrapper around Google Places API. Useful for when you need to validate or
|
|
37
|
+
discover addresses from ambiguous text. Input should be a search query.`
|
|
38
|
+
});
|
|
39
|
+
const apiKey = fields?.apiKey ?? (0, env_js_1.getEnvironmentVariable)("GOOGLE_PLACES_API_KEY");
|
|
40
|
+
if (apiKey === undefined) {
|
|
41
|
+
throw new Error(`Google Places API key not set. You can set it as "GOOGLE_PLACES_API_KEY" in your environment variables.`);
|
|
42
|
+
}
|
|
43
|
+
this.apiKey = apiKey;
|
|
44
|
+
}
|
|
45
|
+
async _call(input) {
|
|
46
|
+
const res = await fetch(`https://places.googleapis.com/v1/places:searchText`, {
|
|
47
|
+
method: "POST",
|
|
48
|
+
body: JSON.stringify({
|
|
49
|
+
textQuery: input,
|
|
50
|
+
languageCode: "en",
|
|
51
|
+
}),
|
|
52
|
+
headers: {
|
|
53
|
+
"X-Goog-Api-Key": this.apiKey,
|
|
54
|
+
"X-Goog-FieldMask": "places.displayName,places.formattedAddress,places.id,places.internationalPhoneNumber,places.websiteUri",
|
|
55
|
+
"Content-Type": "application/json",
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
if (!res.ok) {
|
|
59
|
+
let message;
|
|
60
|
+
try {
|
|
61
|
+
const json = await res.json();
|
|
62
|
+
message = json.error.message;
|
|
63
|
+
}
|
|
64
|
+
catch (e) {
|
|
65
|
+
message =
|
|
66
|
+
"Unable to parse error message: Google did not return a JSON response.";
|
|
67
|
+
}
|
|
68
|
+
throw new Error(`Got ${res.status}: ${res.statusText} error from Google Places API: ${message}`);
|
|
69
|
+
}
|
|
70
|
+
const json = await res.json();
|
|
71
|
+
const results = json?.places?.map((place) => ({
|
|
72
|
+
name: place.displayName?.text,
|
|
73
|
+
id: place.id,
|
|
74
|
+
address: place.formattedAddress,
|
|
75
|
+
phoneNumber: place.internationalPhoneNumber,
|
|
76
|
+
website: place.websiteUri,
|
|
77
|
+
})) ?? [];
|
|
78
|
+
return JSON.stringify(results);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
exports.GooglePlacesAPI = GooglePlacesAPI;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Tool } from "./base.js";
|
|
2
|
+
/**
|
|
3
|
+
* Interface for parameters required by GooglePlacesAPI class.
|
|
4
|
+
*/
|
|
5
|
+
export interface GooglePlacesAPIParams {
|
|
6
|
+
apiKey?: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Tool that queries the Google Places API
|
|
10
|
+
*/
|
|
11
|
+
export declare class GooglePlacesAPI extends Tool {
|
|
12
|
+
static lc_name(): string;
|
|
13
|
+
get lc_secrets(): {
|
|
14
|
+
[key: string]: string;
|
|
15
|
+
} | undefined;
|
|
16
|
+
name: string;
|
|
17
|
+
protected apiKey: string;
|
|
18
|
+
description: string;
|
|
19
|
+
constructor(fields?: GooglePlacesAPIParams);
|
|
20
|
+
_call(input: string): Promise<string>;
|
|
21
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { getEnvironmentVariable } from "../util/env.js";
|
|
2
|
+
import { Tool } from "./base.js";
|
|
3
|
+
/**
|
|
4
|
+
* Tool that queries the Google Places API
|
|
5
|
+
*/
|
|
6
|
+
export class GooglePlacesAPI extends Tool {
|
|
7
|
+
static lc_name() {
|
|
8
|
+
return "GooglePlacesAPI";
|
|
9
|
+
}
|
|
10
|
+
get lc_secrets() {
|
|
11
|
+
return {
|
|
12
|
+
apiKey: "GOOGLE_PLACES_API_KEY",
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
constructor(fields) {
|
|
16
|
+
super(...arguments);
|
|
17
|
+
Object.defineProperty(this, "name", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
configurable: true,
|
|
20
|
+
writable: true,
|
|
21
|
+
value: "google_places"
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(this, "apiKey", {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
configurable: true,
|
|
26
|
+
writable: true,
|
|
27
|
+
value: void 0
|
|
28
|
+
});
|
|
29
|
+
Object.defineProperty(this, "description", {
|
|
30
|
+
enumerable: true,
|
|
31
|
+
configurable: true,
|
|
32
|
+
writable: true,
|
|
33
|
+
value: `A wrapper around Google Places API. Useful for when you need to validate or
|
|
34
|
+
discover addresses from ambiguous text. Input should be a search query.`
|
|
35
|
+
});
|
|
36
|
+
const apiKey = fields?.apiKey ?? getEnvironmentVariable("GOOGLE_PLACES_API_KEY");
|
|
37
|
+
if (apiKey === undefined) {
|
|
38
|
+
throw new Error(`Google Places API key not set. You can set it as "GOOGLE_PLACES_API_KEY" in your environment variables.`);
|
|
39
|
+
}
|
|
40
|
+
this.apiKey = apiKey;
|
|
41
|
+
}
|
|
42
|
+
async _call(input) {
|
|
43
|
+
const res = await fetch(`https://places.googleapis.com/v1/places:searchText`, {
|
|
44
|
+
method: "POST",
|
|
45
|
+
body: JSON.stringify({
|
|
46
|
+
textQuery: input,
|
|
47
|
+
languageCode: "en",
|
|
48
|
+
}),
|
|
49
|
+
headers: {
|
|
50
|
+
"X-Goog-Api-Key": this.apiKey,
|
|
51
|
+
"X-Goog-FieldMask": "places.displayName,places.formattedAddress,places.id,places.internationalPhoneNumber,places.websiteUri",
|
|
52
|
+
"Content-Type": "application/json",
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
if (!res.ok) {
|
|
56
|
+
let message;
|
|
57
|
+
try {
|
|
58
|
+
const json = await res.json();
|
|
59
|
+
message = json.error.message;
|
|
60
|
+
}
|
|
61
|
+
catch (e) {
|
|
62
|
+
message =
|
|
63
|
+
"Unable to parse error message: Google did not return a JSON response.";
|
|
64
|
+
}
|
|
65
|
+
throw new Error(`Got ${res.status}: ${res.statusText} error from Google Places API: ${message}`);
|
|
66
|
+
}
|
|
67
|
+
const json = await res.json();
|
|
68
|
+
const results = json?.places?.map((place) => ({
|
|
69
|
+
name: place.displayName?.text,
|
|
70
|
+
id: place.id,
|
|
71
|
+
address: place.formattedAddress,
|
|
72
|
+
phoneNumber: place.internationalPhoneNumber,
|
|
73
|
+
website: place.websiteUri,
|
|
74
|
+
})) ?? [];
|
|
75
|
+
return JSON.stringify(results);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -243,7 +243,7 @@ class WebBrowser extends base_js_1.Tool {
|
|
|
243
243
|
}));
|
|
244
244
|
const vectorStore = await memory_js_1.MemoryVectorStore.fromDocuments(docs, this.embeddings);
|
|
245
245
|
const results = await vectorStore.similaritySearch(task, 4, undefined, runManager?.getChild("vectorstore"));
|
|
246
|
-
context = (0, document_js_2.formatDocumentsAsString)(results
|
|
246
|
+
context = (0, document_js_2.formatDocumentsAsString)(results);
|
|
247
247
|
}
|
|
248
248
|
const input = `Text:${context}\n\nI need ${doSummary ? "a summary" : task} from the above text, also provide up to 5 markdown links from within that would be of interest (always including URL and text). Links should be provided, if present, in markdown syntax as a list under the heading "Relevant Links:".`;
|
|
249
249
|
return this.model.predict(input, undefined, runManager?.getChild());
|
package/dist/tools/webbrowser.js
CHANGED
|
@@ -212,7 +212,7 @@ export class WebBrowser extends Tool {
|
|
|
212
212
|
}));
|
|
213
213
|
const vectorStore = await MemoryVectorStore.fromDocuments(docs, this.embeddings);
|
|
214
214
|
const results = await vectorStore.similaritySearch(task, 4, undefined, runManager?.getChild("vectorstore"));
|
|
215
|
-
context = formatDocumentsAsString(results
|
|
215
|
+
context = formatDocumentsAsString(results);
|
|
216
216
|
}
|
|
217
217
|
const input = `Text:${context}\n\nI need ${doSummary ? "a summary" : task} from the above text, also provide up to 5 markdown links from within that would be of interest (always including URL and text). Links should be provided, if present, in markdown syntax as a list under the heading "Relevant Links:".`;
|
|
218
218
|
return this.model.predict(input, undefined, runManager?.getChild());
|
package/dist/util/document.cjs
CHANGED
|
@@ -8,5 +8,5 @@ exports.formatDocumentsAsString = void 0;
|
|
|
8
8
|
* @param documents
|
|
9
9
|
* @returns A string of the documents page content, separated by newlines.
|
|
10
10
|
*/
|
|
11
|
-
const formatDocumentsAsString = (documents
|
|
11
|
+
const formatDocumentsAsString = (documents) => documents.map((doc) => doc.pageContent).join("\n\n");
|
|
12
12
|
exports.formatDocumentsAsString = formatDocumentsAsString;
|
package/dist/util/document.d.ts
CHANGED
|
@@ -6,4 +6,4 @@ import { Document } from "../document.js";
|
|
|
6
6
|
* @param documents
|
|
7
7
|
* @returns A string of the documents page content, separated by newlines.
|
|
8
8
|
*/
|
|
9
|
-
export declare const formatDocumentsAsString: (documents: Document[]
|
|
9
|
+
export declare const formatDocumentsAsString: (documents: Document[]) => string;
|
package/dist/util/document.js
CHANGED
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* @param documents
|
|
6
6
|
* @returns A string of the documents page content, separated by newlines.
|
|
7
7
|
*/
|
|
8
|
-
export const formatDocumentsAsString = (documents
|
|
8
|
+
export const formatDocumentsAsString = (documents) => documents.map((doc) => doc.pageContent).join("\n\n");
|
package/dist/util/tiktoken.cjs
CHANGED
|
@@ -1,26 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const caller = /* #__PURE__ */ new async_caller_js_1.AsyncCaller({});
|
|
8
|
-
async function getEncoding(encoding, options) {
|
|
9
|
-
if (!(encoding in cache)) {
|
|
10
|
-
cache[encoding] = caller
|
|
11
|
-
.fetch(`https://tiktoken.pages.dev/js/${encoding}.json`, {
|
|
12
|
-
signal: options?.signal,
|
|
13
|
-
})
|
|
14
|
-
.then((res) => res.json())
|
|
15
|
-
.catch((e) => {
|
|
16
|
-
delete cache[encoding];
|
|
17
|
-
throw e;
|
|
18
|
-
});
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
19
7
|
}
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
exports
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("@langchain/core/utils/tiktoken"), exports);
|
package/dist/util/tiktoken.d.ts
CHANGED
|
@@ -1,9 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function getEncoding(encoding: TiktokenEncoding, options?: {
|
|
3
|
-
signal?: AbortSignal;
|
|
4
|
-
extendedSpecialTokens?: Record<string, number>;
|
|
5
|
-
}): Promise<Tiktoken>;
|
|
6
|
-
export declare function encodingForModel(model: TiktokenModel, options?: {
|
|
7
|
-
signal?: AbortSignal;
|
|
8
|
-
extendedSpecialTokens?: Record<string, number>;
|
|
9
|
-
}): Promise<Tiktoken>;
|
|
1
|
+
export * from "@langchain/core/utils/tiktoken";
|
package/dist/util/tiktoken.js
CHANGED
|
@@ -1,21 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { AsyncCaller } from "./async_caller.js";
|
|
3
|
-
const cache = {};
|
|
4
|
-
const caller = /* #__PURE__ */ new AsyncCaller({});
|
|
5
|
-
export async function getEncoding(encoding, options) {
|
|
6
|
-
if (!(encoding in cache)) {
|
|
7
|
-
cache[encoding] = caller
|
|
8
|
-
.fetch(`https://tiktoken.pages.dev/js/${encoding}.json`, {
|
|
9
|
-
signal: options?.signal,
|
|
10
|
-
})
|
|
11
|
-
.then((res) => res.json())
|
|
12
|
-
.catch((e) => {
|
|
13
|
-
delete cache[encoding];
|
|
14
|
-
throw e;
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
return new Tiktoken(await cache[encoding], options?.extendedSpecialTokens);
|
|
18
|
-
}
|
|
19
|
-
export async function encodingForModel(model, options) {
|
|
20
|
-
return getEncoding(getEncodingNameForModel(model), options);
|
|
21
|
-
}
|
|
1
|
+
export * from "@langchain/core/utils/tiktoken";
|
|
@@ -258,12 +258,25 @@ class ElasticVectorSearch extends base_js_1.VectorStore {
|
|
|
258
258
|
return;
|
|
259
259
|
await this.client.indices.create(request);
|
|
260
260
|
}
|
|
261
|
-
buildMetadataTerms(filter
|
|
261
|
+
buildMetadataTerms(filter
|
|
262
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
263
|
+
) {
|
|
262
264
|
if (filter == null)
|
|
263
265
|
return [];
|
|
264
266
|
const result = [];
|
|
265
|
-
|
|
266
|
-
|
|
267
|
+
const filters = Array.isArray(filter)
|
|
268
|
+
? filter
|
|
269
|
+
: Object.entries(filter).map(([key, value]) => ({
|
|
270
|
+
operator: "term",
|
|
271
|
+
field: key,
|
|
272
|
+
value,
|
|
273
|
+
}));
|
|
274
|
+
for (const condition of filters) {
|
|
275
|
+
result.push({
|
|
276
|
+
[condition.operator]: {
|
|
277
|
+
[`metadata.${condition.field}`]: condition.value,
|
|
278
|
+
},
|
|
279
|
+
});
|
|
267
280
|
}
|
|
268
281
|
return result;
|
|
269
282
|
}
|
|
@@ -33,7 +33,11 @@ export interface ElasticClientArgs {
|
|
|
33
33
|
/**
|
|
34
34
|
* Type representing a filter object in Elasticsearch.
|
|
35
35
|
*/
|
|
36
|
-
type ElasticFilter = object
|
|
36
|
+
type ElasticFilter = object | {
|
|
37
|
+
field: string;
|
|
38
|
+
operator: string;
|
|
39
|
+
value: any;
|
|
40
|
+
}[];
|
|
37
41
|
/**
|
|
38
42
|
* Class for interacting with an Elasticsearch database. It extends the
|
|
39
43
|
* VectorStore base class and provides methods for adding documents and
|
|
@@ -83,7 +87,7 @@ export declare class ElasticVectorSearch extends VectorStore {
|
|
|
83
87
|
* @param filter Optional filter to apply to the search.
|
|
84
88
|
* @returns A promise that resolves with an array of tuples, where each tuple contains a Document and its similarity score.
|
|
85
89
|
*/
|
|
86
|
-
similaritySearchVectorWithScore(query: number[], k: number, filter?: ElasticFilter
|
|
90
|
+
similaritySearchVectorWithScore(query: number[], k: number, filter?: ElasticFilter): Promise<[Document, number][]>;
|
|
87
91
|
/**
|
|
88
92
|
* Method to delete documents from the Elasticsearch database.
|
|
89
93
|
* @param params Object containing the IDs of the documents to delete.
|
|
@@ -232,12 +232,25 @@ export class ElasticVectorSearch extends VectorStore {
|
|
|
232
232
|
return;
|
|
233
233
|
await this.client.indices.create(request);
|
|
234
234
|
}
|
|
235
|
-
buildMetadataTerms(filter
|
|
235
|
+
buildMetadataTerms(filter
|
|
236
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
237
|
+
) {
|
|
236
238
|
if (filter == null)
|
|
237
239
|
return [];
|
|
238
240
|
const result = [];
|
|
239
|
-
|
|
240
|
-
|
|
241
|
+
const filters = Array.isArray(filter)
|
|
242
|
+
? filter
|
|
243
|
+
: Object.entries(filter).map(([key, value]) => ({
|
|
244
|
+
operator: "term",
|
|
245
|
+
field: key,
|
|
246
|
+
value,
|
|
247
|
+
}));
|
|
248
|
+
for (const condition of filters) {
|
|
249
|
+
result.push({
|
|
250
|
+
[condition.operator]: {
|
|
251
|
+
[`metadata.${condition.field}`]: condition.value,
|
|
252
|
+
},
|
|
253
|
+
});
|
|
241
254
|
}
|
|
242
255
|
return result;
|
|
243
256
|
}
|
|
@@ -249,7 +249,7 @@ class PrismaVectorStore extends base_js_1.VectorStore {
|
|
|
249
249
|
!value.every((v) => typeof v === "string")) {
|
|
250
250
|
throw new Error(`Invalid filter: IN operator requires an array of strings. Received: ${JSON.stringify(value, null, 2)}`);
|
|
251
251
|
}
|
|
252
|
-
return this.Prisma.sql `${colRaw} ${opRaw} (${
|
|
252
|
+
return this.Prisma.sql `${colRaw} ${opRaw} (${this.Prisma.join(value)})`;
|
|
253
253
|
}
|
|
254
254
|
case OpMap.isNull:
|
|
255
255
|
case OpMap.isNotNull:
|
|
@@ -246,7 +246,7 @@ class PrismaVectorStore extends VectorStore {
|
|
|
246
246
|
!value.every((v) => typeof v === "string")) {
|
|
247
247
|
throw new Error(`Invalid filter: IN operator requires an array of strings. Received: ${JSON.stringify(value, null, 2)}`);
|
|
248
248
|
}
|
|
249
|
-
return this.Prisma.sql `${colRaw} ${opRaw} (${
|
|
249
|
+
return this.Prisma.sql `${colRaw} ${opRaw} (${this.Prisma.join(value)})`;
|
|
250
250
|
}
|
|
251
251
|
case OpMap.isNull:
|
|
252
252
|
case OpMap.isNotNull:
|
|
@@ -108,7 +108,7 @@ export declare class WeaviateStore extends VectorStore {
|
|
|
108
108
|
*
|
|
109
109
|
* @returns {Promise<Document[]>} - List of documents selected by maximal marginal relevance.
|
|
110
110
|
*/
|
|
111
|
-
maxMarginalRelevanceSearch(query: string, options: MaxMarginalRelevanceSearchOptions<this["FilterType"]>, _callbacks
|
|
111
|
+
maxMarginalRelevanceSearch(query: string, options: MaxMarginalRelevanceSearchOptions<this["FilterType"]>, _callbacks?: undefined): Promise<Document[]>;
|
|
112
112
|
/**
|
|
113
113
|
* Static method to create a new `WeaviateStore` instance from a list of
|
|
114
114
|
* texts. It first creates documents from the texts and metadata, then
|
|
@@ -93,8 +93,9 @@ class XataVectorSearch extends base_js_1.VectorStore {
|
|
|
93
93
|
size: k,
|
|
94
94
|
filter,
|
|
95
95
|
});
|
|
96
|
+
return (
|
|
96
97
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
97
|
-
|
|
98
|
+
records?.map((record) => [
|
|
98
99
|
new document_js_1.Document({
|
|
99
100
|
pageContent: record.content,
|
|
100
101
|
metadata: Object.fromEntries(Object.entries(record).filter(([key]) => key !== "content" &&
|
|
@@ -103,7 +104,7 @@ class XataVectorSearch extends base_js_1.VectorStore {
|
|
|
103
104
|
key !== "id")),
|
|
104
105
|
}),
|
|
105
106
|
record.xata.score,
|
|
106
|
-
]);
|
|
107
|
+
]) ?? []);
|
|
107
108
|
}
|
|
108
109
|
}
|
|
109
110
|
exports.XataVectorSearch = XataVectorSearch;
|
|
@@ -90,8 +90,9 @@ export class XataVectorSearch extends VectorStore {
|
|
|
90
90
|
size: k,
|
|
91
91
|
filter,
|
|
92
92
|
});
|
|
93
|
+
return (
|
|
93
94
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
94
|
-
|
|
95
|
+
records?.map((record) => [
|
|
95
96
|
new Document({
|
|
96
97
|
pageContent: record.content,
|
|
97
98
|
metadata: Object.fromEntries(Object.entries(record).filter(([key]) => key !== "content" &&
|
|
@@ -100,6 +101,6 @@ export class XataVectorSearch extends VectorStore {
|
|
|
100
101
|
key !== "id")),
|
|
101
102
|
}),
|
|
102
103
|
record.xata.score,
|
|
103
|
-
]);
|
|
104
|
+
]) ?? []);
|
|
104
105
|
}
|
|
105
106
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('../../dist/document_loaders/fs/chatgpt.cjs');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../../dist/document_loaders/fs/chatgpt.js'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../../dist/document_loaders/fs/chatgpt.js'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('../dist/embeddings/gradient_ai.cjs');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../dist/embeddings/gradient_ai.js'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../dist/embeddings/gradient_ai.js'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('../dist/llms/gradient_ai.cjs');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../dist/llms/gradient_ai.js'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../dist/llms/gradient_ai.js'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('../dist/llms/watsonx_ai.cjs');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../dist/llms/watsonx_ai.js'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../dist/llms/watsonx_ai.js'
|