langchain 0.0.199 → 0.0.201

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 (87) hide show
  1. package/agents/toolkits/connery.cjs +1 -0
  2. package/agents/toolkits/connery.d.ts +1 -0
  3. package/agents/toolkits/connery.js +1 -0
  4. package/dist/agents/index.cjs +3 -1
  5. package/dist/agents/index.d.ts +1 -1
  6. package/dist/agents/index.js +1 -1
  7. package/dist/agents/toolkits/connery/index.cjs +39 -0
  8. package/dist/agents/toolkits/connery/index.d.ts +23 -0
  9. package/dist/agents/toolkits/connery/index.js +35 -0
  10. package/dist/agents/toolkits/conversational_retrieval/tool.cjs +1 -1
  11. package/dist/agents/toolkits/conversational_retrieval/tool.js +1 -1
  12. package/dist/chat_models/fake.cjs +2 -114
  13. package/dist/chat_models/fake.d.ts +1 -52
  14. package/dist/chat_models/fake.js +1 -113
  15. package/dist/chat_models/llama_cpp.cjs +2 -1
  16. package/dist/chat_models/llama_cpp.d.ts +1 -1
  17. package/dist/chat_models/llama_cpp.js +2 -1
  18. package/dist/chat_models/minimax.d.ts +1 -1
  19. package/dist/document_loaders/fs/obsidian.cjs +240 -0
  20. package/dist/document_loaders/fs/obsidian.d.ts +26 -0
  21. package/dist/document_loaders/fs/obsidian.js +233 -0
  22. package/dist/embeddings/gradient_ai.cjs +103 -0
  23. package/dist/embeddings/gradient_ai.d.ts +48 -0
  24. package/dist/embeddings/gradient_ai.js +99 -0
  25. package/dist/llms/gradient_ai.cjs +22 -8
  26. package/dist/llms/gradient_ai.d.ts +7 -2
  27. package/dist/llms/gradient_ai.js +22 -8
  28. package/dist/llms/llama_cpp.cjs +2 -1
  29. package/dist/llms/llama_cpp.d.ts +1 -1
  30. package/dist/llms/llama_cpp.js +2 -1
  31. package/dist/load/import_constants.cjs +3 -0
  32. package/dist/load/import_constants.js +3 -0
  33. package/dist/load/import_map.cjs +5 -3
  34. package/dist/load/import_map.d.ts +2 -0
  35. package/dist/load/import_map.js +2 -0
  36. package/dist/memory/vector_store.cjs +1 -1
  37. package/dist/memory/vector_store.js +1 -1
  38. package/dist/tools/connery.cjs +279 -0
  39. package/dist/tools/connery.d.ts +145 -0
  40. package/dist/tools/connery.js +274 -0
  41. package/dist/tools/gmail/base.cjs +69 -0
  42. package/dist/tools/gmail/base.d.ts +19 -0
  43. package/dist/tools/gmail/base.js +65 -0
  44. package/dist/tools/gmail/create_draft.cjs +62 -0
  45. package/dist/tools/gmail/create_draft.d.ts +35 -0
  46. package/dist/tools/gmail/create_draft.js +58 -0
  47. package/dist/tools/gmail/descriptions.cjs +118 -0
  48. package/dist/tools/gmail/descriptions.d.ts +5 -0
  49. package/dist/tools/gmail/descriptions.js +115 -0
  50. package/dist/tools/gmail/get_message.cjs +83 -0
  51. package/dist/tools/gmail/get_message.d.ts +18 -0
  52. package/dist/tools/gmail/get_message.js +79 -0
  53. package/dist/tools/gmail/get_thread.cjs +89 -0
  54. package/dist/tools/gmail/get_thread.d.ts +18 -0
  55. package/dist/tools/gmail/get_thread.js +85 -0
  56. package/dist/tools/gmail/index.cjs +13 -0
  57. package/dist/tools/gmail/index.d.ts +11 -0
  58. package/dist/tools/gmail/index.js +5 -0
  59. package/dist/tools/gmail/search.cjs +118 -0
  60. package/dist/tools/gmail/search.d.ts +29 -0
  61. package/dist/tools/gmail/search.js +114 -0
  62. package/dist/tools/gmail/send_message.cjs +74 -0
  63. package/dist/tools/gmail/send_message.d.ts +35 -0
  64. package/dist/tools/gmail/send_message.js +70 -0
  65. package/dist/tools/webbrowser.cjs +1 -1
  66. package/dist/tools/webbrowser.js +1 -1
  67. package/dist/tools/wolframalpha.cjs +1 -1
  68. package/dist/tools/wolframalpha.js +1 -1
  69. package/dist/util/document.cjs +1 -1
  70. package/dist/util/document.d.ts +1 -1
  71. package/dist/util/document.js +1 -1
  72. package/dist/util/tiktoken.cjs +15 -24
  73. package/dist/util/tiktoken.d.ts +1 -9
  74. package/dist/util/tiktoken.js +1 -21
  75. package/document_loaders/fs/obsidian.cjs +1 -0
  76. package/document_loaders/fs/obsidian.d.ts +1 -0
  77. package/document_loaders/fs/obsidian.js +1 -0
  78. package/embeddings/gradient_ai.cjs +1 -0
  79. package/embeddings/gradient_ai.d.ts +1 -0
  80. package/embeddings/gradient_ai.js +1 -0
  81. package/package.json +43 -3
  82. package/tools/connery.cjs +1 -0
  83. package/tools/connery.d.ts +1 -0
  84. package/tools/connery.js +1 -0
  85. package/tools/gmail.cjs +1 -0
  86. package/tools/gmail.d.ts +1 -0
  87. package/tools/gmail.js +1 -0
