langchain 0.1.2 → 0.1.3
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/openai_functions/index.cjs +3 -3
- package/dist/agents/openai_functions/index.js +3 -3
- package/dist/agents/openai_functions/output_parser.cjs +1 -1
- package/dist/agents/openai_functions/output_parser.d.ts +1 -1
- package/dist/agents/openai_functions/output_parser.js +1 -1
- package/dist/agents/openai_tools/index.cjs +2 -2
- package/dist/agents/openai_tools/index.js +2 -2
- package/dist/agents/openai_tools/output_parser.cjs +1 -1
- package/dist/agents/openai_tools/output_parser.d.ts +1 -1
- package/dist/agents/openai_tools/output_parser.js +1 -1
- package/dist/cache/cloudflare_kv.cjs +2 -1
- package/dist/cache/cloudflare_kv.js +2 -1
- package/dist/chains/history_aware_retriever.cjs +1 -1
- package/dist/chains/history_aware_retriever.d.ts +1 -1
- package/dist/chains/history_aware_retriever.js +1 -1
- package/dist/chains/sql_db/sql_db_prompt.cjs +20 -1
- package/dist/chains/sql_db/sql_db_prompt.d.ts +6 -0
- package/dist/chains/sql_db/sql_db_prompt.js +19 -0
- package/dist/chat_models/cloudflare_workersai.cjs +2 -0
- package/dist/chat_models/cloudflare_workersai.js +2 -0
- package/dist/embeddings/cloudflare_workersai.cjs +2 -0
- package/dist/embeddings/cloudflare_workersai.js +2 -0
- package/dist/experimental/chat_models/anthropic_functions.cjs +2 -2
- package/dist/experimental/chat_models/anthropic_functions.js +2 -2
- package/dist/llms/cloudflare_workersai.cjs +2 -0
- package/dist/llms/cloudflare_workersai.js +2 -0
- package/dist/stores/message/cloudflare_d1.cjs +2 -0
- package/dist/stores/message/cloudflare_d1.js +2 -0
- package/dist/tools/convert_to_openai.cjs +3 -26
- package/dist/tools/convert_to_openai.d.ts +2 -8
- package/dist/tools/convert_to_openai.js +2 -24
- package/dist/util/sql_utils.cjs +23 -0
- package/dist/util/sql_utils.js +24 -1
- package/dist/vectorstores/cloudflare_vectorize.cjs +2 -0
- package/dist/vectorstores/cloudflare_vectorize.js +2 -0
- package/package.json +4 -4
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createOpenAIFunctionsAgent = exports.OpenAIAgent = exports._formatIntermediateSteps = void 0;
|
|
4
4
|
const runnables_1 = require("@langchain/core/runnables");
|
|
5
|
-
const
|
|
5
|
+
const function_calling_1 = require("@langchain/core/utils/function_calling");
|
|
6
6
|
const messages_1 = require("@langchain/core/messages");
|
|
7
7
|
const prompts_1 = require("@langchain/core/prompts");
|
|
8
8
|
const agent_js_1 = require("../agent.cjs");
|
|
@@ -145,7 +145,7 @@ class OpenAIAgent extends agent_js_1.Agent {
|
|
|
145
145
|
const llm = this.llmChain.llm;
|
|
146
146
|
const valuesForPrompt = { ...newInputs };
|
|
147
147
|
const valuesForLLM = {
|
|
148
|
-
functions: this.tools.map(
|
|
148
|
+
functions: this.tools.map(function_calling_1.convertToOpenAIFunction),
|
|
149
149
|
};
|
|
150
150
|
const callKeys = "callKeys" in this.llmChain.llm ? this.llmChain.llm.callKeys : [];
|
|
151
151
|
for (const key of callKeys) {
|
|
@@ -227,7 +227,7 @@ async function createOpenAIFunctionsAgent({ llm, tools, prompt, }) {
|
|
|
227
227
|
].join("\n"));
|
|
228
228
|
}
|
|
229
229
|
const llmWithTools = llm.bind({
|
|
230
|
-
functions: tools.map(
|
|
230
|
+
functions: tools.map(function_calling_1.convertToOpenAIFunction),
|
|
231
231
|
});
|
|
232
232
|
const agent = runnables_1.RunnableSequence.from([
|
|
233
233
|
runnables_1.RunnablePassthrough.assign({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RunnablePassthrough, RunnableSequence, } from "@langchain/core/runnables";
|
|
2
|
-
import {
|
|
2
|
+
import { convertToOpenAIFunction } from "@langchain/core/utils/function_calling";
|
|
3
3
|
import { AIMessage, FunctionMessage, } from "@langchain/core/messages";
|
|
4
4
|
import { ChatPromptTemplate, HumanMessagePromptTemplate, MessagesPlaceholder, SystemMessagePromptTemplate, } from "@langchain/core/prompts";
|
|
5
5
|
import { Agent } from "../agent.js";
|
|
@@ -141,7 +141,7 @@ export class OpenAIAgent extends Agent {
|
|
|
141
141
|
const llm = this.llmChain.llm;
|
|
142
142
|
const valuesForPrompt = { ...newInputs };
|
|
143
143
|
const valuesForLLM = {
|
|
144
|
-
functions: this.tools.map(
|
|
144
|
+
functions: this.tools.map(convertToOpenAIFunction),
|
|
145
145
|
};
|
|
146
146
|
const callKeys = "callKeys" in this.llmChain.llm ? this.llmChain.llm.callKeys : [];
|
|
147
147
|
for (const key of callKeys) {
|
|
@@ -222,7 +222,7 @@ export async function createOpenAIFunctionsAgent({ llm, tools, prompt, }) {
|
|
|
222
222
|
].join("\n"));
|
|
223
223
|
}
|
|
224
224
|
const llmWithTools = llm.bind({
|
|
225
|
-
functions: tools.map(
|
|
225
|
+
functions: tools.map(convertToOpenAIFunction),
|
|
226
226
|
});
|
|
227
227
|
const agent = RunnableSequence.from([
|
|
228
228
|
RunnablePassthrough.assign({
|
|
@@ -18,7 +18,7 @@ const types_js_1 = require("../types.cjs");
|
|
|
18
18
|
* modelName: "gpt-4",
|
|
19
19
|
* temperature: 0,
|
|
20
20
|
* }).bind({
|
|
21
|
-
* functions: tools.map((tool) =>
|
|
21
|
+
* functions: tools.map((tool) => convertToOpenAIFunction(tool)),
|
|
22
22
|
* });
|
|
23
23
|
*
|
|
24
24
|
* const runnableAgent = RunnableSequence.from([
|
|
@@ -22,7 +22,7 @@ export type FunctionsAgentAction = AgentAction & {
|
|
|
22
22
|
* modelName: "gpt-4",
|
|
23
23
|
* temperature: 0,
|
|
24
24
|
* }).bind({
|
|
25
|
-
* functions: tools.map((tool) =>
|
|
25
|
+
* functions: tools.map((tool) => convertToOpenAIFunction(tool)),
|
|
26
26
|
* });
|
|
27
27
|
*
|
|
28
28
|
* const runnableAgent = RunnableSequence.from([
|
|
@@ -15,7 +15,7 @@ import { AgentActionOutputParser } from "../types.js";
|
|
|
15
15
|
* modelName: "gpt-4",
|
|
16
16
|
* temperature: 0,
|
|
17
17
|
* }).bind({
|
|
18
|
-
* functions: tools.map((tool) =>
|
|
18
|
+
* functions: tools.map((tool) => convertToOpenAIFunction(tool)),
|
|
19
19
|
* });
|
|
20
20
|
*
|
|
21
21
|
* const runnableAgent = RunnableSequence.from([
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createOpenAIToolsAgent = exports.OpenAIToolsAgentOutputParser = void 0;
|
|
4
4
|
const runnables_1 = require("@langchain/core/runnables");
|
|
5
|
-
const
|
|
5
|
+
const function_calling_1 = require("@langchain/core/utils/function_calling");
|
|
6
6
|
const openai_tools_js_1 = require("../format_scratchpad/openai_tools.cjs");
|
|
7
7
|
const output_parser_js_1 = require("../openai/output_parser.cjs");
|
|
8
8
|
Object.defineProperty(exports, "OpenAIToolsAgentOutputParser", { enumerable: true, get: function () { return output_parser_js_1.OpenAIToolsAgentOutputParser; } });
|
|
@@ -69,7 +69,7 @@ async function createOpenAIToolsAgent({ llm, tools, prompt, }) {
|
|
|
69
69
|
`Found ${JSON.stringify(prompt.inputVariables)} instead.`,
|
|
70
70
|
].join("\n"));
|
|
71
71
|
}
|
|
72
|
-
const modelWithTools = llm.bind({ tools: tools.map(
|
|
72
|
+
const modelWithTools = llm.bind({ tools: tools.map(function_calling_1.convertToOpenAITool) });
|
|
73
73
|
const agent = runnables_1.RunnableSequence.from([
|
|
74
74
|
runnables_1.RunnablePassthrough.assign({
|
|
75
75
|
agent_scratchpad: (input) => (0, openai_tools_js_1.formatToOpenAIToolMessages)(input.steps),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RunnablePassthrough, RunnableSequence, } from "@langchain/core/runnables";
|
|
2
|
-
import {
|
|
2
|
+
import { convertToOpenAITool } from "@langchain/core/utils/function_calling";
|
|
3
3
|
import { formatToOpenAIToolMessages } from "../format_scratchpad/openai_tools.js";
|
|
4
4
|
import { OpenAIToolsAgentOutputParser, } from "../openai/output_parser.js";
|
|
5
5
|
export { OpenAIToolsAgentOutputParser };
|
|
@@ -66,7 +66,7 @@ export async function createOpenAIToolsAgent({ llm, tools, prompt, }) {
|
|
|
66
66
|
`Found ${JSON.stringify(prompt.inputVariables)} instead.`,
|
|
67
67
|
].join("\n"));
|
|
68
68
|
}
|
|
69
|
-
const modelWithTools = llm.bind({ tools: tools.map(
|
|
69
|
+
const modelWithTools = llm.bind({ tools: tools.map(convertToOpenAITool) });
|
|
70
70
|
const agent = RunnableSequence.from([
|
|
71
71
|
RunnablePassthrough.assign({
|
|
72
72
|
agent_scratchpad: (input) => formatToOpenAIToolMessages(input.steps),
|
|
@@ -24,7 +24,7 @@ const types_js_1 = require("../types.cjs");
|
|
|
24
24
|
* new ChatOpenAI({
|
|
25
25
|
* modelName: "gpt-3.5-turbo-1106",
|
|
26
26
|
* temperature: 0,
|
|
27
|
-
* }).bind({ tools: tools.map(
|
|
27
|
+
* }).bind({ tools: tools.map(convertToOpenAITool) }),
|
|
28
28
|
* new OpenAIToolsAgentOutputParser(),
|
|
29
29
|
* ]).withConfig({ runName: "OpenAIToolsAgent" });
|
|
30
30
|
*
|
|
@@ -32,7 +32,7 @@ export type ToolsAgentStep = AgentStep & {
|
|
|
32
32
|
* new ChatOpenAI({
|
|
33
33
|
* modelName: "gpt-3.5-turbo-1106",
|
|
34
34
|
* temperature: 0,
|
|
35
|
-
* }).bind({ tools: tools.map(
|
|
35
|
+
* }).bind({ tools: tools.map(convertToOpenAITool) }),
|
|
36
36
|
* new OpenAIToolsAgentOutputParser(),
|
|
37
37
|
* ]).withConfig({ runName: "OpenAIToolsAgent" });
|
|
38
38
|
*
|
|
@@ -21,7 +21,7 @@ import { AgentMultiActionOutputParser } from "../types.js";
|
|
|
21
21
|
* new ChatOpenAI({
|
|
22
22
|
* modelName: "gpt-3.5-turbo-1106",
|
|
23
23
|
* temperature: 0,
|
|
24
|
-
* }).bind({ tools: tools.map(
|
|
24
|
+
* }).bind({ tools: tools.map(convertToOpenAITool) }),
|
|
25
25
|
* new OpenAIToolsAgentOutputParser(),
|
|
26
26
|
* ]).withConfig({ runName: "OpenAIToolsAgent" });
|
|
27
27
|
*
|
|
@@ -17,6 +17,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
const entrypoint_deprecation_js_1 = require("../util/entrypoint_deprecation.cjs");
|
|
18
18
|
/* #__PURE__ */ (0, entrypoint_deprecation_js_1.logVersion010MigrationWarning)({
|
|
19
19
|
oldEntrypointName: "cache/cloudflare_kv",
|
|
20
|
-
newEntrypointName: "
|
|
20
|
+
newEntrypointName: "",
|
|
21
|
+
newPackageName: "@langchain/cloudflare",
|
|
21
22
|
});
|
|
22
23
|
__exportStar(require("@langchain/community/caches/cloudflare_kv"), exports);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { logVersion010MigrationWarning } from "../util/entrypoint_deprecation.js";
|
|
2
2
|
/* #__PURE__ */ logVersion010MigrationWarning({
|
|
3
3
|
oldEntrypointName: "cache/cloudflare_kv",
|
|
4
|
-
newEntrypointName: "
|
|
4
|
+
newEntrypointName: "",
|
|
5
|
+
newPackageName: "@langchain/cloudflare",
|
|
5
6
|
});
|
|
6
7
|
export * from "@langchain/community/caches/cloudflare_kv";
|
|
@@ -24,7 +24,7 @@ const output_parsers_1 = require("@langchain/core/output_parsers");
|
|
|
24
24
|
* const rephrasePrompt = await pull("langchain-ai/chat-langchain-rephrase");
|
|
25
25
|
* const llm = new ChatOpenAI({});
|
|
26
26
|
* const retriever = ...
|
|
27
|
-
* const
|
|
27
|
+
* const chain = await createHistoryAwareRetriever({
|
|
28
28
|
* llm,
|
|
29
29
|
* retriever,
|
|
30
30
|
* rephrasePrompt,
|
|
@@ -41,7 +41,7 @@ export type CreateHistoryAwareRetrieverParams = {
|
|
|
41
41
|
* const rephrasePrompt = await pull("langchain-ai/chat-langchain-rephrase");
|
|
42
42
|
* const llm = new ChatOpenAI({});
|
|
43
43
|
* const retriever = ...
|
|
44
|
-
* const
|
|
44
|
+
* const chain = await createHistoryAwareRetriever({
|
|
45
45
|
* llm,
|
|
46
46
|
* retriever,
|
|
47
47
|
* rephrasePrompt,
|
|
@@ -21,7 +21,7 @@ import { StringOutputParser } from "@langchain/core/output_parsers";
|
|
|
21
21
|
* const rephrasePrompt = await pull("langchain-ai/chat-langchain-rephrase");
|
|
22
22
|
* const llm = new ChatOpenAI({});
|
|
23
23
|
* const retriever = ...
|
|
24
|
-
* const
|
|
24
|
+
* const chain = await createHistoryAwareRetriever({
|
|
25
25
|
* llm,
|
|
26
26
|
* retriever,
|
|
27
27
|
* rephrasePrompt,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SQL_SAP_HANA_PROMPT = exports.SQL_MSSQL_PROMPT = exports.SQL_MYSQL_PROMPT = exports.SQL_SQLITE_PROMPT = exports.SQL_POSTGRES_PROMPT = exports.DEFAULT_SQL_DATABASE_PROMPT = void 0;
|
|
3
|
+
exports.SQL_ORACLE_PROMPT = exports.SQL_SAP_HANA_PROMPT = exports.SQL_MSSQL_PROMPT = exports.SQL_MYSQL_PROMPT = exports.SQL_SQLITE_PROMPT = exports.SQL_POSTGRES_PROMPT = exports.DEFAULT_SQL_DATABASE_PROMPT = void 0;
|
|
4
4
|
/* eslint-disable spaced-comment */
|
|
5
5
|
const prompts_1 = require("@langchain/core/prompts");
|
|
6
6
|
exports.DEFAULT_SQL_DATABASE_PROMPT = new prompts_1.PromptTemplate({
|
|
@@ -120,3 +120,22 @@ Only use the following tables:
|
|
|
120
120
|
Question: {input}`,
|
|
121
121
|
inputVariables: ["dialect", "table_info", "input", "top_k"],
|
|
122
122
|
});
|
|
123
|
+
exports.SQL_ORACLE_PROMPT = new prompts_1.PromptTemplate({
|
|
124
|
+
template: `You are a ORACLE expert. Given an input question, first create a syntactically correct ORACLE query to run, then look at the results of the query and return the answer to the input question.
|
|
125
|
+
Unless the user specifies in the question a specific number of examples to obtain, query for at most {top_k} results using the ROWNUM clause as per ORACLE. You can order the results to return the most informative data in the database.
|
|
126
|
+
Never query for all columns from a table. You must query only the columns that are needed to answer the question.
|
|
127
|
+
Pay attention to use only the column names you can see in the tables below. Be careful to not query for columns that do not exist. Also, pay attention to which column is in which table.
|
|
128
|
+
|
|
129
|
+
Use the following format:
|
|
130
|
+
|
|
131
|
+
Question: "Question here"
|
|
132
|
+
SQLQuery: "SQL Query to run"
|
|
133
|
+
SQLResult: "Result of the SQLQuery"
|
|
134
|
+
Answer: "Final answer here"
|
|
135
|
+
|
|
136
|
+
Only use the following tables:
|
|
137
|
+
{table_info}
|
|
138
|
+
|
|
139
|
+
Question: {input}`,
|
|
140
|
+
inputVariables: ["dialect", "table_info", "input", "top_k"],
|
|
141
|
+
});
|
|
@@ -117,3 +117,22 @@ Only use the following tables:
|
|
|
117
117
|
Question: {input}`,
|
|
118
118
|
inputVariables: ["dialect", "table_info", "input", "top_k"],
|
|
119
119
|
});
|
|
120
|
+
export const SQL_ORACLE_PROMPT = /*#__PURE__*/ new PromptTemplate({
|
|
121
|
+
template: `You are a ORACLE expert. Given an input question, first create a syntactically correct ORACLE query to run, then look at the results of the query and return the answer to the input question.
|
|
122
|
+
Unless the user specifies in the question a specific number of examples to obtain, query for at most {top_k} results using the ROWNUM clause as per ORACLE. You can order the results to return the most informative data in the database.
|
|
123
|
+
Never query for all columns from a table. You must query only the columns that are needed to answer the question.
|
|
124
|
+
Pay attention to use only the column names you can see in the tables below. Be careful to not query for columns that do not exist. Also, pay attention to which column is in which table.
|
|
125
|
+
|
|
126
|
+
Use the following format:
|
|
127
|
+
|
|
128
|
+
Question: "Question here"
|
|
129
|
+
SQLQuery: "SQL Query to run"
|
|
130
|
+
SQLResult: "Result of the SQLQuery"
|
|
131
|
+
Answer: "Final answer here"
|
|
132
|
+
|
|
133
|
+
Only use the following tables:
|
|
134
|
+
{table_info}
|
|
135
|
+
|
|
136
|
+
Question: {input}`,
|
|
137
|
+
inputVariables: ["dialect", "table_info", "input", "top_k"],
|
|
138
|
+
});
|
|
@@ -17,5 +17,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
const entrypoint_deprecation_js_1 = require("../util/entrypoint_deprecation.cjs");
|
|
18
18
|
/* #__PURE__ */ (0, entrypoint_deprecation_js_1.logVersion010MigrationWarning)({
|
|
19
19
|
oldEntrypointName: "chat_models/cloudflare_workersai",
|
|
20
|
+
newEntrypointName: "",
|
|
21
|
+
newPackageName: "@langchain/cloudflare",
|
|
20
22
|
});
|
|
21
23
|
__exportStar(require("@langchain/community/chat_models/cloudflare_workersai"), exports);
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { logVersion010MigrationWarning } from "../util/entrypoint_deprecation.js";
|
|
2
2
|
/* #__PURE__ */ logVersion010MigrationWarning({
|
|
3
3
|
oldEntrypointName: "chat_models/cloudflare_workersai",
|
|
4
|
+
newEntrypointName: "",
|
|
5
|
+
newPackageName: "@langchain/cloudflare",
|
|
4
6
|
});
|
|
5
7
|
export * from "@langchain/community/chat_models/cloudflare_workersai";
|
|
@@ -17,5 +17,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
const entrypoint_deprecation_js_1 = require("../util/entrypoint_deprecation.cjs");
|
|
18
18
|
/* #__PURE__ */ (0, entrypoint_deprecation_js_1.logVersion010MigrationWarning)({
|
|
19
19
|
oldEntrypointName: "embeddings/cloudflare_workersai",
|
|
20
|
+
newEntrypointName: "",
|
|
21
|
+
newPackageName: "@langchain/cloudflare",
|
|
20
22
|
});
|
|
21
23
|
__exportStar(require("@langchain/community/embeddings/cloudflare_workersai"), exports);
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { logVersion010MigrationWarning } from "../util/entrypoint_deprecation.js";
|
|
2
2
|
/* #__PURE__ */ logVersion010MigrationWarning({
|
|
3
3
|
oldEntrypointName: "embeddings/cloudflare_workersai",
|
|
4
|
+
newEntrypointName: "",
|
|
5
|
+
newPackageName: "@langchain/cloudflare",
|
|
4
6
|
});
|
|
5
7
|
export * from "@langchain/community/embeddings/cloudflare_workersai";
|
|
@@ -5,7 +5,7 @@ const fast_xml_parser_1 = require("fast-xml-parser");
|
|
|
5
5
|
const messages_1 = require("@langchain/core/messages");
|
|
6
6
|
const chat_models_1 = require("@langchain/core/language_models/chat_models");
|
|
7
7
|
const prompts_1 = require("@langchain/core/prompts");
|
|
8
|
-
const
|
|
8
|
+
const function_calling_1 = require("@langchain/core/utils/function_calling");
|
|
9
9
|
const anthropic_js_1 = require("../../chat_models/anthropic.cjs");
|
|
10
10
|
const TOOL_SYSTEM_PROMPT =
|
|
11
11
|
/* #__PURE__ */
|
|
@@ -71,7 +71,7 @@ class AnthropicFunctions extends chat_models_1.BaseChatModel {
|
|
|
71
71
|
let functionCall;
|
|
72
72
|
if (options.tools) {
|
|
73
73
|
// eslint-disable-next-line no-param-reassign
|
|
74
|
-
options.functions = (options.functions ?? []).concat(options.tools.map(
|
|
74
|
+
options.functions = (options.functions ?? []).concat(options.tools.map(function_calling_1.convertToOpenAIFunction));
|
|
75
75
|
}
|
|
76
76
|
if (options.functions !== undefined && options.functions.length > 0) {
|
|
77
77
|
const content = await TOOL_SYSTEM_PROMPT.format({
|
|
@@ -2,7 +2,7 @@ import { XMLParser } from "fast-xml-parser";
|
|
|
2
2
|
import { AIMessage, SystemMessage, } from "@langchain/core/messages";
|
|
3
3
|
import { BaseChatModel, } from "@langchain/core/language_models/chat_models";
|
|
4
4
|
import { PromptTemplate } from "@langchain/core/prompts";
|
|
5
|
-
import {
|
|
5
|
+
import { convertToOpenAIFunction } from "@langchain/core/utils/function_calling";
|
|
6
6
|
import { ChatAnthropic, DEFAULT_STOP_SEQUENCES, } from "../../chat_models/anthropic.js";
|
|
7
7
|
const TOOL_SYSTEM_PROMPT =
|
|
8
8
|
/* #__PURE__ */
|
|
@@ -68,7 +68,7 @@ export class AnthropicFunctions extends BaseChatModel {
|
|
|
68
68
|
let functionCall;
|
|
69
69
|
if (options.tools) {
|
|
70
70
|
// eslint-disable-next-line no-param-reassign
|
|
71
|
-
options.functions = (options.functions ?? []).concat(options.tools.map(
|
|
71
|
+
options.functions = (options.functions ?? []).concat(options.tools.map(convertToOpenAIFunction));
|
|
72
72
|
}
|
|
73
73
|
if (options.functions !== undefined && options.functions.length > 0) {
|
|
74
74
|
const content = await TOOL_SYSTEM_PROMPT.format({
|
|
@@ -17,5 +17,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
const entrypoint_deprecation_js_1 = require("../util/entrypoint_deprecation.cjs");
|
|
18
18
|
/* #__PURE__ */ (0, entrypoint_deprecation_js_1.logVersion010MigrationWarning)({
|
|
19
19
|
oldEntrypointName: "llms/cloudflare_workersai",
|
|
20
|
+
newEntrypointName: "",
|
|
21
|
+
newPackageName: "@langchain/cloudflare",
|
|
20
22
|
});
|
|
21
23
|
__exportStar(require("@langchain/community/llms/cloudflare_workersai"), exports);
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { logVersion010MigrationWarning } from "../util/entrypoint_deprecation.js";
|
|
2
2
|
/* #__PURE__ */ logVersion010MigrationWarning({
|
|
3
3
|
oldEntrypointName: "llms/cloudflare_workersai",
|
|
4
|
+
newEntrypointName: "",
|
|
5
|
+
newPackageName: "@langchain/cloudflare",
|
|
4
6
|
});
|
|
5
7
|
export * from "@langchain/community/llms/cloudflare_workersai";
|
|
@@ -17,5 +17,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
const entrypoint_deprecation_js_1 = require("../../util/entrypoint_deprecation.cjs");
|
|
18
18
|
/* #__PURE__ */ (0, entrypoint_deprecation_js_1.logVersion010MigrationWarning)({
|
|
19
19
|
oldEntrypointName: "stores/message/cloudflare_d1",
|
|
20
|
+
newEntrypointName: "",
|
|
21
|
+
newPackageName: "@langchain/cloudflare",
|
|
20
22
|
});
|
|
21
23
|
__exportStar(require("@langchain/community/stores/message/cloudflare_d1"), exports);
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { logVersion010MigrationWarning } from "../../util/entrypoint_deprecation.js";
|
|
2
2
|
/* #__PURE__ */ logVersion010MigrationWarning({
|
|
3
3
|
oldEntrypointName: "stores/message/cloudflare_d1",
|
|
4
|
+
newEntrypointName: "",
|
|
5
|
+
newPackageName: "@langchain/cloudflare",
|
|
4
6
|
});
|
|
5
7
|
export * from "@langchain/community/stores/message/cloudflare_d1";
|
|
@@ -2,32 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.formatToOpenAIAssistantTool = exports.formatToOpenAITool = exports.formatToOpenAIFunction = void 0;
|
|
4
4
|
const zod_to_json_schema_1 = require("zod-to-json-schema");
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
* function to convert the schema of the `StructuredTool` into a JSON
|
|
9
|
-
* schema, which is then used as the parameters for the OpenAI function.
|
|
10
|
-
*/
|
|
11
|
-
function formatToOpenAIFunction(tool) {
|
|
12
|
-
return {
|
|
13
|
-
name: tool.name,
|
|
14
|
-
description: tool.description,
|
|
15
|
-
parameters: (0, zod_to_json_schema_1.zodToJsonSchema)(tool.schema),
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
exports.formatToOpenAIFunction = formatToOpenAIFunction;
|
|
19
|
-
function formatToOpenAITool(tool) {
|
|
20
|
-
const schema = (0, zod_to_json_schema_1.zodToJsonSchema)(tool.schema);
|
|
21
|
-
return {
|
|
22
|
-
type: "function",
|
|
23
|
-
function: {
|
|
24
|
-
name: tool.name,
|
|
25
|
-
description: tool.description,
|
|
26
|
-
parameters: schema,
|
|
27
|
-
},
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
exports.formatToOpenAITool = formatToOpenAITool;
|
|
5
|
+
const function_calling_1 = require("@langchain/core/utils/function_calling");
|
|
6
|
+
Object.defineProperty(exports, "formatToOpenAIFunction", { enumerable: true, get: function () { return function_calling_1.convertToOpenAIFunction; } });
|
|
7
|
+
Object.defineProperty(exports, "formatToOpenAITool", { enumerable: true, get: function () { return function_calling_1.convertToOpenAITool; } });
|
|
31
8
|
function formatToOpenAIAssistantTool(tool) {
|
|
32
9
|
return {
|
|
33
10
|
type: "function",
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import type { OpenAIClient } from "@langchain/openai";
|
|
2
2
|
import type { StructuredToolInterface } from "@langchain/core/tools";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
* with OpenAI's ChatCompletionFunctions. It uses the `zodToJsonSchema`
|
|
6
|
-
* function to convert the schema of the `StructuredTool` into a JSON
|
|
7
|
-
* schema, which is then used as the parameters for the OpenAI function.
|
|
8
|
-
*/
|
|
9
|
-
export declare function formatToOpenAIFunction(tool: StructuredToolInterface): OpenAIClient.Chat.ChatCompletionCreateParams.Function;
|
|
10
|
-
export declare function formatToOpenAITool(tool: StructuredToolInterface): OpenAIClient.Chat.ChatCompletionTool;
|
|
3
|
+
import { convertToOpenAIFunction, convertToOpenAITool } from "@langchain/core/utils/function_calling";
|
|
4
|
+
export { convertToOpenAIFunction as formatToOpenAIFunction, convertToOpenAITool as formatToOpenAITool, };
|
|
11
5
|
export declare function formatToOpenAIAssistantTool(tool: StructuredToolInterface): OpenAIClient.Beta.AssistantCreateParams.AssistantToolsFunction;
|
|
@@ -1,28 +1,6 @@
|
|
|
1
1
|
import { zodToJsonSchema } from "zod-to-json-schema";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* with OpenAI's ChatCompletionFunctions. It uses the `zodToJsonSchema`
|
|
5
|
-
* function to convert the schema of the `StructuredTool` into a JSON
|
|
6
|
-
* schema, which is then used as the parameters for the OpenAI function.
|
|
7
|
-
*/
|
|
8
|
-
export function formatToOpenAIFunction(tool) {
|
|
9
|
-
return {
|
|
10
|
-
name: tool.name,
|
|
11
|
-
description: tool.description,
|
|
12
|
-
parameters: zodToJsonSchema(tool.schema),
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
export function formatToOpenAITool(tool) {
|
|
16
|
-
const schema = zodToJsonSchema(tool.schema);
|
|
17
|
-
return {
|
|
18
|
-
type: "function",
|
|
19
|
-
function: {
|
|
20
|
-
name: tool.name,
|
|
21
|
-
description: tool.description,
|
|
22
|
-
parameters: schema,
|
|
23
|
-
},
|
|
24
|
-
};
|
|
25
|
-
}
|
|
2
|
+
import { convertToOpenAIFunction, convertToOpenAITool, } from "@langchain/core/utils/function_calling";
|
|
3
|
+
export { convertToOpenAIFunction as formatToOpenAIFunction, convertToOpenAITool as formatToOpenAITool, };
|
|
26
4
|
export function formatToOpenAIAssistantTool(tool) {
|
|
27
5
|
return {
|
|
28
6
|
type: "function",
|
package/dist/util/sql_utils.cjs
CHANGED
|
@@ -126,6 +126,20 @@ const getTableAndColumnsName = async (appDataSource) => {
|
|
|
126
126
|
}));
|
|
127
127
|
return formatToSqlTable(repLowerCase);
|
|
128
128
|
}
|
|
129
|
+
if (appDataSource.options.type === "oracle") {
|
|
130
|
+
const schemaName = appDataSource.options.schema;
|
|
131
|
+
const sql = `
|
|
132
|
+
SELECT
|
|
133
|
+
TABLE_NAME AS "table_name",
|
|
134
|
+
COLUMN_NAME AS "column_name",
|
|
135
|
+
DATA_TYPE AS "data_type",
|
|
136
|
+
NULLABLE AS "is_nullable"
|
|
137
|
+
FROM ALL_TAB_COLS
|
|
138
|
+
WHERE
|
|
139
|
+
OWNER = UPPER('${schemaName}')`;
|
|
140
|
+
const rep = await appDataSource.query(sql);
|
|
141
|
+
return formatToSqlTable(rep);
|
|
142
|
+
}
|
|
129
143
|
throw new Error("Database type not implemented yet");
|
|
130
144
|
};
|
|
131
145
|
exports.getTableAndColumnsName = getTableAndColumnsName;
|
|
@@ -161,6 +175,9 @@ const generateTableInfoFromTables = async (tables, appDataSource, nbSampleRow, c
|
|
|
161
175
|
appDataSource.options?.username ??
|
|
162
176
|
"public";
|
|
163
177
|
}
|
|
178
|
+
else if (appDataSource.options.type === "oracle") {
|
|
179
|
+
schema = appDataSource.options.schema;
|
|
180
|
+
}
|
|
164
181
|
let sqlCreateTableQuery = schema
|
|
165
182
|
? `CREATE TABLE "${schema}"."${currentTable.tableName}" (\n`
|
|
166
183
|
: `CREATE TABLE ${currentTable.tableName} (\n`;
|
|
@@ -189,6 +206,9 @@ const generateTableInfoFromTables = async (tables, appDataSource, nbSampleRow, c
|
|
|
189
206
|
"public";
|
|
190
207
|
sqlSelectInfoQuery = `SELECT * FROM "${schema}"."${currentTable.tableName}" LIMIT ${nbSampleRow};\n`;
|
|
191
208
|
}
|
|
209
|
+
else if (appDataSource.options.type === "oracle") {
|
|
210
|
+
sqlSelectInfoQuery = `SELECT * FROM "${schema}"."${currentTable.tableName}" WHERE ROWNUM <= '${nbSampleRow}'`;
|
|
211
|
+
}
|
|
192
212
|
else {
|
|
193
213
|
sqlSelectInfoQuery = `SELECT * FROM "${currentTable.tableName}" LIMIT ${nbSampleRow};\n`;
|
|
194
214
|
}
|
|
@@ -229,6 +249,9 @@ const getPromptTemplateFromDataSource = (appDataSource) => {
|
|
|
229
249
|
if (appDataSource.options.type === "sap") {
|
|
230
250
|
return sql_db_prompt_js_1.SQL_SAP_HANA_PROMPT;
|
|
231
251
|
}
|
|
252
|
+
if (appDataSource.options.type === "oracle") {
|
|
253
|
+
return sql_db_prompt_js_1.SQL_ORACLE_PROMPT;
|
|
254
|
+
}
|
|
232
255
|
return sql_db_prompt_js_1.DEFAULT_SQL_DATABASE_PROMPT;
|
|
233
256
|
};
|
|
234
257
|
exports.getPromptTemplateFromDataSource = getPromptTemplateFromDataSource;
|
package/dist/util/sql_utils.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DEFAULT_SQL_DATABASE_PROMPT, SQL_SAP_HANA_PROMPT, SQL_MSSQL_PROMPT, SQL_MYSQL_PROMPT, SQL_POSTGRES_PROMPT, SQL_SQLITE_PROMPT, } from "../chains/sql_db/sql_db_prompt.js";
|
|
1
|
+
import { DEFAULT_SQL_DATABASE_PROMPT, SQL_SAP_HANA_PROMPT, SQL_MSSQL_PROMPT, SQL_MYSQL_PROMPT, SQL_POSTGRES_PROMPT, SQL_SQLITE_PROMPT, SQL_ORACLE_PROMPT, } from "../chains/sql_db/sql_db_prompt.js";
|
|
2
2
|
export const verifyListTablesExistInDatabase = (tablesFromDatabase, listTables, errorPrefixMsg) => {
|
|
3
3
|
const onlyTableNames = tablesFromDatabase.map((table) => table.tableName);
|
|
4
4
|
if (listTables.length > 0) {
|
|
@@ -120,6 +120,20 @@ export const getTableAndColumnsName = async (appDataSource) => {
|
|
|
120
120
|
}));
|
|
121
121
|
return formatToSqlTable(repLowerCase);
|
|
122
122
|
}
|
|
123
|
+
if (appDataSource.options.type === "oracle") {
|
|
124
|
+
const schemaName = appDataSource.options.schema;
|
|
125
|
+
const sql = `
|
|
126
|
+
SELECT
|
|
127
|
+
TABLE_NAME AS "table_name",
|
|
128
|
+
COLUMN_NAME AS "column_name",
|
|
129
|
+
DATA_TYPE AS "data_type",
|
|
130
|
+
NULLABLE AS "is_nullable"
|
|
131
|
+
FROM ALL_TAB_COLS
|
|
132
|
+
WHERE
|
|
133
|
+
OWNER = UPPER('${schemaName}')`;
|
|
134
|
+
const rep = await appDataSource.query(sql);
|
|
135
|
+
return formatToSqlTable(rep);
|
|
136
|
+
}
|
|
123
137
|
throw new Error("Database type not implemented yet");
|
|
124
138
|
};
|
|
125
139
|
const formatSqlResponseToSimpleTableString = (rawResult) => {
|
|
@@ -154,6 +168,9 @@ export const generateTableInfoFromTables = async (tables, appDataSource, nbSampl
|
|
|
154
168
|
appDataSource.options?.username ??
|
|
155
169
|
"public";
|
|
156
170
|
}
|
|
171
|
+
else if (appDataSource.options.type === "oracle") {
|
|
172
|
+
schema = appDataSource.options.schema;
|
|
173
|
+
}
|
|
157
174
|
let sqlCreateTableQuery = schema
|
|
158
175
|
? `CREATE TABLE "${schema}"."${currentTable.tableName}" (\n`
|
|
159
176
|
: `CREATE TABLE ${currentTable.tableName} (\n`;
|
|
@@ -182,6 +199,9 @@ export const generateTableInfoFromTables = async (tables, appDataSource, nbSampl
|
|
|
182
199
|
"public";
|
|
183
200
|
sqlSelectInfoQuery = `SELECT * FROM "${schema}"."${currentTable.tableName}" LIMIT ${nbSampleRow};\n`;
|
|
184
201
|
}
|
|
202
|
+
else if (appDataSource.options.type === "oracle") {
|
|
203
|
+
sqlSelectInfoQuery = `SELECT * FROM "${schema}"."${currentTable.tableName}" WHERE ROWNUM <= '${nbSampleRow}'`;
|
|
204
|
+
}
|
|
185
205
|
else {
|
|
186
206
|
sqlSelectInfoQuery = `SELECT * FROM "${currentTable.tableName}" LIMIT ${nbSampleRow};\n`;
|
|
187
207
|
}
|
|
@@ -221,5 +241,8 @@ export const getPromptTemplateFromDataSource = (appDataSource) => {
|
|
|
221
241
|
if (appDataSource.options.type === "sap") {
|
|
222
242
|
return SQL_SAP_HANA_PROMPT;
|
|
223
243
|
}
|
|
244
|
+
if (appDataSource.options.type === "oracle") {
|
|
245
|
+
return SQL_ORACLE_PROMPT;
|
|
246
|
+
}
|
|
224
247
|
return DEFAULT_SQL_DATABASE_PROMPT;
|
|
225
248
|
};
|
|
@@ -17,5 +17,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
const entrypoint_deprecation_js_1 = require("../util/entrypoint_deprecation.cjs");
|
|
18
18
|
/* #__PURE__ */ (0, entrypoint_deprecation_js_1.logVersion010MigrationWarning)({
|
|
19
19
|
oldEntrypointName: "vectorstores/cloudflare_vectorize",
|
|
20
|
+
newEntrypointName: "",
|
|
21
|
+
newPackageName: "@langchain/cloudflare",
|
|
20
22
|
});
|
|
21
23
|
__exportStar(require("@langchain/community/vectorstores/cloudflare_vectorize"), exports);
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { logVersion010MigrationWarning } from "../util/entrypoint_deprecation.js";
|
|
2
2
|
/* #__PURE__ */ logVersion010MigrationWarning({
|
|
3
3
|
oldEntrypointName: "vectorstores/cloudflare_vectorize",
|
|
4
|
+
newEntrypointName: "",
|
|
5
|
+
newPackageName: "@langchain/cloudflare",
|
|
4
6
|
});
|
|
5
7
|
export * from "@langchain/community/vectorstores/cloudflare_vectorize";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "langchain",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Typescript bindings for langchain",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -1202,9 +1202,9 @@
|
|
|
1202
1202
|
},
|
|
1203
1203
|
"dependencies": {
|
|
1204
1204
|
"@anthropic-ai/sdk": "^0.9.1",
|
|
1205
|
-
"@langchain/community": "~0.0.
|
|
1206
|
-
"@langchain/core": "~0.1.
|
|
1207
|
-
"@langchain/openai": "~0.0.
|
|
1205
|
+
"@langchain/community": "~0.0.17",
|
|
1206
|
+
"@langchain/core": "~0.1.13",
|
|
1207
|
+
"@langchain/openai": "~0.0.12",
|
|
1208
1208
|
"binary-extensions": "^2.2.0",
|
|
1209
1209
|
"expr-eval": "^2.0.2",
|
|
1210
1210
|
"js-tiktoken": "^1.0.7",
|