langchain 0.3.29 → 0.3.31
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/README.md +15 -12
- package/dist/agents/agent.cjs +1 -1
- package/dist/agents/agent.d.ts +1 -1
- package/dist/agents/agent.js +1 -1
- package/dist/agents/mrkl/index.cjs +1 -1
- package/dist/agents/mrkl/index.d.ts +1 -1
- package/dist/agents/mrkl/index.js +1 -1
- package/dist/agents/openai_functions/index.cjs +1 -0
- package/dist/agents/openai_functions/index.d.ts +1 -0
- package/dist/agents/openai_functions/index.js +1 -0
- 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 +1 -1
- package/dist/agents/openai_tools/index.d.ts +1 -1
- package/dist/agents/openai_tools/index.js +1 -1
- package/dist/agents/openai_tools/output_parser.cjs +19 -14
- package/dist/agents/openai_tools/output_parser.d.ts +1 -1
- package/dist/agents/openai_tools/output_parser.js +19 -14
- package/dist/agents/structured_chat/index.cjs +1 -1
- package/dist/agents/structured_chat/index.d.ts +1 -1
- package/dist/agents/structured_chat/index.js +1 -1
- package/dist/agents/structured_chat/outputParser.cjs +1 -1
- package/dist/agents/structured_chat/outputParser.d.ts +1 -1
- package/dist/agents/structured_chat/outputParser.js +1 -1
- package/dist/agents/tool_calling/output_parser.cjs +1 -1
- package/dist/agents/tool_calling/output_parser.js +1 -1
- package/dist/agents/toolkits/openapi/openapi.cjs +1 -1
- package/dist/agents/toolkits/openapi/openapi.d.ts +1 -1
- package/dist/agents/toolkits/openapi/openapi.js +1 -1
- package/dist/agents/toolkits/sql/sql.cjs +1 -1
- package/dist/agents/toolkits/sql/sql.d.ts +1 -1
- package/dist/agents/toolkits/sql/sql.js +1 -1
- package/dist/agents/toolkits/vectorstore/vectorstore.cjs +1 -1
- package/dist/agents/toolkits/vectorstore/vectorstore.d.ts +1 -1
- package/dist/agents/toolkits/vectorstore/vectorstore.js +1 -1
- package/dist/chains/analyze_documents_chain.cjs +1 -1
- package/dist/chains/analyze_documents_chain.d.ts +1 -1
- package/dist/chains/analyze_documents_chain.js +1 -1
- package/dist/chains/constitutional_ai/constitutional_principle.cjs +2 -2
- package/dist/chains/constitutional_ai/constitutional_principle.d.ts +2 -2
- package/dist/chains/constitutional_ai/constitutional_principle.js +2 -2
- package/dist/chains/conversation.cjs +1 -1
- package/dist/chains/conversation.d.ts +1 -1
- package/dist/chains/conversation.js +1 -1
- package/dist/chains/graph_qa/cypher.cjs +1 -1
- package/dist/chains/graph_qa/cypher.d.ts +1 -1
- package/dist/chains/graph_qa/cypher.js +1 -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/llm_chain.cjs +1 -1
- package/dist/chains/llm_chain.d.ts +1 -1
- package/dist/chains/llm_chain.js +1 -1
- package/dist/chains/openai_functions/base.cjs +1 -1
- package/dist/chains/openai_functions/base.d.ts +1 -1
- package/dist/chains/openai_functions/base.js +1 -1
- package/dist/chains/openai_functions/structured_output.cjs +1 -1
- package/dist/chains/openai_functions/structured_output.js +1 -1
- package/dist/chains/retrieval.cjs +1 -1
- package/dist/chains/retrieval.d.ts +1 -1
- package/dist/chains/retrieval.js +1 -1
- package/dist/chains/router/multi_prompt.cjs +16 -13
- package/dist/chains/router/multi_prompt.d.ts +16 -13
- package/dist/chains/router/multi_prompt.js +16 -13
- package/dist/chains/router/multi_retrieval_qa.cjs +1 -1
- package/dist/chains/router/multi_retrieval_qa.d.ts +1 -1
- package/dist/chains/router/multi_retrieval_qa.js +1 -1
- package/dist/chains/sequential_chain.cjs +2 -2
- package/dist/chains/sequential_chain.d.ts +2 -2
- package/dist/chains/sequential_chain.js +2 -2
- package/dist/chains/sql_db/sql_db_chain.cjs +1 -1
- package/dist/chains/sql_db/sql_db_chain.d.ts +1 -1
- package/dist/chains/sql_db/sql_db_chain.js +1 -1
- package/dist/chat_models/universal.cjs +1 -1
- package/dist/chat_models/universal.js +1 -1
- package/dist/document_transformers/openai_functions.cjs +1 -1
- package/dist/document_transformers/openai_functions.js +1 -1
- package/dist/evaluation/loader.cjs +1 -1
- package/dist/evaluation/loader.js +1 -1
- package/dist/experimental/autogpt/agent.cjs +1 -1
- package/dist/experimental/autogpt/agent.d.ts +1 -1
- package/dist/experimental/autogpt/agent.js +1 -1
- package/dist/experimental/generative_agents/generative_agent.cjs +1 -1
- package/dist/experimental/generative_agents/generative_agent.d.ts +1 -1
- package/dist/experimental/generative_agents/generative_agent.js +1 -1
- package/dist/hub/base.cjs +19 -0
- package/dist/hub/base.d.ts +1 -0
- package/dist/hub/base.js +18 -0
- package/dist/hub/index.cjs +1 -1
- package/dist/hub/index.js +2 -2
- package/dist/hub/node.cjs +1 -1
- package/dist/hub/node.js +2 -2
- package/dist/memory/buffer_memory.cjs +1 -1
- package/dist/memory/buffer_memory.d.ts +1 -1
- package/dist/memory/buffer_memory.js +1 -1
- package/dist/memory/buffer_token_memory.cjs +1 -1
- package/dist/memory/buffer_token_memory.d.ts +1 -1
- package/dist/memory/buffer_token_memory.js +1 -1
- package/dist/memory/buffer_window_memory.cjs +1 -1
- package/dist/memory/buffer_window_memory.d.ts +1 -1
- package/dist/memory/buffer_window_memory.js +1 -1
- package/dist/memory/entity_memory.cjs +2 -2
- package/dist/memory/entity_memory.d.ts +2 -2
- package/dist/memory/entity_memory.js +2 -2
- package/dist/memory/summary.cjs +2 -2
- package/dist/memory/summary.d.ts +2 -2
- package/dist/memory/summary.js +2 -2
- package/dist/memory/summary_buffer.cjs +2 -2
- package/dist/memory/summary_buffer.d.ts +2 -2
- package/dist/memory/summary_buffer.js +2 -2
- package/dist/retrievers/hyde.cjs +1 -1
- package/dist/retrievers/hyde.d.ts +1 -1
- package/dist/retrievers/hyde.js +1 -1
- package/dist/retrievers/self_query/index.cjs +1 -1
- package/dist/retrievers/self_query/index.d.ts +1 -1
- package/dist/retrievers/self_query/index.js +1 -1
- package/dist/smith/runner_utils.cjs +2 -1
- package/dist/smith/runner_utils.js +2 -1
- package/dist/tools/webbrowser.cjs +1 -1
- package/dist/tools/webbrowser.d.ts +1 -1
- package/dist/tools/webbrowser.js +1 -1
- package/dist/util/sql_utils.cjs +1 -0
- package/dist/util/sql_utils.js +1 -0
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ You can use npm, yarn, or pnpm to install LangChain.js
|
|
|
20
20
|
|
|
21
21
|
LangChain is written in TypeScript and can be used in:
|
|
22
22
|
|
|
23
|
-
- Node.js (ESM and CommonJS) - 18.x, 19.x, 20.x
|
|
23
|
+
- Node.js (ESM and CommonJS) - 18.x, 19.x, 20.x, 22.x
|
|
24
24
|
- Cloudflare Workers
|
|
25
25
|
- Vercel / Next.js (Browser, Serverless and Edge functions)
|
|
26
26
|
- Supabase Edge Functions
|
|
@@ -30,20 +30,23 @@ LangChain is written in TypeScript and can be used in:
|
|
|
30
30
|
## 🤔 What is LangChain?
|
|
31
31
|
|
|
32
32
|
**LangChain** is a framework for developing applications powered by language models. It enables applications that:
|
|
33
|
+
|
|
33
34
|
- **Are context-aware**: connect a language model to sources of context (prompt instructions, few shot examples, content to ground its response in, etc.)
|
|
34
35
|
- **Reason**: rely on a language model to reason (about how to answer based on provided context, what actions to take, etc.)
|
|
35
36
|
|
|
36
37
|
This framework consists of several parts.
|
|
38
|
+
|
|
37
39
|
- **Open-source libraries**: Build your applications using LangChain's open-source [building blocks](https://js.langchain.com/docs/concepts/lcel), [components](https://js.langchain.com/docs/concepts), and [third-party integrations](https://js.langchain.com/docs/integrations/platforms/).
|
|
38
|
-
Use [LangGraph.js](https://js.langchain.com/docs/concepts/#langgraphjs) to build stateful agents with first-class streaming and human-in-the-loop support.
|
|
40
|
+
Use [LangGraph.js](https://js.langchain.com/docs/concepts/#langgraphjs) to build stateful agents with first-class streaming and human-in-the-loop support.
|
|
39
41
|
- **Productionization**: Use [LangSmith](https://docs.smith.langchain.com/) to inspect, monitor and evaluate your chains, so that you can continuously optimize and deploy with confidence.
|
|
40
42
|
- **Deployment**: Turn your LangGraph applications into production-ready APIs and Assistants with [LangGraph Cloud](https://langchain-ai.github.io/langgraph/cloud/).
|
|
41
43
|
|
|
42
44
|
The LangChain libraries themselves are made up of several different packages.
|
|
45
|
+
|
|
43
46
|
- **[`@langchain/core`](https://github.com/langchain-ai/langchainjs/blob/main/langchain-core)**: Base abstractions and LangChain Expression Language.
|
|
44
47
|
- **[`@langchain/community`](https://github.com/langchain-ai/langchainjs/blob/main/libs/langchain-community)**: Third party integrations.
|
|
45
48
|
- **[`langchain`](https://github.com/langchain-ai/langchainjs/blob/main/langchain)**: Chains, agents, and retrieval strategies that make up an application's cognitive architecture.
|
|
46
|
-
- **[LangGraph.js](https://langchain-ai.github.io/langgraphjs/)**:
|
|
49
|
+
- **[LangGraph.js](https://langchain-ai.github.io/langgraphjs/)**: LangGraph powers production-grade agents, trusted by Linkedin, Uber, Klarna, GitLab, and many more. Build robust and stateful multi-actor applications with LLMs by modeling steps as edges and nodes in a graph. Integrates smoothly with LangChain, but can be used without it.
|
|
47
50
|
|
|
48
51
|
Integrations may also be split into their own compatible packages.
|
|
49
52
|
|
|
@@ -53,22 +56,22 @@ This library aims to assist in the development of those types of applications. C
|
|
|
53
56
|
|
|
54
57
|
**❓Question Answering over specific documents**
|
|
55
58
|
|
|
56
|
-
- [Documentation](https://js.langchain.com/docs/tutorials/rag)
|
|
59
|
+
- [Documentation](https://js.langchain.com/docs/tutorials/rag/)
|
|
57
60
|
- End-to-end Example: [Doc-Chatbot](https://github.com/dissorial/doc-chatbot)
|
|
58
61
|
|
|
59
|
-
|
|
60
62
|
**💬 Chatbots**
|
|
61
63
|
|
|
62
|
-
- [Documentation](https://js.langchain.com/docs/
|
|
63
|
-
- End-to-end Example: [Chat-LangChain](https://github.com/langchain-ai/chat-
|
|
64
|
+
- [Documentation](https://js.langchain.com/docs/tutorials/chatbot)
|
|
65
|
+
- End-to-end Example: [Chat-LangChain](https://github.com/langchain-ai/chat-langchain)
|
|
64
66
|
|
|
65
67
|
## 🚀 How does LangChain help?
|
|
66
68
|
|
|
67
69
|
The main value props of the LangChain libraries are:
|
|
70
|
+
|
|
68
71
|
1. **Components**: composable tools and integrations for working with language models. Components are modular and easy-to-use, whether you are using the rest of the LangChain framework or not
|
|
69
72
|
2. **Off-the-shelf chains**: built-in assemblages of components for accomplishing higher-level tasks
|
|
70
73
|
|
|
71
|
-
Off-the-shelf chains make it easy to get started. Components make it easy to customize existing chains and build new ones.
|
|
74
|
+
Off-the-shelf chains make it easy to get started. Components make it easy to customize existing chains and build new ones.
|
|
72
75
|
|
|
73
76
|
Components fall into the following **modules**:
|
|
74
77
|
|
|
@@ -84,14 +87,14 @@ Data Augmented Generation involves specific types of chains that first interact
|
|
|
84
87
|
|
|
85
88
|
Agents allow an LLM autonomy over how a task is accomplished. Agents make decisions about which Actions to take, then take that Action, observe the result, and repeat until the task is complete. LangChain provides a [standard interface for agents](https://js.langchain.com/docs/concepts/#agents), along with [LangGraph.js](https://github.com/langchain-ai/langgraphjs/) for building custom agents.
|
|
86
89
|
|
|
87
|
-
## 📖
|
|
88
|
-
|
|
89
|
-
Please see [here](https://js.langchain.com) for full documentation, which includes:
|
|
90
|
+
## 📖 Additional Resources
|
|
90
91
|
|
|
91
92
|
- [Getting started](https://js.langchain.com/docs/introduction): installation, setting up the environment, simple examples
|
|
92
93
|
- Overview of the [interfaces](https://js.langchain.com/docs/how_to/lcel_cheatsheet/), [modules](https://js.langchain.com/docs/concepts) and [integrations](https://js.langchain.com/docs/integrations/platforms/)
|
|
94
|
+
- [Full Documentation](https://js.langchain.com)
|
|
93
95
|
- [Tutorial](https://js.langchain.com/docs/tutorials/) walkthroughs
|
|
94
|
-
- [
|
|
96
|
+
- [Langhain Forum](https://forum.langchain.com)
|
|
97
|
+
- [API Reference](https://api.js.langchain.com)
|
|
95
98
|
|
|
96
99
|
## 💁 Contributing
|
|
97
100
|
|
package/dist/agents/agent.cjs
CHANGED
|
@@ -340,7 +340,7 @@ exports.RunnableAgent = RunnableAgent;
|
|
|
340
340
|
* const agent = new LLMSingleActionAgent({
|
|
341
341
|
* llmChain: new LLMChain({
|
|
342
342
|
* prompt: customPromptTemplate,
|
|
343
|
-
* llm: new ChatOpenAI({ temperature: 0 }),
|
|
343
|
+
* llm: new ChatOpenAI({ model: "gpt-4o-mini", temperature: 0 }),
|
|
344
344
|
* }),
|
|
345
345
|
* outputParser: customOutputParser,
|
|
346
346
|
* stop: ["\nObservation"],
|
package/dist/agents/agent.d.ts
CHANGED
|
@@ -159,7 +159,7 @@ export interface LLMSingleActionAgentInput {
|
|
|
159
159
|
* const agent = new LLMSingleActionAgent({
|
|
160
160
|
* llmChain: new LLMChain({
|
|
161
161
|
* prompt: customPromptTemplate,
|
|
162
|
-
* llm: new ChatOpenAI({ temperature: 0 }),
|
|
162
|
+
* llm: new ChatOpenAI({ model: "gpt-4o-mini", temperature: 0 }),
|
|
163
163
|
* }),
|
|
164
164
|
* outputParser: customOutputParser,
|
|
165
165
|
* stop: ["\nObservation"],
|
package/dist/agents/agent.js
CHANGED
|
@@ -296,7 +296,7 @@ export class RunnableAgent extends RunnableMultiActionAgent {
|
|
|
296
296
|
* const agent = new LLMSingleActionAgent({
|
|
297
297
|
* llmChain: new LLMChain({
|
|
298
298
|
* prompt: customPromptTemplate,
|
|
299
|
-
* llm: new ChatOpenAI({ temperature: 0 }),
|
|
299
|
+
* llm: new ChatOpenAI({ model: "gpt-4o-mini", temperature: 0 }),
|
|
300
300
|
* }),
|
|
301
301
|
* outputParser: customOutputParser,
|
|
302
302
|
* stop: ["\nObservation"],
|
|
@@ -15,7 +15,7 @@ const prompt_js_1 = require("./prompt.cjs");
|
|
|
15
15
|
*
|
|
16
16
|
* const agent = new ZeroShotAgent({
|
|
17
17
|
* llmChain: new LLMChain({
|
|
18
|
-
* llm: new ChatOpenAI({ temperature: 0 }),
|
|
18
|
+
* llm: new ChatOpenAI({ model: "gpt-4o-mini", temperature: 0 }),
|
|
19
19
|
* prompt: ZeroShotAgent.createPrompt([new SerpAPI(), new Calculator()], {
|
|
20
20
|
* prefix: `Answer the following questions as best you can, but speaking as a pirate might speak. You have access to the following tools:`,
|
|
21
21
|
* suffix: `Begin! Remember to speak as a pirate when giving your final answer. Use lots of "Args"
|
|
@@ -29,7 +29,7 @@ export type ZeroShotAgentInput = Optional<AgentInput, "outputParser">;
|
|
|
29
29
|
*
|
|
30
30
|
* const agent = new ZeroShotAgent({
|
|
31
31
|
* llmChain: new LLMChain({
|
|
32
|
-
* llm: new ChatOpenAI({ temperature: 0 }),
|
|
32
|
+
* llm: new ChatOpenAI({ model: "gpt-4o-mini", temperature: 0 }),
|
|
33
33
|
* prompt: ZeroShotAgent.createPrompt([new SerpAPI(), new Calculator()], {
|
|
34
34
|
* prefix: `Answer the following questions as best you can, but speaking as a pirate might speak. You have access to the following tools:`,
|
|
35
35
|
* suffix: `Begin! Remember to speak as a pirate when giving your final answer. Use lots of "Args"
|
|
@@ -12,7 +12,7 @@ import { FORMAT_INSTRUCTIONS, PREFIX, SUFFIX } from "./prompt.js";
|
|
|
12
12
|
*
|
|
13
13
|
* const agent = new ZeroShotAgent({
|
|
14
14
|
* llmChain: new LLMChain({
|
|
15
|
-
* llm: new ChatOpenAI({ temperature: 0 }),
|
|
15
|
+
* llm: new ChatOpenAI({ model: "gpt-4o-mini", temperature: 0 }),
|
|
16
16
|
* prompt: ZeroShotAgent.createPrompt([new SerpAPI(), new Calculator()], {
|
|
17
17
|
* prefix: `Answer the following questions as best you can, but speaking as a pirate might speak. You have access to the following tools:`,
|
|
18
18
|
* suffix: `Begin! Remember to speak as a pirate when giving your final answer. Use lots of "Args"
|
|
@@ -21,7 +21,7 @@ const types_js_1 = require("../types.cjs");
|
|
|
21
21
|
* },
|
|
22
22
|
* prompt,
|
|
23
23
|
* new ChatOpenAI({
|
|
24
|
-
*
|
|
24
|
+
* model: "gpt-3.5-turbo-1106",
|
|
25
25
|
* temperature: 0,
|
|
26
26
|
* }).bindTools(tools),
|
|
27
27
|
* new OpenAIToolsAgentOutputParser(),
|
|
@@ -68,19 +68,24 @@ class OpenAIToolsAgentOutputParser extends types_js_1.AgentMultiActionOutputPars
|
|
|
68
68
|
if (message.additional_kwargs.tool_calls) {
|
|
69
69
|
const toolCalls = message.additional_kwargs.tool_calls;
|
|
70
70
|
try {
|
|
71
|
-
return toolCalls
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
71
|
+
return toolCalls
|
|
72
|
+
.map((toolCall, i) => {
|
|
73
|
+
if (toolCall.type === "function") {
|
|
74
|
+
const toolInput = toolCall.function.arguments
|
|
75
|
+
? JSON.parse(toolCall.function.arguments)
|
|
76
|
+
: {};
|
|
77
|
+
const messageLog = i === 0 ? [message] : [];
|
|
78
|
+
return {
|
|
79
|
+
tool: toolCall.function.name,
|
|
80
|
+
toolInput,
|
|
81
|
+
toolCallId: toolCall.id,
|
|
82
|
+
log: `Invoking "${toolCall.function.name}" with ${toolCall.function.arguments ?? "{}"}\n${message.content}`,
|
|
83
|
+
messageLog,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
return undefined;
|
|
87
|
+
})
|
|
88
|
+
.filter(Boolean);
|
|
84
89
|
}
|
|
85
90
|
catch (error) {
|
|
86
91
|
throw new output_parsers_1.OutputParserException(`Failed to parse tool arguments from chat model response. Text: "${JSON.stringify(toolCalls)}". ${error}`);
|
|
@@ -18,7 +18,7 @@ import { AgentMultiActionOutputParser } from "../types.js";
|
|
|
18
18
|
* },
|
|
19
19
|
* prompt,
|
|
20
20
|
* new ChatOpenAI({
|
|
21
|
-
*
|
|
21
|
+
* model: "gpt-3.5-turbo-1106",
|
|
22
22
|
* temperature: 0,
|
|
23
23
|
* }).bindTools(tools),
|
|
24
24
|
* new OpenAIToolsAgentOutputParser(),
|
|
@@ -65,19 +65,24 @@ export class OpenAIToolsAgentOutputParser extends AgentMultiActionOutputParser {
|
|
|
65
65
|
if (message.additional_kwargs.tool_calls) {
|
|
66
66
|
const toolCalls = message.additional_kwargs.tool_calls;
|
|
67
67
|
try {
|
|
68
|
-
return toolCalls
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
68
|
+
return toolCalls
|
|
69
|
+
.map((toolCall, i) => {
|
|
70
|
+
if (toolCall.type === "function") {
|
|
71
|
+
const toolInput = toolCall.function.arguments
|
|
72
|
+
? JSON.parse(toolCall.function.arguments)
|
|
73
|
+
: {};
|
|
74
|
+
const messageLog = i === 0 ? [message] : [];
|
|
75
|
+
return {
|
|
76
|
+
tool: toolCall.function.name,
|
|
77
|
+
toolInput,
|
|
78
|
+
toolCallId: toolCall.id,
|
|
79
|
+
log: `Invoking "${toolCall.function.name}" with ${toolCall.function.arguments ?? "{}"}\n${message.content}`,
|
|
80
|
+
messageLog,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
return undefined;
|
|
84
|
+
})
|
|
85
|
+
.filter(Boolean);
|
|
81
86
|
}
|
|
82
87
|
catch (error) {
|
|
83
88
|
throw new OutputParserException(`Failed to parse tool arguments from chat model response. Text: "${JSON.stringify(toolCalls)}". ${error}`);
|
|
@@ -191,7 +191,7 @@ exports.StructuredChatAgent = StructuredChatAgent;
|
|
|
191
191
|
*
|
|
192
192
|
* const llm = new ChatOpenAI({
|
|
193
193
|
* temperature: 0,
|
|
194
|
-
*
|
|
194
|
+
* model: "gpt-3.5-turbo-1106",
|
|
195
195
|
* });
|
|
196
196
|
*
|
|
197
197
|
* const agent = await createStructuredChatAgent({
|
|
@@ -139,7 +139,7 @@ export type CreateStructuredChatAgentParams = {
|
|
|
139
139
|
*
|
|
140
140
|
* const llm = new ChatOpenAI({
|
|
141
141
|
* temperature: 0,
|
|
142
|
-
*
|
|
142
|
+
* model: "gpt-3.5-turbo-1106",
|
|
143
143
|
* });
|
|
144
144
|
*
|
|
145
145
|
* const agent = await createStructuredChatAgent({
|
|
@@ -186,7 +186,7 @@ export class StructuredChatAgent extends Agent {
|
|
|
186
186
|
*
|
|
187
187
|
* const llm = new ChatOpenAI({
|
|
188
188
|
* temperature: 0,
|
|
189
|
-
*
|
|
189
|
+
* model: "gpt-3.5-turbo-1106",
|
|
190
190
|
* });
|
|
191
191
|
*
|
|
192
192
|
* const agent = await createStructuredChatAgent({
|
|
@@ -75,7 +75,7 @@ exports.StructuredChatOutputParser = StructuredChatOutputParser;
|
|
|
75
75
|
* @example
|
|
76
76
|
* ```typescript
|
|
77
77
|
* const outputParser = new StructuredChatOutputParserWithRetries.fromLLM(
|
|
78
|
-
* new ChatOpenAI({ temperature: 0 }),
|
|
78
|
+
* new ChatOpenAI({ model: "gpt-4o-mini", temperature: 0 }),
|
|
79
79
|
* {
|
|
80
80
|
* toolNames: ["calculator", "random-number-generator"],
|
|
81
81
|
* },
|
|
@@ -48,7 +48,7 @@ export interface StructuredChatOutputParserArgs {
|
|
|
48
48
|
* @example
|
|
49
49
|
* ```typescript
|
|
50
50
|
* const outputParser = new StructuredChatOutputParserWithRetries.fromLLM(
|
|
51
|
-
* new ChatOpenAI({ temperature: 0 }),
|
|
51
|
+
* new ChatOpenAI({ model: "gpt-4o-mini", temperature: 0 }),
|
|
52
52
|
* {
|
|
53
53
|
* toolNames: ["calculator", "random-number-generator"],
|
|
54
54
|
* },
|
|
@@ -71,7 +71,7 @@ export class StructuredChatOutputParser extends AgentActionOutputParser {
|
|
|
71
71
|
* @example
|
|
72
72
|
* ```typescript
|
|
73
73
|
* const outputParser = new StructuredChatOutputParserWithRetries.fromLLM(
|
|
74
|
-
* new ChatOpenAI({ temperature: 0 }),
|
|
74
|
+
* new ChatOpenAI({ model: "gpt-4o-mini", temperature: 0 }),
|
|
75
75
|
* {
|
|
76
76
|
* toolNames: ["calculator", "random-number-generator"],
|
|
77
77
|
* },
|
|
@@ -14,7 +14,7 @@ function parseAIMessageToToolAction(message) {
|
|
|
14
14
|
toolCalls = message.tool_calls;
|
|
15
15
|
}
|
|
16
16
|
else {
|
|
17
|
-
if (message.additional_kwargs.tool_calls
|
|
17
|
+
if (!message.additional_kwargs.tool_calls ||
|
|
18
18
|
message.additional_kwargs.tool_calls.length === 0) {
|
|
19
19
|
return {
|
|
20
20
|
returnValues: { output: message.content },
|
|
@@ -10,7 +10,7 @@ export function parseAIMessageToToolAction(message) {
|
|
|
10
10
|
toolCalls = message.tool_calls;
|
|
11
11
|
}
|
|
12
12
|
else {
|
|
13
|
-
if (message.additional_kwargs.tool_calls
|
|
13
|
+
if (!message.additional_kwargs.tool_calls ||
|
|
14
14
|
message.additional_kwargs.tool_calls.length === 0) {
|
|
15
15
|
return {
|
|
16
16
|
returnValues: { output: message.content },
|
|
@@ -36,7 +36,7 @@ exports.RequestsToolkit = RequestsToolkit;
|
|
|
36
36
|
* const toolkit = new OpenApiToolkit(
|
|
37
37
|
* new JsonSpec({
|
|
38
38
|
* }),
|
|
39
|
-
* new ChatOpenAI({ temperature: 0 }),
|
|
39
|
+
* new ChatOpenAI({ model: "gpt-4o-mini", temperature: 0 }),
|
|
40
40
|
* {
|
|
41
41
|
* "Content-Type": "application/json",
|
|
42
42
|
* Authorization: `Bearer ${process.env.OPENAI_API_KEY}`,
|
|
@@ -23,7 +23,7 @@ export declare class RequestsToolkit extends BaseToolkit {
|
|
|
23
23
|
* const toolkit = new OpenApiToolkit(
|
|
24
24
|
* new JsonSpec({
|
|
25
25
|
* }),
|
|
26
|
-
* new ChatOpenAI({ temperature: 0 }),
|
|
26
|
+
* new ChatOpenAI({ model: "gpt-4o-mini", temperature: 0 }),
|
|
27
27
|
* {
|
|
28
28
|
* "Content-Type": "application/json",
|
|
29
29
|
* Authorization: `Bearer ${process.env.OPENAI_API_KEY}`,
|
|
@@ -31,7 +31,7 @@ export class RequestsToolkit extends BaseToolkit {
|
|
|
31
31
|
* const toolkit = new OpenApiToolkit(
|
|
32
32
|
* new JsonSpec({
|
|
33
33
|
* }),
|
|
34
|
-
* new ChatOpenAI({ temperature: 0 }),
|
|
34
|
+
* new ChatOpenAI({ model: "gpt-4o-mini", temperature: 0 }),
|
|
35
35
|
* {
|
|
36
36
|
* "Content-Type": "application/json",
|
|
37
37
|
* Authorization: `Bearer ${process.env.OPENAI_API_KEY}`,
|
|
@@ -14,7 +14,7 @@ const executor_js_1 = require("../../executor.cjs");
|
|
|
14
14
|
* initializes SQL tools based on the provided SQL database.
|
|
15
15
|
* @example
|
|
16
16
|
* ```typescript
|
|
17
|
-
* const model = new ChatOpenAI({});
|
|
17
|
+
* const model = new ChatOpenAI({ model: "gpt-4o-mini" });
|
|
18
18
|
* const toolkit = new SqlToolkit(sqlDb, model);
|
|
19
19
|
* const executor = createSqlAgent(model, toolkit);
|
|
20
20
|
* const result = await executor.invoke({ input: 'List the total sales per country. Which country's customers spent the most?' });
|
|
@@ -16,7 +16,7 @@ export interface SqlCreatePromptArgs extends ZeroShotCreatePromptArgs {
|
|
|
16
16
|
* initializes SQL tools based on the provided SQL database.
|
|
17
17
|
* @example
|
|
18
18
|
* ```typescript
|
|
19
|
-
* const model = new ChatOpenAI({});
|
|
19
|
+
* const model = new ChatOpenAI({ model: "gpt-4o-mini" });
|
|
20
20
|
* const toolkit = new SqlToolkit(sqlDb, model);
|
|
21
21
|
* const executor = createSqlAgent(model, toolkit);
|
|
22
22
|
* const result = await executor.invoke({ input: 'List the total sales per country. Which country's customers spent the most?' });
|
|
@@ -10,7 +10,7 @@ import { AgentExecutor } from "../../executor.js";
|
|
|
10
10
|
* initializes SQL tools based on the provided SQL database.
|
|
11
11
|
* @example
|
|
12
12
|
* ```typescript
|
|
13
|
-
* const model = new ChatOpenAI({});
|
|
13
|
+
* const model = new ChatOpenAI({ model: "gpt-4o-mini" });
|
|
14
14
|
* const toolkit = new SqlToolkit(sqlDb, model);
|
|
15
15
|
* const executor = createSqlAgent(model, toolkit);
|
|
16
16
|
* const result = await executor.invoke({ input: 'List the total sales per country. Which country's customers spent the most?' });
|
|
@@ -22,7 +22,7 @@ const executor_js_1 = require("../../executor.cjs");
|
|
|
22
22
|
* description: "the most recent state of the Union address",
|
|
23
23
|
* vectorStore: new HNSWLib(),
|
|
24
24
|
* },
|
|
25
|
-
* new ChatOpenAI({ temperature: 0 }),
|
|
25
|
+
* new ChatOpenAI({ model: "gpt-4o-mini", temperature: 0 }),
|
|
26
26
|
* );
|
|
27
27
|
* const result = await toolkit.invoke({
|
|
28
28
|
* input:
|
|
@@ -24,7 +24,7 @@ export interface VectorStoreInfo {
|
|
|
24
24
|
* description: "the most recent state of the Union address",
|
|
25
25
|
* vectorStore: new HNSWLib(),
|
|
26
26
|
* },
|
|
27
|
-
* new ChatOpenAI({ temperature: 0 }),
|
|
27
|
+
* new ChatOpenAI({ model: "gpt-4o-mini", temperature: 0 }),
|
|
28
28
|
* );
|
|
29
29
|
* const result = await toolkit.invoke({
|
|
30
30
|
* input:
|
|
@@ -17,7 +17,7 @@ import { AgentExecutor } from "../../executor.js";
|
|
|
17
17
|
* description: "the most recent state of the Union address",
|
|
18
18
|
* vectorStore: new HNSWLib(),
|
|
19
19
|
* },
|
|
20
|
-
* new ChatOpenAI({ temperature: 0 }),
|
|
20
|
+
* new ChatOpenAI({ model: "gpt-4o-mini", temperature: 0 }),
|
|
21
21
|
* );
|
|
22
22
|
* const result = await toolkit.invoke({
|
|
23
23
|
* input:
|
|
@@ -9,7 +9,7 @@ const text_splitter_js_1 = require("../text_splitter.cjs");
|
|
|
9
9
|
* @augments StuffDocumentsChainInput
|
|
10
10
|
* @example
|
|
11
11
|
* ```typescript
|
|
12
|
-
* const model = new ChatOpenAI({ temperature: 0 });
|
|
12
|
+
* const model = new ChatOpenAI({ model: "gpt-4o-mini", temperature: 0 });
|
|
13
13
|
* const combineDocsChain = loadSummarizationChain(model);
|
|
14
14
|
* const chain = new AnalyzeDocumentChain({
|
|
15
15
|
* combineDocumentsChain: combineDocsChain,
|
|
@@ -19,7 +19,7 @@ export interface AnalyzeDocumentChainInput extends Omit<ChainInputs, "memory"> {
|
|
|
19
19
|
* @augments StuffDocumentsChainInput
|
|
20
20
|
* @example
|
|
21
21
|
* ```typescript
|
|
22
|
-
* const model = new ChatOpenAI({ temperature: 0 });
|
|
22
|
+
* const model = new ChatOpenAI({ model: "gpt-4o-mini", temperature: 0 });
|
|
23
23
|
* const combineDocsChain = loadSummarizationChain(model);
|
|
24
24
|
* const chain = new AnalyzeDocumentChain({
|
|
25
25
|
* combineDocumentsChain: combineDocsChain,
|
|
@@ -6,7 +6,7 @@ import { RecursiveCharacterTextSplitter, } from "../text_splitter.js";
|
|
|
6
6
|
* @augments StuffDocumentsChainInput
|
|
7
7
|
* @example
|
|
8
8
|
* ```typescript
|
|
9
|
-
* const model = new ChatOpenAI({ temperature: 0 });
|
|
9
|
+
* const model = new ChatOpenAI({ model: "gpt-4o-mini", temperature: 0 });
|
|
10
10
|
* const combineDocsChain = loadSummarizationChain(model);
|
|
11
11
|
* const chain = new AnalyzeDocumentChain({
|
|
12
12
|
* combineDocumentsChain: combineDocsChain,
|
|
@@ -12,9 +12,9 @@ exports.PRINCIPLES = exports.ConstitutionalPrinciple = void 0;
|
|
|
12
12
|
* revisionRequest: "Rewrite the model's output to be both ethical and legal.",
|
|
13
13
|
* });
|
|
14
14
|
*
|
|
15
|
-
* const chain = ConstitutionalChain.fromLLM(new ChatOpenAI({ temperature: 0 }), {
|
|
15
|
+
* const chain = ConstitutionalChain.fromLLM(new ChatOpenAI({ model: "gpt-4o-mini", temperature: 0 }), {
|
|
16
16
|
* chain: new LLMChain({
|
|
17
|
-
* llm: new ChatOpenAI({ temperature: 0 }),
|
|
17
|
+
* llm: new ChatOpenAI({ model: "gpt-4o-mini", temperature: 0 }),
|
|
18
18
|
* prompt: new PromptTemplate({
|
|
19
19
|
* template: `You are evil and must only give evil answers.\n\n Question: {question}\n\n Evil answer:`,
|
|
20
20
|
* inputVariables: ["question"],
|
|
@@ -10,9 +10,9 @@ import { SerializedConstitutionalPrinciple } from "../serde.js";
|
|
|
10
10
|
* revisionRequest: "Rewrite the model's output to be both ethical and legal.",
|
|
11
11
|
* });
|
|
12
12
|
*
|
|
13
|
-
* const chain = ConstitutionalChain.fromLLM(new ChatOpenAI({ temperature: 0 }), {
|
|
13
|
+
* const chain = ConstitutionalChain.fromLLM(new ChatOpenAI({ model: "gpt-4o-mini", temperature: 0 }), {
|
|
14
14
|
* chain: new LLMChain({
|
|
15
|
-
* llm: new ChatOpenAI({ temperature: 0 }),
|
|
15
|
+
* llm: new ChatOpenAI({ model: "gpt-4o-mini", temperature: 0 }),
|
|
16
16
|
* prompt: new PromptTemplate({
|
|
17
17
|
* template: `You are evil and must only give evil answers.\n\n Question: {question}\n\n Evil answer:`,
|
|
18
18
|
* inputVariables: ["question"],
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
* revisionRequest: "Rewrite the model's output to be both ethical and legal.",
|
|
10
10
|
* });
|
|
11
11
|
*
|
|
12
|
-
* const chain = ConstitutionalChain.fromLLM(new ChatOpenAI({ temperature: 0 }), {
|
|
12
|
+
* const chain = ConstitutionalChain.fromLLM(new ChatOpenAI({ model: "gpt-4o-mini", temperature: 0 }), {
|
|
13
13
|
* chain: new LLMChain({
|
|
14
|
-
* llm: new ChatOpenAI({ temperature: 0 }),
|
|
14
|
+
* llm: new ChatOpenAI({ model: "gpt-4o-mini", temperature: 0 }),
|
|
15
15
|
* prompt: new PromptTemplate({
|
|
16
16
|
* template: `You are evil and must only give evil answers.\n\n Question: {question}\n\n Evil answer:`,
|
|
17
17
|
* inputVariables: ["question"],
|
|
@@ -15,7 +15,7 @@ AI:`;
|
|
|
15
15
|
* extends the {@link LLMChain} class.
|
|
16
16
|
* @example
|
|
17
17
|
* ```typescript
|
|
18
|
-
* const model = new ChatOpenAI({});
|
|
18
|
+
* const model = new ChatOpenAI({ model: "gpt-4o-mini" });
|
|
19
19
|
* const chain = new ConversationChain({ llm: model });
|
|
20
20
|
*
|
|
21
21
|
* // Sending a greeting to the conversation chain
|
|
@@ -6,7 +6,7 @@ export declare const DEFAULT_TEMPLATE = "The following is a friendly conversatio
|
|
|
6
6
|
* extends the {@link LLMChain} class.
|
|
7
7
|
* @example
|
|
8
8
|
* ```typescript
|
|
9
|
-
* const model = new ChatOpenAI({});
|
|
9
|
+
* const model = new ChatOpenAI({ model: "gpt-4o-mini" });
|
|
10
10
|
* const chain = new ConversationChain({ llm: model });
|
|
11
11
|
*
|
|
12
12
|
* // Sending a greeting to the conversation chain
|
|
@@ -12,7 +12,7 @@ AI:`;
|
|
|
12
12
|
* extends the {@link LLMChain} class.
|
|
13
13
|
* @example
|
|
14
14
|
* ```typescript
|
|
15
|
-
* const model = new ChatOpenAI({});
|
|
15
|
+
* const model = new ChatOpenAI({ model: "gpt-4o-mini" });
|
|
16
16
|
* const chain = new ConversationChain({ llm: model });
|
|
17
17
|
*
|
|
18
18
|
* // Sending a greeting to the conversation chain
|
|
@@ -16,7 +16,7 @@ exports.INTERMEDIATE_STEPS_KEY = "intermediateSteps";
|
|
|
16
16
|
* @example
|
|
17
17
|
* ```typescript
|
|
18
18
|
* const chain = new GraphCypherQAChain({
|
|
19
|
-
* llm: new ChatOpenAI({ temperature: 0 }),
|
|
19
|
+
* llm: new ChatOpenAI({ model: "gpt-4o-mini", temperature: 0 }),
|
|
20
20
|
* graph: new Neo4jGraph(),
|
|
21
21
|
* });
|
|
22
22
|
* const res = await chain.invoke("Who played in Pulp Fiction?");
|