@@ -0,0 +1,118 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GmailSearch = void 0;
4
+ const zod_1 = require("zod");
5
+ const base_js_1 = require("./base.cjs");
6
+ const descriptions_js_1 = require("./descriptions.cjs");
7
+ class GmailSearch extends base_js_1.GmailBaseTool {
8
+ constructor(fields) {
9
+ super(fields);
10
+ Object.defineProperty(this, "name", {
11
+ enumerable: true,
12
+ configurable: true,
13
+ writable: true,
14
+ value: "search_gmail"
15
+ });
16
+ Object.defineProperty(this, "schema", {
17
+ enumerable: true,
18
+ configurable: true,
19
+ writable: true,
20
+ value: zod_1.z.object({
21
+ query: zod_1.z.string(),
22
+ maxResults: zod_1.z.number().optional(),
23
+ resource: zod_1.z.enum(["messages", "threads"]).optional(),
24
+ })
25
+ });
26
+ Object.defineProperty(this, "description", {
27
+ enumerable: true,
28
+ configurable: true,
29
+ writable: true,
30
+ value: descriptions_js_1.SEARCH_DESCRIPTION
31
+ });
32
+ }
33
+ async _call(arg) {
34
+ const { query, maxResults = 10, resource = "messages" } = arg;
35
+ const response = await this.gmail.users.messages.list({
36
+ userId: "me",
37
+ q: query,
38
+ maxResults,
39
+ });
40
+ const { data } = response;
41
+ if (!data) {
42
+ throw new Error("No data returned from Gmail");
43
+ }
44
+ const { messages } = data;
45
+ if (!messages) {
46
+ throw new Error("No messages returned from Gmail");
47
+ }
48
+ if (resource === "messages") {
49
+ const parsedMessages = await this.parseMessages(messages);
50
+ return `Result for the query ${query}:\n${JSON.stringify(parsedMessages)}`;
51
+ }
52
+ else if (resource === "threads") {
53
+ const parsedThreads = await this.parseThreads(messages);
54
+ return `Result for the query ${query}:\n${JSON.stringify(parsedThreads)}`;
55
+ }
56
+ throw new Error(`Invalid resource: ${resource}`);
57
+ }
58
+ async parseMessages(messages) {
59
+ const parsedMessages = await Promise.all(messages.map(async (message) => {
60
+ const messageData = await this.gmail.users.messages.get({
61
+ userId: "me",
62
+ format: "raw",
63
+ id: message.id ?? "",
64
+ });
65
+ const headers = messageData.data.payload?.headers || [];
66
+ const subject = headers.find((header) => header.name === "Subject");
67
+ const sender = headers.find((header) => header.name === "From");
68
+ let body = "";
69
+ if (messageData.data.payload?.parts) {
70
+ body = messageData.data.payload.parts
71
+ .map((part) => part.body?.data ?? "")
72
+ .join("");
73
+ }
74
+ else if (messageData.data.payload?.body?.data) {
75
+ body = messageData.data.payload.body.data;
76
+ }
77
+ return {
78
+ id: message.id,
79
+ threadId: message.threadId,
80
+ snippet: message.snippet,
81
+ body,
82
+ subject,
83
+ sender,
84
+ };
85
+ }));
86
+ return parsedMessages;
87
+ }
88
+ async parseThreads(threads) {
89
+ const parsedThreads = await Promise.all(threads.map(async (thread) => {
90
+ const threadData = await this.gmail.users.threads.get({
91
+ userId: "me",
92
+ format: "raw",
93
+ id: thread.id ?? "",
94
+ });
95
+ const headers = threadData.data.messages?.[0]?.payload?.headers || [];
96
+ const subject = headers.find((header) => header.name === "Subject");
97
+ const sender = headers.find((header) => header.name === "From");
98
+ let body = "";
99
+ if (threadData.data.messages?.[0]?.payload?.parts) {
100
+ body = threadData.data.messages[0].payload.parts
101
+ .map((part) => part.body?.data ?? "")
102
+ .join("");
103
+ }
104
+ else if (threadData.data.messages?.[0]?.payload?.body?.data) {
105
+ body = threadData.data.messages[0].payload.body.data;
106
+ }
107
+ return {
108
+ id: thread.id,
109
+ snippet: thread.snippet,
110
+ body,
111
+ subject,
112
+ sender,
113
+ };
114
+ }));
115
+ return parsedThreads;
116
+ }
117
+ }
118
+ exports.GmailSearch = GmailSearch;
@@ -0,0 +1,29 @@
1
+ import { gmail_v1 } from "googleapis";
2
+ import { z } from "zod";
3
+ import { GmailBaseTool, GmailBaseToolParams } from "./base.js";
4
+ export declare class GmailSearch extends GmailBaseTool {
5
+ name: string;
6
+ schema: z.ZodObject<{
7
+ query: z.ZodString;
8
+ maxResults: z.ZodOptional<z.ZodNumber>;
9
+ resource: z.ZodOptional<z.ZodEnum<["messages", "threads"]>>;
10
+ }, "strip", z.ZodTypeAny, {
11
+ query: string;
12
+ maxResults?: number | undefined;
13
+ resource?: "messages" | "threads" | undefined;
14
+ }, {
15
+ query: string;
16
+ maxResults?: number | undefined;
17
+ resource?: "messages" | "threads" | undefined;
18
+ }>;
19
+ description: string;
20
+ constructor(fields?: GmailBaseToolParams);
21
+ _call(arg: z.output<typeof this.schema>): Promise<string>;
22
+ parseMessages(messages: gmail_v1.Schema$Message[]): Promise<gmail_v1.Schema$Message[]>;
23
+ parseThreads(threads: gmail_v1.Schema$Thread[]): Promise<gmail_v1.Schema$Thread[]>;
24
+ }
25
+ export type SearchSchema = {
26
+ query: string;
27
+ maxResults?: number;
28
+ resource?: "messages" | "threads";
29
+ };
@@ -0,0 +1,114 @@
1
+ import { z } from "zod";
2
+ import { GmailBaseTool } from "./base.js";
3
+ import { SEARCH_DESCRIPTION } from "./descriptions.js";
4
+ export class GmailSearch extends GmailBaseTool {
5
+ constructor(fields) {
6
+ super(fields);
7
+ Object.defineProperty(this, "name", {
8
+ enumerable: true,
9
+ configurable: true,
10
+ writable: true,
11
+ value: "search_gmail"
12
+ });
13
+ Object.defineProperty(this, "schema", {
14
+ enumerable: true,
15
+ configurable: true,
16
+ writable: true,
17
+ value: z.object({
18
+ query: z.string(),
19
+ maxResults: z.number().optional(),
20
+ resource: z.enum(["messages", "threads"]).optional(),
21
+ })
22
+ });
23
+ Object.defineProperty(this, "description", {
24
+ enumerable: true,
25
+ configurable: true,
26
+ writable: true,
27
+ value: SEARCH_DESCRIPTION
28
+ });
29
+ }
30
+ async _call(arg) {
31
+ const { query, maxResults = 10, resource = "messages" } = arg;
32
+ const response = await this.gmail.users.messages.list({
33
+ userId: "me",
34
+ q: query,
35
+ maxResults,
36
+ });
37
+ const { data } = response;
38
+ if (!data) {
39
+ throw new Error("No data returned from Gmail");
40
+ }
41
+ const { messages } = data;
42
+ if (!messages) {
43
+ throw new Error("No messages returned from Gmail");
44
+ }
45
+ if (resource === "messages") {
46
+ const parsedMessages = await this.parseMessages(messages);
47
+ return `Result for the query ${query}:\n${JSON.stringify(parsedMessages)}`;
48
+ }
49
+ else if (resource === "threads") {
50
+ const parsedThreads = await this.parseThreads(messages);
51
+ return `Result for the query ${query}:\n${JSON.stringify(parsedThreads)}`;
52
+ }
53
+ throw new Error(`Invalid resource: ${resource}`);
54
+ }
55
+ async parseMessages(messages) {
56
+ const parsedMessages = await Promise.all(messages.map(async (message) => {
57
+ const messageData = await this.gmail.users.messages.get({
58
+ userId: "me",
59
+ format: "raw",
60
+ id: message.id ?? "",
61
+ });
62
+ const headers = messageData.data.payload?.headers || [];
63
+ const subject = headers.find((header) => header.name === "Subject");
64
+ const sender = headers.find((header) => header.name === "From");
65
+ let body = "";
66
+ if (messageData.data.payload?.parts) {
67
+ body = messageData.data.payload.parts
68
+ .map((part) => part.body?.data ?? "")
69
+ .join("");
70
+ }
71
+ else if (messageData.data.payload?.body?.data) {
72
+ body = messageData.data.payload.body.data;
73
+ }
74
+ return {
75
+ id: message.id,
76
+ threadId: message.threadId,
77
+ snippet: message.snippet,
78
+ body,
79
+ subject,
80
+ sender,
81
+ };
82
+ }));
83
+ return parsedMessages;
84
+ }
85
+ async parseThreads(threads) {
86
+ const parsedThreads = await Promise.all(threads.map(async (thread) => {
87
+ const threadData = await this.gmail.users.threads.get({
88
+ userId: "me",
89
+ format: "raw",
90
+ id: thread.id ?? "",
91
+ });
92
+ const headers = threadData.data.messages?.[0]?.payload?.headers || [];
93
+ const subject = headers.find((header) => header.name === "Subject");
94
+ const sender = headers.find((header) => header.name === "From");
95
+ let body = "";
96
+ if (threadData.data.messages?.[0]?.payload?.parts) {
97
+ body = threadData.data.messages[0].payload.parts
98
+ .map((part) => part.body?.data ?? "")
99
+ .join("");
100
+ }
101
+ else if (threadData.data.messages?.[0]?.payload?.body?.data) {
102
+ body = threadData.data.messages[0].payload.body.data;
103
+ }
104
+ return {
105
+ id: thread.id,
106
+ snippet: thread.snippet,
107
+ body,
108
+ subject,
109
+ sender,
110
+ };
111
+ }));
112
+ return parsedThreads;
113
+ }
114
+ }
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GmailSendMessage = void 0;
4
+ const zod_1 = require("zod");
5
+ const base_js_1 = require("./base.cjs");
6
+ const descriptions_js_1 = require("./descriptions.cjs");
7
+ class GmailSendMessage extends base_js_1.GmailBaseTool {
8
+ constructor(fields) {
9
+ super(fields);
10
+ Object.defineProperty(this, "name", {
11
+ enumerable: true,
12
+ configurable: true,
13
+ writable: true,
14
+ value: "gmail_send_message"
15
+ });
16
+ Object.defineProperty(this, "schema", {
17
+ enumerable: true,
18
+ configurable: true,
19
+ writable: true,
20
+ value: zod_1.z.object({
21
+ message: zod_1.z.string(),
22
+ to: zod_1.z.array(zod_1.z.string()),
23
+ subject: zod_1.z.string(),
24
+ cc: zod_1.z.array(zod_1.z.string()).optional(),
25
+ bcc: zod_1.z.array(zod_1.z.string()).optional(),
26
+ })
27
+ });
28
+ Object.defineProperty(this, "description", {
29
+ enumerable: true,
30
+ configurable: true,
31
+ writable: true,
32
+ value: descriptions_js_1.GET_MESSAGE_DESCRIPTION
33
+ });
34
+ }
35
+ createEmailMessage({ message, to, subject, cc, bcc, }) {
36
+ const emailLines = [];
37
+ // Format the recipient(s)
38
+ const formatEmailList = (emails) => Array.isArray(emails) ? emails.join(",") : emails;
39
+ emailLines.push(`To: ${formatEmailList(to)}`);
40
+ if (cc)
41
+ emailLines.push(`Cc: ${formatEmailList(cc)}`);
42
+ if (bcc)
43
+ emailLines.push(`Bcc: ${formatEmailList(bcc)}`);
44
+ emailLines.push(`Subject: ${subject}`);
45
+ emailLines.push("");
46
+ emailLines.push(message);
47
+ // Convert the email message to base64url string
48
+ const email = emailLines.join("\r\n").trim();
49
+ // this encode may be an issue
50
+ return Buffer.from(email).toString("base64url");
51
+ }
52
+ async _call({ message, to, subject, cc, bcc, }) {
53
+ const rawMessage = this.createEmailMessage({
54
+ message,
55
+ to,
56
+ subject,
57
+ cc,
58
+ bcc,
59
+ });
60
+ try {
61
+ const response = await this.gmail.users.messages.send({
62
+ userId: "me",
63
+ requestBody: {
64
+ raw: rawMessage,
65
+ },
66
+ });
67
+ return `Message sent. Message Id: ${response.data.id}`;
68
+ }
69
+ catch (error) {
70
+ throw new Error(`An error occurred while sending the message: ${error}`);
71
+ }
72
+ }
73
+ }
74
+ exports.GmailSendMessage = GmailSendMessage;
@@ -0,0 +1,35 @@
1
+ import { z } from "zod";
2
+ import { GmailBaseTool, GmailBaseToolParams } from "./base.js";
3
+ export declare class GmailSendMessage extends GmailBaseTool {
4
+ name: string;
5
+ schema: z.ZodObject<{
6
+ message: z.ZodString;
7
+ to: z.ZodArray<z.ZodString, "many">;
8
+ subject: z.ZodString;
9
+ cc: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
10
+ bcc: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
11
+ }, "strip", z.ZodTypeAny, {
12
+ message: string;
13
+ subject: string;
14
+ to: string[];
15
+ cc?: string[] | undefined;
16
+ bcc?: string[] | undefined;
17
+ }, {
18
+ message: string;
19
+ subject: string;
20
+ to: string[];
21
+ cc?: string[] | undefined;
22
+ bcc?: string[] | undefined;
23
+ }>;
24
+ description: string;
25
+ constructor(fields?: GmailBaseToolParams);
26
+ private createEmailMessage;
27
+ _call({ message, to, subject, cc, bcc, }: z.output<typeof this.schema>): Promise<string>;
28
+ }
29
+ export type SendMessageSchema = {
30
+ message: string;
31
+ to: string[];
32
+ subject: string;
33
+ cc?: string[];
34
+ bcc?: string[];
35
+ };
@@ -0,0 +1,70 @@
1
+ import { z } from "zod";
2
+ import { GmailBaseTool } from "./base.js";
3
+ import { GET_MESSAGE_DESCRIPTION } from "./descriptions.js";
4
+ export class GmailSendMessage extends GmailBaseTool {
5
+ constructor(fields) {
6
+ super(fields);
7
+ Object.defineProperty(this, "name", {
8
+ enumerable: true,
9
+ configurable: true,
10
+ writable: true,
11
+ value: "gmail_send_message"
12
+ });
13
+ Object.defineProperty(this, "schema", {
14
+ enumerable: true,
15
+ configurable: true,
16
+ writable: true,
17
+ value: z.object({
18
+ message: z.string(),
19
+ to: z.array(z.string()),
20
+ subject: z.string(),
21
+ cc: z.array(z.string()).optional(),
22
+ bcc: z.array(z.string()).optional(),
23
+ })
24
+ });
25
+ Object.defineProperty(this, "description", {
26
+ enumerable: true,
27
+ configurable: true,
28
+ writable: true,
29
+ value: GET_MESSAGE_DESCRIPTION
30
+ });
31
+ }
32
+ createEmailMessage({ message, to, subject, cc, bcc, }) {
33
+ const emailLines = [];
34
+ // Format the recipient(s)
35
+ const formatEmailList = (emails) => Array.isArray(emails) ? emails.join(",") : emails;
36
+ emailLines.push(`To: ${formatEmailList(to)}`);
37
+ if (cc)
38
+ emailLines.push(`Cc: ${formatEmailList(cc)}`);
39
+ if (bcc)
40
+ emailLines.push(`Bcc: ${formatEmailList(bcc)}`);
41
+ emailLines.push(`Subject: ${subject}`);
42
+ emailLines.push("");
43
+ emailLines.push(message);
44
+ // Convert the email message to base64url string
45
+ const email = emailLines.join("\r\n").trim();
46
+ // this encode may be an issue
47
+ return Buffer.from(email).toString("base64url");
48
+ }
49
+ async _call({ message, to, subject, cc, bcc, }) {
50
+ const rawMessage = this.createEmailMessage({
51
+ message,
52
+ to,
53
+ subject,
54
+ cc,
55
+ bcc,
56
+ });
57
+ try {
58
+ const response = await this.gmail.users.messages.send({
59
+ userId: "me",
60
+ requestBody: {
61
+ raw: rawMessage,
62
+ },
63
+ });
64
+ return `Message sent. Message Id: ${response.data.id}`;
65
+ }
66
+ catch (error) {
67
+ throw new Error(`An error occurred while sending the message: ${error}`);
68
+ }
69
+ }
70
+ }
@@ -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, "\n");
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());
@@ -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, "\n");
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());
@@ -41,7 +41,7 @@ class WolframAlphaTool extends base_js_1.Tool {
41
41
  return "WolframAlphaTool";
42
42
  }
43
43
  async _call(query) {
44
- const url = `https://www.wolframalpha.com/api/v1/llm-api?appid=${this.appid}&input=${query}`;
44
+ const url = `https://www.wolframalpha.com/api/v1/llm-api?appid=${this.appid}&input=${encodeURIComponent(query)}`;
45
45
  const res = await fetch(url);
46
46
  return res.text();
47
47
  }
@@ -38,7 +38,7 @@ export class WolframAlphaTool extends Tool {
38
38
  return "WolframAlphaTool";
39
39
  }
40
40
  async _call(query) {
41
- const url = `https://www.wolframalpha.com/api/v1/llm-api?appid=${this.appid}&input=${query}`;
41
+ const url = `https://www.wolframalpha.com/api/v1/llm-api?appid=${this.appid}&input=${encodeURIComponent(query)}`;
42
42
  const res = await fetch(url);
43
43
  return res.text();
44
44
  }
@@ -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, separator = "\n\n") => documents.map((doc) => doc.pageContent).join(separator);
11
+ const formatDocumentsAsString = (documents) => documents.map((doc) => doc.pageContent).join("\n\n");
12
12
  exports.formatDocumentsAsString = formatDocumentsAsString;
@@ -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[], separator?: string) => string;
9
+ export declare const formatDocumentsAsString: (documents: Document[]) => string;
@@ -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, separator = "\n\n") => documents.map((doc) => doc.pageContent).join(separator);
8
+ export const formatDocumentsAsString = (documents) => documents.map((doc) => doc.pageContent).join("\n\n");
@@ -1,26 +1,17 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.encodingForModel = exports.getEncoding = void 0;
4
- const lite_1 = require("js-tiktoken/lite");
5
- const async_caller_js_1 = require("./async_caller.cjs");
6
- const cache = {};
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
- return new lite_1.Tiktoken(await cache[encoding], options?.extendedSpecialTokens);
21
- }
22
- exports.getEncoding = getEncoding;
23
- async function encodingForModel(model, options) {
24
- return getEncoding((0, lite_1.getEncodingNameForModel)(model), options);
25
- }
26
- exports.encodingForModel = encodingForModel;
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);
@@ -1,9 +1 @@
1
- import { Tiktoken, TiktokenEncoding, TiktokenModel } from "js-tiktoken/lite";
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";
@@ -1,21 +1 @@
1
- import { Tiktoken, getEncodingNameForModel, } from "js-tiktoken/lite";
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";
@@ -0,0 +1 @@
1
+ module.exports = require('../../dist/document_loaders/fs/obsidian.cjs');
@@ -0,0 +1 @@
1
+ export * from '../../dist/document_loaders/fs/obsidian.js'
@@ -0,0 +1 @@
1
+ export * from '../../dist/document_loaders/fs/obsidian.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'