langchain 0.0.11 → 0.0.13
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/agents.d.ts +1 -1
- package/agents.js +1 -1
- package/chains.d.ts +1 -1
- package/chains.js +1 -1
- package/dist/agents/agent.d.ts +5 -5
- package/dist/agents/agent.js +4 -9
- package/dist/agents/agent.js.map +1 -1
- package/dist/agents/agent_toolkits/base.d.ts +4 -0
- package/dist/agents/agent_toolkits/base.js +3 -0
- package/dist/agents/agent_toolkits/base.js.map +1 -0
- package/dist/agents/agent_toolkits/index.d.ts +3 -0
- package/dist/agents/agent_toolkits/index.js +4 -0
- package/dist/agents/agent_toolkits/index.js.map +1 -0
- package/dist/agents/agent_toolkits/json.d.ts +11 -0
- package/dist/agents/agent_toolkits/json.js +47 -0
- package/dist/agents/agent_toolkits/json.js.map +1 -0
- package/dist/agents/agent_toolkits/openapi.d.ts +14 -0
- package/dist/agents/agent_toolkits/openapi.js +57 -0
- package/dist/agents/agent_toolkits/openapi.js.map +1 -0
- package/dist/agents/agent_toolkits/prompt.d.ts +7 -0
- package/dist/agents/agent_toolkits/prompt.js +71 -0
- package/dist/agents/agent_toolkits/prompt.js.map +1 -0
- package/dist/agents/agent_toolkits/sql.d.ts +17 -0
- package/dist/agents/agent_toolkits/sql.js +61 -0
- package/dist/agents/agent_toolkits/sql.js.map +1 -0
- package/dist/agents/executor.d.ts +3 -3
- package/dist/agents/executor.js +6 -11
- package/dist/agents/executor.js.map +1 -1
- package/dist/agents/helpers.d.ts +3 -2
- package/dist/agents/helpers.js +5 -9
- package/dist/agents/helpers.js.map +1 -1
- package/dist/agents/index.d.ts +8 -7
- package/dist/agents/index.js +7 -16
- package/dist/agents/index.js.map +1 -1
- package/dist/agents/initialize.d.ts +3 -3
- package/dist/agents/initialize.js +5 -9
- package/dist/agents/initialize.js.map +1 -1
- package/dist/agents/load.d.ts +2 -2
- package/dist/agents/load.js +9 -13
- package/dist/agents/load.js.map +1 -1
- package/dist/agents/mrkl/index.d.ts +4 -4
- package/dist/agents/mrkl/index.js +13 -16
- package/dist/agents/mrkl/index.js.map +1 -1
- package/dist/agents/mrkl/prompt.js +3 -7
- package/dist/agents/mrkl/prompt.js.map +1 -1
- package/dist/agents/tests/agent.int.test.js +16 -18
- package/dist/agents/tests/agent.int.test.js.map +1 -1
- package/dist/agents/tests/calculator.test.js +17 -19
- package/dist/agents/tests/calculator.test.js.map +1 -1
- package/dist/agents/tests/json.test.d.ts +1 -0
- package/dist/agents/tests/json.test.js +48 -0
- package/dist/agents/tests/json.test.js.map +1 -0
- package/dist/agents/tests/sql.test.d.ts +1 -0
- package/dist/agents/tests/sql.test.js +68 -0
- package/dist/agents/tests/sql.test.js.map +1 -0
- package/dist/agents/tools/IFTTTWebhook.d.ts +35 -1
- package/dist/agents/tools/IFTTTWebhook.js +3 -11
- package/dist/agents/tools/IFTTTWebhook.js.map +1 -1
- package/dist/agents/tools/base.js +1 -5
- package/dist/agents/tools/base.js.map +1 -1
- package/dist/agents/tools/bingserpapi.d.ts +1 -1
- package/dist/agents/tools/bingserpapi.js +4 -11
- package/dist/agents/tools/bingserpapi.js.map +1 -1
- package/dist/agents/tools/calculator.d.ts +1 -1
- package/dist/agents/tools/calculator.js +4 -8
- package/dist/agents/tools/calculator.js.map +1 -1
- package/dist/agents/tools/chain.d.ts +15 -0
- package/dist/agents/tools/chain.js +38 -0
- package/dist/agents/tools/chain.js.map +1 -0
- package/dist/agents/tools/dadjokeapi.d.ts +1 -1
- package/dist/agents/tools/dadjokeapi.js +4 -11
- package/dist/agents/tools/dadjokeapi.js.map +1 -1
- package/dist/agents/tools/dynamic.d.ts +3 -3
- package/dist/agents/tools/dynamic.js +2 -6
- package/dist/agents/tools/dynamic.js.map +1 -1
- package/dist/agents/tools/index.d.ts +11 -7
- package/dist/agents/tools/index.js +11 -17
- package/dist/agents/tools/index.js.map +1 -1
- package/dist/agents/tools/json.d.ts +30 -0
- package/dist/agents/tools/json.js +110 -0
- package/dist/agents/tools/json.js.map +1 -0
- package/dist/agents/tools/llm-math.d.ts +1 -0
- package/dist/agents/tools/llm-math.js +1 -1
- package/dist/agents/tools/llm-math.js.map +1 -1
- package/dist/agents/tools/requests.d.ts +21 -0
- package/dist/agents/tools/requests.js +74 -0
- package/dist/agents/tools/requests.js.map +1 -0
- package/dist/agents/tools/serpapi.d.ts +5 -2
- package/dist/agents/tools/serpapi.js +18 -28
- package/dist/agents/tools/serpapi.js.map +1 -1
- package/dist/agents/tools/sql.d.ts +44 -0
- package/dist/agents/tools/sql.js +236 -0
- package/dist/agents/tools/sql.js.map +1 -0
- package/dist/agents/types.d.ts +2 -2
- package/dist/agents/types.js +1 -2
- package/dist/agents/types.js.map +1 -1
- package/dist/cache.d.ts +1 -1
- package/dist/cache.js +5 -14
- package/dist/cache.js.map +1 -1
- package/dist/chains/analyze_documents_chain.d.ts +2 -2
- package/dist/chains/analyze_documents_chain.js +9 -14
- package/dist/chains/analyze_documents_chain.js.map +1 -1
- package/dist/chains/base.d.ts +4 -6
- package/dist/chains/base.js +22 -23
- package/dist/chains/base.js.map +1 -1
- package/dist/chains/chat_vector_db_chain.d.ts +3 -3
- package/dist/chains/chat_vector_db_chain.js +15 -20
- package/dist/chains/chat_vector_db_chain.js.map +1 -1
- package/dist/chains/combine_docs_chain.d.ts +1 -1
- package/dist/chains/combine_docs_chain.js +18 -25
- package/dist/chains/combine_docs_chain.js.map +1 -1
- package/dist/chains/conversation.d.ts +4 -4
- package/dist/chains/conversation.js +8 -13
- package/dist/chains/conversation.js.map +1 -1
- package/dist/chains/index.d.ts +9 -9
- package/dist/chains/index.js +9 -23
- package/dist/chains/index.js.map +1 -1
- package/dist/chains/llm_chain.d.ts +4 -4
- package/dist/chains/llm_chain.js +16 -23
- package/dist/chains/llm_chain.js.map +1 -1
- package/dist/chains/load.d.ts +2 -2
- package/dist/chains/load.js +9 -13
- package/dist/chains/load.js.map +1 -1
- package/dist/chains/question_answering/load.d.ts +3 -3
- package/dist/chains/question_answering/load.js +12 -16
- package/dist/chains/question_answering/load.js.map +1 -1
- package/dist/chains/question_answering/map_reduce_prompts.d.ts +1 -1
- package/dist/chains/question_answering/map_reduce_prompts.js +3 -6
- package/dist/chains/question_answering/map_reduce_prompts.js.map +1 -1
- package/dist/chains/question_answering/stuff_prompts.d.ts +1 -1
- package/dist/chains/question_answering/stuff_prompts.js +2 -5
- package/dist/chains/question_answering/stuff_prompts.js.map +1 -1
- package/dist/chains/question_answering/tests/load.int.test.js +16 -18
- package/dist/chains/question_answering/tests/load.int.test.js.map +1 -1
- package/dist/chains/summarization/load.d.ts +4 -4
- package/dist/chains/summarization/load.js +11 -15
- package/dist/chains/summarization/load.js.map +1 -1
- package/dist/chains/summarization/stuff_prompts.d.ts +1 -1
- package/dist/chains/summarization/stuff_prompts.js +2 -5
- package/dist/chains/summarization/stuff_prompts.js.map +1 -1
- package/dist/chains/summarization/tests/load.int.test.js +16 -18
- package/dist/chains/summarization/tests/load.int.test.js.map +1 -1
- package/dist/chains/tests/chat_vector_db_qa_chain.int.test.js +19 -21
- package/dist/chains/tests/chat_vector_db_qa_chain.int.test.js.map +1 -1
- package/dist/chains/tests/combine_docs_chain.int.test.js +26 -28
- package/dist/chains/tests/combine_docs_chain.int.test.js.map +1 -1
- package/dist/chains/tests/combine_docs_chain.test.js +12 -14
- package/dist/chains/tests/combine_docs_chain.test.js.map +1 -1
- package/dist/chains/tests/llm_chain.int.test.js +22 -24
- package/dist/chains/tests/llm_chain.int.test.js.map +1 -1
- package/dist/chains/tests/vector_db_qa_chain.int.test.js +23 -25
- package/dist/chains/tests/vector_db_qa_chain.int.test.js.map +1 -1
- package/dist/chains/vector_db_qa.d.ts +3 -3
- package/dist/chains/vector_db_qa.js +9 -14
- package/dist/chains/vector_db_qa.js.map +1 -1
- package/dist/docstore/base.d.ts +1 -1
- package/dist/docstore/base.js +1 -5
- package/dist/docstore/base.js.map +1 -1
- package/dist/docstore/in_memory.d.ts +2 -2
- package/dist/docstore/in_memory.js +4 -9
- package/dist/docstore/in_memory.js.map +1 -1
- package/dist/docstore/index.d.ts +3 -3
- package/dist/docstore/index.js +3 -9
- package/dist/docstore/index.js.map +1 -1
- package/dist/document.js +3 -8
- package/dist/document.js.map +1 -1
- package/dist/document_loaders/base.d.ts +2 -2
- package/dist/document_loaders/base.js +3 -7
- package/dist/document_loaders/base.js.map +1 -1
- package/dist/document_loaders/cheerio_web_base.d.ts +3 -3
- package/dist/document_loaders/cheerio_web_base.js +5 -9
- package/dist/document_loaders/cheerio_web_base.js.map +1 -1
- package/dist/document_loaders/college_confidential.d.ts +2 -2
- package/dist/document_loaders/college_confidential.js +4 -8
- package/dist/document_loaders/college_confidential.js.map +1 -1
- package/dist/document_loaders/gitbook.d.ts +2 -2
- package/dist/document_loaders/gitbook.js +6 -11
- package/dist/document_loaders/gitbook.js.map +1 -1
- package/dist/document_loaders/hn.d.ts +2 -2
- package/dist/document_loaders/hn.js +5 -9
- package/dist/document_loaders/hn.js.map +1 -1
- package/dist/document_loaders/imsdb.d.ts +2 -2
- package/dist/document_loaders/imsdb.js +4 -8
- package/dist/document_loaders/imsdb.js.map +1 -1
- package/dist/document_loaders/index.d.ts +9 -9
- package/dist/document_loaders/index.js +8 -19
- package/dist/document_loaders/index.js.map +1 -1
- package/dist/document_loaders/srt.d.ts +9 -2
- package/dist/document_loaders/srt.js +25 -41
- package/dist/document_loaders/srt.js.map +1 -1
- package/dist/document_loaders/text.d.ts +2 -2
- package/dist/document_loaders/text.js +5 -9
- package/dist/document_loaders/text.js.map +1 -1
- package/dist/embeddings/base.js +1 -5
- package/dist/embeddings/base.js.map +1 -1
- package/dist/embeddings/fake.d.ts +1 -1
- package/dist/embeddings/fake.js +2 -6
- package/dist/embeddings/fake.js.map +1 -1
- package/dist/embeddings/index.d.ts +1 -1
- package/dist/embeddings/index.js +1 -5
- package/dist/embeddings/index.js.map +1 -1
- package/dist/embeddings/openai.d.ts +9 -1
- package/dist/embeddings/openai.js +39 -29
- package/dist/embeddings/openai.js.map +1 -1
- package/dist/embeddings/tests/openai.int.test.js +10 -12
- package/dist/embeddings/tests/openai.int.test.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -11
- package/dist/index.js.map +1 -1
- package/dist/llms/base.d.ts +1 -1
- package/dist/llms/base.js +18 -29
- package/dist/llms/base.js.map +1 -1
- package/dist/llms/cohere.d.ts +5 -1
- package/dist/llms/cohere.js +29 -15
- package/dist/llms/cohere.js.map +1 -1
- package/dist/llms/hf.d.ts +5 -1
- package/dist/llms/hf.js +15 -29
- package/dist/llms/hf.js.map +1 -1
- package/dist/llms/index.d.ts +5 -4
- package/dist/llms/index.js +5 -13
- package/dist/llms/index.js.map +1 -1
- package/dist/llms/load.d.ts +2 -11
- package/dist/llms/load.js +4 -7
- package/dist/llms/load.js.map +1 -1
- package/dist/llms/openai.d.ts +9 -2
- package/dist/llms/openai.js +66 -74
- package/dist/llms/openai.js.map +1 -1
- package/dist/llms/tests/cohere.int.test.js +4 -6
- package/dist/llms/tests/cohere.int.test.js.map +1 -1
- package/dist/llms/tests/huggingface_hub.int.test.js +4 -6
- package/dist/llms/tests/huggingface_hub.int.test.js.map +1 -1
- package/dist/llms/tests/openai.int.test.js +4 -6
- package/dist/llms/tests/openai.int.test.js.map +1 -1
- package/dist/memory/base.js +1 -5
- package/dist/memory/base.js.map +1 -1
- package/dist/memory/buffer_memory.d.ts +1 -1
- package/dist/memory/buffer_memory.js +5 -10
- package/dist/memory/buffer_memory.js.map +1 -1
- package/dist/memory/buffer_window_memory.d.ts +1 -1
- package/dist/memory/buffer_window_memory.js +6 -11
- package/dist/memory/buffer_window_memory.js.map +1 -1
- package/dist/memory/index.d.ts +3 -3
- package/dist/memory/index.js +3 -9
- package/dist/memory/index.js.map +1 -1
- package/dist/memory/tests/buffer_memory.test.js +6 -8
- package/dist/memory/tests/buffer_memory.test.js.map +1 -1
- package/dist/memory/tests/buffer_window_memory.test.js +7 -9
- package/dist/memory/tests/buffer_window_memory.test.js.map +1 -1
- package/dist/prompts/base.d.ts +3 -5
- package/dist/prompts/base.js +13 -13
- package/dist/prompts/base.js.map +1 -1
- package/dist/prompts/few_shot.d.ts +4 -4
- package/dist/prompts/few_shot.js +19 -20
- package/dist/prompts/few_shot.js.map +1 -1
- package/dist/prompts/index.d.ts +4 -4
- package/dist/prompts/index.js +4 -11
- package/dist/prompts/index.js.map +1 -1
- package/dist/prompts/load.d.ts +1 -1
- package/dist/prompts/load.js +7 -11
- package/dist/prompts/load.js.map +1 -1
- package/dist/prompts/parser.js +4 -11
- package/dist/prompts/parser.js.map +1 -1
- package/dist/prompts/prompt.d.ts +3 -3
- package/dist/prompts/prompt.js +11 -16
- package/dist/prompts/prompt.js.map +1 -1
- package/dist/prompts/template.d.ts +1 -1
- package/dist/prompts/template.js +10 -17
- package/dist/prompts/template.js.map +1 -1
- package/dist/prompts/tests/load.test.js +14 -18
- package/dist/prompts/tests/load.test.js.map +1 -1
- package/dist/prompts/tests/template.test.js +8 -10
- package/dist/prompts/tests/template.test.js.map +1 -1
- package/dist/tests/text_splitter.test.js +48 -50
- package/dist/tests/text_splitter.test.js.map +1 -1
- package/dist/text_splitter.d.ts +10 -9
- package/dist/text_splitter.js +33 -47
- package/dist/text_splitter.js.map +1 -1
- package/dist/util/axios-fetch-adapter.d.ts +6 -0
- package/dist/util/axios-fetch-adapter.js +202 -0
- package/dist/util/axios-fetch-adapter.js.map +1 -0
- package/dist/util/hub.d.ts +2 -2
- package/dist/util/hub.js +9 -22
- package/dist/util/hub.js.map +1 -1
- package/dist/util/index.d.ts +8 -5
- package/dist/util/index.js +28 -48
- package/dist/util/index.js.map +1 -1
- package/dist/vectorstores/base.d.ts +2 -2
- package/dist/vectorstores/base.js +2 -7
- package/dist/vectorstores/base.js.map +1 -1
- package/dist/vectorstores/chroma.d.ts +3 -3
- package/dist/vectorstores/chroma.js +20 -19
- package/dist/vectorstores/chroma.js.map +1 -1
- package/dist/vectorstores/hnswlib.d.ts +12 -5
- package/dist/vectorstores/hnswlib.js +59 -60
- package/dist/vectorstores/hnswlib.js.map +1 -1
- package/dist/vectorstores/index.d.ts +3 -3
- package/dist/vectorstores/index.js +3 -9
- package/dist/vectorstores/index.js.map +1 -1
- package/dist/vectorstores/pinecone.d.ts +9 -11
- package/dist/vectorstores/pinecone.js +29 -25
- package/dist/vectorstores/pinecone.js.map +1 -1
- package/dist/vectorstores/tests/hnswlib.int.test.js +28 -36
- package/dist/vectorstores/tests/hnswlib.int.test.js.map +1 -1
- package/dist/vectorstores/tests/hnswlib.test.js +13 -16
- package/dist/vectorstores/tests/hnswlib.test.js.map +1 -1
- package/docstore.d.ts +1 -1
- package/docstore.js +1 -1
- package/document.d.ts +1 -1
- package/document.js +1 -1
- package/document_loaders.d.ts +1 -1
- package/document_loaders.js +1 -1
- package/embeddings.d.ts +1 -1
- package/embeddings.js +1 -1
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/llms.d.ts +1 -1
- package/llms.js +1 -1
- package/memory.d.ts +1 -1
- package/memory.js +1 -1
- package/package.json +44 -54
- package/prompts.d.ts +1 -1
- package/prompts.js +1 -1
- package/text_splitter.d.ts +1 -1
- package/text_splitter.js +1 -1
- package/tools.d.ts +1 -1
- package/tools.js +1 -1
- package/vectorstores.d.ts +1 -1
- package/vectorstores.js +1 -1
- package/agents.mjs +0 -1
- package/chains.mjs +0 -1
- package/dist/embeddings/cohere.d.ts +0 -0
- package/dist/embeddings/cohere.js +0 -2
- package/dist/embeddings/cohere.js.map +0 -1
- package/docstore.mjs +0 -1
- package/document.mjs +0 -1
- package/document_loaders.mjs +0 -1
- package/embeddings.mjs +0 -1
- package/index.mjs +0 -1
- package/llms.mjs +0 -1
- package/memory.mjs +0 -1
- package/prompts.mjs +0 -1
- package/text_splitter.mjs +0 -1
- package/tools.mjs +0 -1
- package/vectorstores.mjs +0 -1
package/agents.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './dist/agents'
|
|
1
|
+
export * from './dist/agents/index.js'
|
package/agents.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export * from './dist/agents/index.js'
|
package/chains.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './dist/chains'
|
|
1
|
+
export * from './dist/chains/index.js'
|
package/chains.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export * from './dist/chains/index.js'
|
package/dist/agents/agent.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ChainValues } from "../chains";
|
|
2
|
-
import { SerializedZeroShotAgent, AgentAction, AgentFinish, AgentStep, StoppingMethod, Tool } from "./index";
|
|
3
|
-
import { BaseLLM } from "../llms";
|
|
4
|
-
import { LLMChain } from "../chains/llm_chain";
|
|
5
|
-
import { BasePromptTemplate } from "../prompts";
|
|
1
|
+
import { ChainValues } from "../chains/index.js";
|
|
2
|
+
import { SerializedZeroShotAgent, AgentAction, AgentFinish, AgentStep, StoppingMethod, Tool } from "./index.js";
|
|
3
|
+
import { BaseLLM } from "../llms/index.js";
|
|
4
|
+
import { LLMChain } from "../chains/llm_chain.js";
|
|
5
|
+
import { BasePromptTemplate } from "../prompts/index.js";
|
|
6
6
|
export interface StaticAgent {
|
|
7
7
|
/**
|
|
8
8
|
* Create a prompt for this class
|
package/dist/agents/agent.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Agent = exports.staticImplements = void 0;
|
|
4
|
-
const index_1 = require("./index");
|
|
1
|
+
import { ZeroShotAgent, } from "./index.js";
|
|
5
2
|
class ParseError extends Error {
|
|
6
3
|
constructor(msg, output) {
|
|
7
4
|
super(msg);
|
|
@@ -14,8 +11,7 @@ class ParseError extends Error {
|
|
|
14
11
|
this.output = output;
|
|
15
12
|
}
|
|
16
13
|
}
|
|
17
|
-
const staticImplements = (_) => { };
|
|
18
|
-
exports.staticImplements = staticImplements;
|
|
14
|
+
export const staticImplements = (_) => { };
|
|
19
15
|
/**
|
|
20
16
|
* Class responsible for calling a language model and deciding an action.
|
|
21
17
|
*
|
|
@@ -23,7 +19,7 @@ exports.staticImplements = staticImplements;
|
|
|
23
19
|
* include a variable called "agent_scratchpad" where the agent can put its
|
|
24
20
|
* intermediary work.
|
|
25
21
|
*/
|
|
26
|
-
class Agent {
|
|
22
|
+
export class Agent {
|
|
27
23
|
get inputKeys() {
|
|
28
24
|
return this.llmChain.inputKeys.filter((k) => k !== "agent_scratchpad");
|
|
29
25
|
}
|
|
@@ -144,11 +140,10 @@ class Agent {
|
|
|
144
140
|
static async deserialize(data) {
|
|
145
141
|
switch (data._type) {
|
|
146
142
|
case "zero-shot-react-description":
|
|
147
|
-
return
|
|
143
|
+
return ZeroShotAgent.deserialize(data);
|
|
148
144
|
default:
|
|
149
145
|
throw new Error("Unknown agent type");
|
|
150
146
|
}
|
|
151
147
|
}
|
|
152
148
|
}
|
|
153
|
-
exports.Agent = Agent;
|
|
154
149
|
//# sourceMappingURL=agent.js.map
|
package/dist/agents/agent.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.js","sourceRoot":"","sources":["../../agents/agent.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"agent.js","sourceRoot":"","sources":["../../src/agents/agent.ts"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,GAOd,MAAM,YAAY,CAAC;AAKpB,MAAM,UAAW,SAAQ,KAAK;IAG5B,YAAY,GAAW,EAAE,MAAc;QACrC,KAAK,CAAC,GAAG,CAAC,CAAC;QAHb;;;;;WAAe;QAIb,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF;AAyBD,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAI,CAAI,EAAE,EAAE,GAAE,CAAC,CAAC;AAShD;;;;;;GAMG;AACH,MAAM,OAAgB,KAAK;IAOzB,IAAI,SA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,EAAE;oBAC5B,OAAO,MAAM,CAAC;iBACf;gBAED,OAAO,EAAE,YAAY,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,GAAG,EAAE,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE,CAAC;aAClE;YAAC,OAAO,GAAG,EAAE;gBACZ,IAAI,CAAC,CAAC,GAAG,YAAY,UAAU,CAAC,EAAE;oBAChC,MAAM,GAAG,CAAC;iBACX;gBACD,OAAO,EAAE,YAAY,EAAE,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,EAAE,GAAG,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC;aAClE;SACF;QAED,MAAM,IAAI,KAAK,CAAC,4BAA4B,mBAAmB,EAAE,CAAC,CAAC;IACrE,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,KAAK,CAAC,WAAW,CACtB,IAAyD;QAEzD,QAAQ,IAAI,CAAC,KAAK,EAAE;YAClB,KAAK,6BAA6B;gBAChC,OAAO,aAAa,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;YACzC;gBACE,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;SACzC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../../src/agents/agent_toolkits/base.ts"],"names":[],"mappings":"AAEA,MAAM,OAAgB,OAAO;CAE5B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/agents/agent_toolkits/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AACtD,OAAO,EACL,eAAe,EACf,cAAc,EACd,kBAAkB,GACnB,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { BaseLLM } from "../../llms/index.js";
|
|
2
|
+
import { JsonSpec, Tool } from "../tools/index.js";
|
|
3
|
+
import { CreatePromptArgs } from "../mrkl/index.js";
|
|
4
|
+
import { Toolkit } from "./base.js";
|
|
5
|
+
import { AgentExecutor } from "../executor.js";
|
|
6
|
+
export declare class JsonToolkit extends Toolkit {
|
|
7
|
+
jsonSpec: JsonSpec;
|
|
8
|
+
tools: Tool[];
|
|
9
|
+
constructor(jsonSpec: JsonSpec);
|
|
10
|
+
}
|
|
11
|
+
export declare function createJsonAgent(llm: BaseLLM, toolkit: JsonToolkit, args?: CreatePromptArgs): AgentExecutor;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { JsonGetValueTool, JsonListKeysTool, } from "../tools/index.js";
|
|
2
|
+
import { JSON_PREFIX, JSON_SUFFIX } from "./prompt.js";
|
|
3
|
+
import { LLMChain } from "../../chains/index.js";
|
|
4
|
+
import { ZeroShotAgent } from "../mrkl/index.js";
|
|
5
|
+
import { Toolkit } from "./base.js";
|
|
6
|
+
import { AgentExecutor } from "../executor.js";
|
|
7
|
+
export class JsonToolkit extends Toolkit {
|
|
8
|
+
constructor(jsonSpec) {
|
|
9
|
+
super();
|
|
10
|
+
Object.defineProperty(this, "jsonSpec", {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
configurable: true,
|
|
13
|
+
writable: true,
|
|
14
|
+
value: jsonSpec
|
|
15
|
+
});
|
|
16
|
+
Object.defineProperty(this, "tools", {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
configurable: true,
|
|
19
|
+
writable: true,
|
|
20
|
+
value: void 0
|
|
21
|
+
});
|
|
22
|
+
this.tools = [
|
|
23
|
+
new JsonListKeysTool(jsonSpec),
|
|
24
|
+
new JsonGetValueTool(jsonSpec),
|
|
25
|
+
];
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export function createJsonAgent(llm, toolkit, args) {
|
|
29
|
+
const { prefix = JSON_PREFIX, suffix = JSON_SUFFIX, inputVariables = ["input", "agent_scratchpad"], } = args ?? {};
|
|
30
|
+
const { tools } = toolkit;
|
|
31
|
+
const prompt = ZeroShotAgent.createPrompt(tools, {
|
|
32
|
+
prefix,
|
|
33
|
+
suffix,
|
|
34
|
+
inputVariables,
|
|
35
|
+
});
|
|
36
|
+
const chain = new LLMChain({ prompt, llm });
|
|
37
|
+
const agent = new ZeroShotAgent({
|
|
38
|
+
llmChain: chain,
|
|
39
|
+
allowedTools: tools.map((t) => t.name),
|
|
40
|
+
});
|
|
41
|
+
return AgentExecutor.fromAgentAndTools({
|
|
42
|
+
agent,
|
|
43
|
+
tools,
|
|
44
|
+
returnIntermediateSteps: true,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=json.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json.js","sourceRoot":"","sources":["../../../src/agents/agent_toolkits/json.ts"],"names":[],"mappings":"AACA,OAAO,EACL,gBAAgB,EAChB,gBAAgB,GAGjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAoB,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,MAAM,OAAO,WAAY,SAAQ,OAAO;IAGtC,YAAmB,QAAkB;QACnC,KAAK,EAAE,CAAC;;;;;mBADS;;QAFnB;;;;;WAAc;QAIZ,IAAI,CAAC,KAAK,GAAG;YACX,IAAI,gBAAgB,CAAC,QAAQ,CAAC;YAC9B,IAAI,gBAAgB,CAAC,QAAQ,CAAC;SAC/B,CAAC;IACJ,CAAC;CACF;AAED,MAAM,UAAU,eAAe,CAC7B,GAAY,EACZ,OAAoB,EACpB,IAAuB;IAEvB,MAAM,EACJ,MAAM,GAAG,WAAW,EACpB,MAAM,GAAG,WAAW,EACpB,cAAc,GAAG,CAAC,OAAO,EAAE,kBAAkB,CAAC,GAC/C,GAAG,IAAI,IAAI,EAAE,CAAC;IACf,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;IAC1B,MAAM,MAAM,GAAG,aAAa,CAAC,YAAY,CAAC,KAAK,EAAE;QAC/C,MAAM;QACN,MAAM;QACN,cAAc;KACf,CAAC,CAAC;IACH,MAAM,KAAK,GAAG,IAAI,QAAQ,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;IAC5C,MAAM,KAAK,GAAG,IAAI,aAAa,CAAC;QAC9B,QAAQ,EAAE,KAAK;QACf,YAAY,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;KACvC,CAAC,CAAC;IACH,OAAO,aAAa,CAAC,iBAAiB,CAAC;QACrC,KAAK;QACL,KAAK;QACL,uBAAuB,EAAE,IAAI;KAC9B,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { BaseLLM } from "../../llms/index.js";
|
|
2
|
+
import { JsonSpec, Tool } from "../tools/index.js";
|
|
3
|
+
import { AgentExecutor } from "../executor.js";
|
|
4
|
+
import { CreatePromptArgs } from "../mrkl/index.js";
|
|
5
|
+
import { Toolkit } from "./base.js";
|
|
6
|
+
import { Headers } from "../tools/requests.js";
|
|
7
|
+
export declare class RequestsToolkit extends Toolkit {
|
|
8
|
+
tools: Tool[];
|
|
9
|
+
constructor(headers?: Headers);
|
|
10
|
+
}
|
|
11
|
+
export declare class OpenApiToolkit extends RequestsToolkit {
|
|
12
|
+
constructor(jsonSpec: JsonSpec, llm: BaseLLM, headers?: Headers);
|
|
13
|
+
}
|
|
14
|
+
export declare function createOpenApiAgent(llm: BaseLLM, openApiToolkit: OpenApiToolkit, args?: CreatePromptArgs): AgentExecutor;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { DynamicTool, RequestsGetTool, RequestsPostTool, } from "../tools/index.js";
|
|
2
|
+
import { AgentExecutor } from "../executor.js";
|
|
3
|
+
import { OPENAPI_PREFIX, OPENAPI_SUFFIX, JSON_EXPLORER_DESCRIPTION, } from "./prompt.js";
|
|
4
|
+
import { LLMChain } from "../../chains/index.js";
|
|
5
|
+
import { ZeroShotAgent } from "../mrkl/index.js";
|
|
6
|
+
import { Toolkit } from "./base.js";
|
|
7
|
+
import { createJsonAgent, JsonToolkit } from "./json.js";
|
|
8
|
+
export class RequestsToolkit extends Toolkit {
|
|
9
|
+
constructor(headers) {
|
|
10
|
+
super();
|
|
11
|
+
Object.defineProperty(this, "tools", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
configurable: true,
|
|
14
|
+
writable: true,
|
|
15
|
+
value: void 0
|
|
16
|
+
});
|
|
17
|
+
this.tools = [new RequestsGetTool(headers), new RequestsPostTool(headers)];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export class OpenApiToolkit extends RequestsToolkit {
|
|
21
|
+
constructor(jsonSpec, llm, headers) {
|
|
22
|
+
super(headers);
|
|
23
|
+
const jsonAgent = createJsonAgent(llm, new JsonToolkit(jsonSpec));
|
|
24
|
+
this.tools = [
|
|
25
|
+
...this.tools,
|
|
26
|
+
new DynamicTool({
|
|
27
|
+
name: "json_explorer",
|
|
28
|
+
func: async (input) => {
|
|
29
|
+
const result = await jsonAgent.call({ input });
|
|
30
|
+
return result.output;
|
|
31
|
+
},
|
|
32
|
+
description: JSON_EXPLORER_DESCRIPTION,
|
|
33
|
+
}),
|
|
34
|
+
];
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
export function createOpenApiAgent(llm, openApiToolkit, args) {
|
|
38
|
+
const { prefix = OPENAPI_PREFIX, suffix = OPENAPI_SUFFIX, inputVariables = ["input", "agent_scratchpad"], } = args ?? {};
|
|
39
|
+
const { tools } = openApiToolkit;
|
|
40
|
+
const prompt = ZeroShotAgent.createPrompt(tools, {
|
|
41
|
+
prefix,
|
|
42
|
+
suffix,
|
|
43
|
+
inputVariables,
|
|
44
|
+
});
|
|
45
|
+
const chain = new LLMChain({
|
|
46
|
+
prompt,
|
|
47
|
+
llm,
|
|
48
|
+
});
|
|
49
|
+
const toolNames = tools.map((tool) => tool.name);
|
|
50
|
+
const agent = new ZeroShotAgent({ llmChain: chain, allowedTools: toolNames });
|
|
51
|
+
return AgentExecutor.fromAgentAndTools({
|
|
52
|
+
agent,
|
|
53
|
+
tools,
|
|
54
|
+
returnIntermediateSteps: true,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=openapi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openapi.js","sourceRoot":"","sources":["../../../src/agents/agent_toolkits/openapi.ts"],"names":[],"mappings":"AACA,OAAO,EACL,WAAW,EAEX,eAAe,EACf,gBAAgB,GAEjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EACL,cAAc,EACd,cAAc,EACd,yBAAyB,GAC1B,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAoB,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAEzD,MAAM,OAAO,eAAgB,SAAQ,OAAO;IAG1C,YAAY,OAAiB;QAC3B,KAAK,EAAE,CAAC;QAHV;;;;;WAAc;QAIZ,IAAI,CAAC,KAAK,GAAG,CAAC,IAAI,eAAe,CAAC,OAAO,CAAC,EAAE,IAAI,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC;IAC7E,CAAC;CACF;AAED,MAAM,OAAO,cAA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AO,aAAa,CAAC,iBAAiB,CAAC;QACrC,KAAK;QACL,KAAK;QACL,uBAAuB,EAAE,IAAI;KAC9B,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const SQL_PREFIX = "You are an agent designed to interact with a SQL database.\nGiven an input question, create a syntactically correct {dialect} query to run, then look at the results of the query and return the answer.\nUnless the user specifies a specific number of examples they wish to obtain, always limit your query to at most {top_k} results using the LIMIT clause.\nYou can order the results by a relevant column to return the most interesting examples in the database.\nNever query for all the columns from a specific table, only ask for a the few relevant columns given the question.\nYou have access to tools for interacting with the database.\nOnly use the below tools. Only use the information returned by the below tools to construct your final answer.\nYou MUST double check your query before executing it. If you get an error while executing a query, rewrite the query and try again.\n\nDO NOT make any DML statements (INSERT, UPDATE, DELETE, DROP etc.) to the database.\n\nIf the question does not seem related to the database, just return \"I don't know\" as the answer.";
|
|
2
|
+
export declare const SQL_SUFFIX = "Begin!\n\nQuestion: {input}\nThought: I should look at the tables in the database to see what I can query.\n{agent_scratchpad}";
|
|
3
|
+
export declare const JSON_PREFIX = "You are an agent designed to interact with JSON.\nYour goal is to return a final answer by interacting with the JSON.\nYou have access to the following tools which help you learn more about the JSON you are interacting with.\nOnly use the below tools. Only use the information returned by the below tools to construct your final answer.\nDo not make up any information that is not contained in the JSON.\nYour input to the tools should be in the form of in json pointer syntax (e.g. /key1/0/key2).\nYou must escape a slash in a key with a ~1, and escape a tilde with a ~0.\nFor example, to access the key /foo, you would use /~1foo\nYou should only use keys that you know for a fact exist. You must validate that a key exists by seeing it previously when calling 'json_list_keys'.\nIf you have not seen a key in one of those responses, you cannot use it.\nYou should only add one key at a time to the path. You cannot add multiple keys at once.\nIf you encounter a null or undefined value, go back to the previous key, look at the available keys, and try again.\n\nIf the question does not seem to be related to the JSON, just return \"I don't know\" as the answer.\nAlways begin your interaction with the 'json_list_keys' with an empty string as the input to see what keys exist in the JSON.\n\nNote that sometimes the value at a given path is large. In this case, you will get an error \"Value is a large dictionary, should explore its keys directly\".\nIn this case, you should ALWAYS follow up by using the 'json_list_keys' tool to see what keys exist at that path.\nDo not simply refer the user to the JSON or a section of the JSON, as this is not a valid answer. Keep digging until you find the answer and explicitly return it.";
|
|
4
|
+
export declare const JSON_SUFFIX = "Begin!\"\n\nQuestion: {input}\nThought: I should look at the keys that exist to see what I can query. I should use the 'json_list_keys' tool with an empty string as the input.\n{agent_scratchpad}";
|
|
5
|
+
export declare const OPENAPI_PREFIX = "You are an agent designed to answer questions by making web requests to an API given the OpenAPI spec.\n\nIf the question does not seem related to the API, return I don't know. Do not make up an answer.\nOnly use information provided by the tools to construct your response.\n\nTo find information in the OpenAPI spec, use the 'json_explorer' tool. The input to this tool is a question about the API.\n\nTake the following steps:\nFirst, find the base URL needed to make the request.\n\nSecond, find the relevant paths needed to answer the question. Take note that, sometimes, you might need to make more than one request to more than one path to answer the question.\n\nThird, find the required parameters needed to make the request. For GET requests, these are usually URL parameters and for POST requests, these are request body parameters.\n\nFourth, make the requests needed to answer the question. Ensure that you are sending the correct parameters to the request by checking which parameters are required. For parameters with a fixed set of values, please use the spec to look at which values are allowed.\n\nUse the exact parameter names as listed in the spec, do not make up any names or abbreviate the names of parameters.\nIf you get a not found error, ensure that you are using a path that actually exists in the spec.";
|
|
6
|
+
export declare const OPENAPI_SUFFIX = "Begin!\"\n\nQuestion: {input}\nThought: I should explore the spec to find the base url for the API.\n{agent_scratchpad}";
|
|
7
|
+
export declare const JSON_EXPLORER_DESCRIPTION = "\nCan be used to answer questions about the openapi spec for the API. Always use this tool before trying to make a request. \nExample inputs to this tool: \n 'What are the required query parameters for a GET request to the /bar endpoint?'\n 'What are the required parameters in the request body for a POST request to the /foo endpoint?'\nAlways give this tool a specific question.";
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
export const SQL_PREFIX = `You are an agent designed to interact with a SQL database.
|
|
2
|
+
Given an input question, create a syntactically correct {dialect} query to run, then look at the results of the query and return the answer.
|
|
3
|
+
Unless the user specifies a specific number of examples they wish to obtain, always limit your query to at most {top_k} results using the LIMIT clause.
|
|
4
|
+
You can order the results by a relevant column to return the most interesting examples in the database.
|
|
5
|
+
Never query for all the columns from a specific table, only ask for a the few relevant columns given the question.
|
|
6
|
+
You have access to tools for interacting with the database.
|
|
7
|
+
Only use the below tools. Only use the information returned by the below tools to construct your final answer.
|
|
8
|
+
You MUST double check your query before executing it. If you get an error while executing a query, rewrite the query and try again.
|
|
9
|
+
|
|
10
|
+
DO NOT make any DML statements (INSERT, UPDATE, DELETE, DROP etc.) to the database.
|
|
11
|
+
|
|
12
|
+
If the question does not seem related to the database, just return "I don't know" as the answer.`;
|
|
13
|
+
export const SQL_SUFFIX = `Begin!
|
|
14
|
+
|
|
15
|
+
Question: {input}
|
|
16
|
+
Thought: I should look at the tables in the database to see what I can query.
|
|
17
|
+
{agent_scratchpad}`;
|
|
18
|
+
export const JSON_PREFIX = `You are an agent designed to interact with JSON.
|
|
19
|
+
Your goal is to return a final answer by interacting with the JSON.
|
|
20
|
+
You have access to the following tools which help you learn more about the JSON you are interacting with.
|
|
21
|
+
Only use the below tools. Only use the information returned by the below tools to construct your final answer.
|
|
22
|
+
Do not make up any information that is not contained in the JSON.
|
|
23
|
+
Your input to the tools should be in the form of in json pointer syntax (e.g. /key1/0/key2).
|
|
24
|
+
You must escape a slash in a key with a ~1, and escape a tilde with a ~0.
|
|
25
|
+
For example, to access the key /foo, you would use /~1foo
|
|
26
|
+
You should only use keys that you know for a fact exist. You must validate that a key exists by seeing it previously when calling 'json_list_keys'.
|
|
27
|
+
If you have not seen a key in one of those responses, you cannot use it.
|
|
28
|
+
You should only add one key at a time to the path. You cannot add multiple keys at once.
|
|
29
|
+
If you encounter a null or undefined value, go back to the previous key, look at the available keys, and try again.
|
|
30
|
+
|
|
31
|
+
If the question does not seem to be related to the JSON, just return "I don't know" as the answer.
|
|
32
|
+
Always begin your interaction with the 'json_list_keys' with an empty string as the input to see what keys exist in the JSON.
|
|
33
|
+
|
|
34
|
+
Note that sometimes the value at a given path is large. In this case, you will get an error "Value is a large dictionary, should explore its keys directly".
|
|
35
|
+
In this case, you should ALWAYS follow up by using the 'json_list_keys' tool to see what keys exist at that path.
|
|
36
|
+
Do not simply refer the user to the JSON or a section of the JSON, as this is not a valid answer. Keep digging until you find the answer and explicitly return it.`;
|
|
37
|
+
export const JSON_SUFFIX = `Begin!"
|
|
38
|
+
|
|
39
|
+
Question: {input}
|
|
40
|
+
Thought: I should look at the keys that exist to see what I can query. I should use the 'json_list_keys' tool with an empty string as the input.
|
|
41
|
+
{agent_scratchpad}`;
|
|
42
|
+
export const OPENAPI_PREFIX = `You are an agent designed to answer questions by making web requests to an API given the OpenAPI spec.
|
|
43
|
+
|
|
44
|
+
If the question does not seem related to the API, return I don't know. Do not make up an answer.
|
|
45
|
+
Only use information provided by the tools to construct your response.
|
|
46
|
+
|
|
47
|
+
To find information in the OpenAPI spec, use the 'json_explorer' tool. The input to this tool is a question about the API.
|
|
48
|
+
|
|
49
|
+
Take the following steps:
|
|
50
|
+
First, find the base URL needed to make the request.
|
|
51
|
+
|
|
52
|
+
Second, find the relevant paths needed to answer the question. Take note that, sometimes, you might need to make more than one request to more than one path to answer the question.
|
|
53
|
+
|
|
54
|
+
Third, find the required parameters needed to make the request. For GET requests, these are usually URL parameters and for POST requests, these are request body parameters.
|
|
55
|
+
|
|
56
|
+
Fourth, make the requests needed to answer the question. Ensure that you are sending the correct parameters to the request by checking which parameters are required. For parameters with a fixed set of values, please use the spec to look at which values are allowed.
|
|
57
|
+
|
|
58
|
+
Use the exact parameter names as listed in the spec, do not make up any names or abbreviate the names of parameters.
|
|
59
|
+
If you get a not found error, ensure that you are using a path that actually exists in the spec.`;
|
|
60
|
+
export const OPENAPI_SUFFIX = `Begin!"
|
|
61
|
+
|
|
62
|
+
Question: {input}
|
|
63
|
+
Thought: I should explore the spec to find the base url for the API.
|
|
64
|
+
{agent_scratchpad}`;
|
|
65
|
+
export const JSON_EXPLORER_DESCRIPTION = `
|
|
66
|
+
Can be used to answer questions about the openapi spec for the API. Always use this tool before trying to make a request.
|
|
67
|
+
Example inputs to this tool:
|
|
68
|
+
'What are the required query parameters for a GET request to the /bar endpoint?'
|
|
69
|
+
'What are the required parameters in the request body for a POST request to the /foo endpoint?'
|
|
70
|
+
Always give this tool a specific question.`;
|
|
71
|
+
//# sourceMappingURL=prompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../../src/agents/agent_toolkits/prompt.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,UAAU,GAAG;;;;;;;;;;;iGAWuE,CAAC;AAElG,MAAM,CAAC,MAAM,UAAU,GAAG;;;;mBAIP,CAAC;AAEpB,MAAM,CAAC,MAAM,WAAW,GAAG;;;;;;;;;;;;;;;;;;mKAkBwI,CAAC;AAEpK,MAAM,CAAC,MAAM,WAAW,GAAG;;;;mBAIR,CAAC;AAEpB,MAAM,CAAC,MAAM,cAAc,GAAG;;;;;;;;;;;;;;;;;iGAiBmE,CAAC;AAElG,MAAM,CAAC,MAAM,cAAc,GAAG;;;;mBAIX,CAAC;AACpB,MAAM,CAAC,MAAM,yBAAyB,GAAG;;;;;2CAKE,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Tool, SqlDatabase } from "../tools/index.js";
|
|
2
|
+
import { Toolkit } from "./base.js";
|
|
3
|
+
import { BaseLLM } from "../../llms/index.js";
|
|
4
|
+
import { CreatePromptArgs } from "../mrkl/index.js";
|
|
5
|
+
import { AgentExecutor } from "../executor.js";
|
|
6
|
+
type SqlCreatePromptArgs = {
|
|
7
|
+
/** Number of results to return. */
|
|
8
|
+
topK?: number;
|
|
9
|
+
} & CreatePromptArgs;
|
|
10
|
+
export declare class SqlToolkit extends Toolkit {
|
|
11
|
+
tools: Tool[];
|
|
12
|
+
db: SqlDatabase;
|
|
13
|
+
dialect: string;
|
|
14
|
+
constructor(db: SqlDatabase);
|
|
15
|
+
}
|
|
16
|
+
export declare function createSqlAgent(llm: BaseLLM, toolkit: SqlToolkit, args?: SqlCreatePromptArgs): AgentExecutor;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { InfoSqlTool, ListTablesSqlTool, QueryCheckerTool, QuerySqlTool, } from "../tools/index.js";
|
|
2
|
+
import { Toolkit } from "./base.js";
|
|
3
|
+
import { SQL_PREFIX, SQL_SUFFIX } from "./prompt.js";
|
|
4
|
+
import { interpolateFString } from "../../prompts/template.js";
|
|
5
|
+
import { LLMChain } from "../../chains/index.js";
|
|
6
|
+
import { ZeroShotAgent } from "../mrkl/index.js";
|
|
7
|
+
import { AgentExecutor } from "../executor.js";
|
|
8
|
+
export class SqlToolkit extends Toolkit {
|
|
9
|
+
constructor(db) {
|
|
10
|
+
super();
|
|
11
|
+
Object.defineProperty(this, "tools", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
configurable: true,
|
|
14
|
+
writable: true,
|
|
15
|
+
value: void 0
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(this, "db", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
configurable: true,
|
|
20
|
+
writable: true,
|
|
21
|
+
value: void 0
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(this, "dialect", {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
configurable: true,
|
|
26
|
+
writable: true,
|
|
27
|
+
value: "sqlite"
|
|
28
|
+
});
|
|
29
|
+
this.db = db;
|
|
30
|
+
this.tools = [
|
|
31
|
+
new QuerySqlTool(db),
|
|
32
|
+
new InfoSqlTool(db),
|
|
33
|
+
new ListTablesSqlTool(db),
|
|
34
|
+
new QueryCheckerTool(),
|
|
35
|
+
];
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export function createSqlAgent(llm, toolkit, args) {
|
|
39
|
+
const { prefix = SQL_PREFIX, suffix = SQL_SUFFIX, inputVariables = ["input", "agent_scratchpad"], topK = 10, } = args ?? {};
|
|
40
|
+
const { tools } = toolkit;
|
|
41
|
+
const formattedPrefix = interpolateFString(prefix, {
|
|
42
|
+
dialect: toolkit.dialect,
|
|
43
|
+
top_k: topK,
|
|
44
|
+
});
|
|
45
|
+
const prompt = ZeroShotAgent.createPrompt(tools, {
|
|
46
|
+
prefix: formattedPrefix,
|
|
47
|
+
suffix,
|
|
48
|
+
inputVariables,
|
|
49
|
+
});
|
|
50
|
+
const chain = new LLMChain({ prompt, llm });
|
|
51
|
+
const agent = new ZeroShotAgent({
|
|
52
|
+
llmChain: chain,
|
|
53
|
+
allowedTools: tools.map((t) => t.name),
|
|
54
|
+
});
|
|
55
|
+
return AgentExecutor.fromAgentAndTools({
|
|
56
|
+
agent,
|
|
57
|
+
tools,
|
|
58
|
+
returnIntermediateSteps: true,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=sql.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sql.js","sourceRoot":"","sources":["../../../src/agents/agent_toolkits/sql.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,WAAW,EACX,iBAAiB,EACjB,gBAAgB,EAChB,YAAY,GAEb,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAoB,MAAM,kBAAkB,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAO/C,MAAM,OAAO,UAAW,SAAQ,OAAO;IAOrC,YAAY,EAAe;QACzB,KAAK,EAAE,CAAC;QAPV;;;;;WAAc;QAEd;;;;;WAAgB;QAEhB;;;;mBAAU,QAAQ;WAAC;QAIjB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ent, Tool, StoppingMethod } from "./index";
|
|
3
|
-
import { SerializedLLMChain } from "../chains/llm_chain";
|
|
1
|
+
import { ChainValues, BaseChain } from "../chains/index.js";
|
|
2
|
+
import { Agent, Tool, StoppingMethod } from "./index.js";
|
|
3
|
+
import { SerializedLLMChain } from "../chains/llm_chain.js";
|
|
4
4
|
type AgentExecutorInput = {
|
|
5
5
|
agent: Agent;
|
|
6
6
|
tools: Tool[];
|
package/dist/agents/executor.js
CHANGED
|
@@ -1,17 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AgentExecutor = void 0;
|
|
4
|
-
const chains_1 = require("../chains");
|
|
1
|
+
import { BaseChain } from "../chains/index.js";
|
|
5
2
|
/**
|
|
6
3
|
* A chain managing an agent using tools.
|
|
7
4
|
* @augments BaseChain
|
|
8
5
|
*/
|
|
9
|
-
class AgentExecutor extends
|
|
6
|
+
export class AgentExecutor extends BaseChain {
|
|
10
7
|
get inputKeys() {
|
|
11
8
|
return this.agent.inputKeys;
|
|
12
9
|
}
|
|
13
10
|
constructor(input) {
|
|
14
|
-
var _a, _b, _c;
|
|
15
11
|
super();
|
|
16
12
|
Object.defineProperty(this, "agent", {
|
|
17
13
|
enumerable: true,
|
|
@@ -46,10 +42,10 @@ class AgentExecutor extends chains_1.BaseChain {
|
|
|
46
42
|
this.agent = input.agent;
|
|
47
43
|
this.tools = input.tools;
|
|
48
44
|
this.returnIntermediateSteps =
|
|
49
|
-
|
|
50
|
-
this.maxIterations =
|
|
45
|
+
input.returnIntermediateSteps ?? this.returnIntermediateSteps;
|
|
46
|
+
this.maxIterations = input.maxIterations ?? this.maxIterations;
|
|
51
47
|
this.earlyStoppingMethod =
|
|
52
|
-
|
|
48
|
+
input.earlyStoppingMethod ?? this.earlyStoppingMethod;
|
|
53
49
|
}
|
|
54
50
|
/** Create from agent and a list of tools. */
|
|
55
51
|
static fromAgentAndTools(fields) {
|
|
@@ -80,7 +76,7 @@ class AgentExecutor extends chains_1.BaseChain {
|
|
|
80
76
|
? await tool.call(action.toolInput)
|
|
81
77
|
: `${action.tool} is not a valid tool, try another one.`;
|
|
82
78
|
steps.push({ action, observation });
|
|
83
|
-
if (tool
|
|
79
|
+
if (tool?.returnDirect) {
|
|
84
80
|
return getOutput({
|
|
85
81
|
returnValues: { [this.agent.returnValues[0]]: observation },
|
|
86
82
|
log: "",
|
|
@@ -98,5 +94,4 @@ class AgentExecutor extends chains_1.BaseChain {
|
|
|
98
94
|
throw new Error("Cannot serialize an AgentExecutor");
|
|
99
95
|
}
|
|
100
96
|
}
|
|
101
|
-
exports.AgentExecutor = AgentExecutor;
|
|
102
97
|
//# sourceMappingURL=executor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../agents/executor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../src/agents/executor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAkB5D;;;GAGG;AACH,MAAM,OAAO,aAAc,SAAQ,SAAS;IAW1C,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC;IAC9B,CAAC;IAED,YAAY,KAAyB;QACnC,KAAK,EAAE,CAAC;QAfV;;;;;WAAa;QAEb;;;;;WAAc;QAEd;;;;mBAA0B,KAAK;WAAC;QAEhC;;;;mBAAyB,EAAE;WAAC;QAE5B;;;;mBAAsC,OAAO;WAAC;QAQ5C,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;QACzB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;QACzB,IAAI,CAAC,uBAAuB;YAC1B,KAAK,CAAC,uBAAuB,IAAI,IAAI,CAAC,uBAAuB,CAAC;QAChE,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC,aAAa,IAAI,IAAI,C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CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;YACpD,MAAM,WAAW,GAAG,IAAI;gBACtB,CAAC,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC;gBACnC,CAAC,CAAC,GAAG,MAAM,CAAC,IAAI,wCAAwC,CAAC;YAC3D,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC,CAAC;YACpC,IAAI,IAAI,EAAE,YAAY,EAAE;gBACtB,OAAO,SAAS,CAAC;oBACf,YAAY,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE;oBAC3D,GAAG,EAAE,EAAE;iBACR,CAAC,CAAC;aACJ;YACD,UAAU,IAAI,CAAC,CAAC;SACjB;QAED,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,qBAAqB,CACnD,IAAI,CAAC,mBAAmB,EACxB,KAAK,EACL,MAAM,CACP,CAAC;QAEF,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC;IAC3B,CAAC;IAED,UAAU;QACR,OAAO,gBAAyB,CAAC;IACnC,CAAC;IAED,SAAS;QACP,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;IACvD,CAAC;CACF"}
|
package/dist/agents/helpers.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import { SerializedAgentT,
|
|
2
|
-
import {
|
|
1
|
+
import type { SerializedAgentT, AgentInput } from "./index.js";
|
|
2
|
+
import { Tool } from "./tools/index.js";
|
|
3
|
+
import { BaseLLM } from "../llms/index.js";
|
|
3
4
|
export declare const deserializeHelper: <T extends string, U, V extends AgentInput, Z>(llm: BaseLLM | undefined, tools: Tool[] | undefined, data: SerializedAgentT<T, U, V>, fromLLMAndTools: (llm: BaseLLM, tools: Tool[], args: U) => Z, fromConstructor: (args: V) => Z) => Promise<Z>;
|
package/dist/agents/helpers.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const chains_1 = require("../chains");
|
|
5
|
-
const util_1 = require("../util");
|
|
6
|
-
const deserializeHelper = async (llm, tools, data, fromLLMAndTools, fromConstructor) => {
|
|
1
|
+
import { LLMChain } from "../chains/index.js";
|
|
2
|
+
import { resolveConfigFromFile } from "../util/index.js";
|
|
3
|
+
export const deserializeHelper = async (llm, tools, data, fromLLMAndTools, fromConstructor) => {
|
|
7
4
|
if (data.load_from_llm_and_tools) {
|
|
8
5
|
if (!llm) {
|
|
9
6
|
throw new Error("Loading from llm and tools, llm must be provided.");
|
|
@@ -13,9 +10,8 @@ const deserializeHelper = async (llm, tools, data, fromLLMAndTools, fromConstruc
|
|
|
13
10
|
}
|
|
14
11
|
return fromLLMAndTools(llm, tools, data);
|
|
15
12
|
}
|
|
16
|
-
const serializedLLMChain =
|
|
17
|
-
const llmChain = await
|
|
13
|
+
const serializedLLMChain = await resolveConfigFromFile("llm_chain", data);
|
|
14
|
+
const llmChain = await LLMChain.deserialize(serializedLLMChain);
|
|
18
15
|
return fromConstructor({ ...data, llmChain });
|
|
19
16
|
};
|
|
20
|
-
exports.deserializeHelper = deserializeHelper;
|
|
21
17
|
//# sourceMappingURL=helpers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../agents/helpers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/agents/helpers.ts"],"names":[],"mappings":"AAGA,OAAO,EAAsB,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAEzD,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,EAMpC,GAAwB,EACxB,KAAyB,EACzB,IAA+B,EAC/B,eAA4D,EAC5D,eAA+B,EACnB,EAAE;IACd,IAAI,IAAI,CAAC,uBAAuB,EAAE;QAChC,IAAI,CAAC,GAAG,EAAE;YACR,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;SACtE;QAED,IAAI,CAAC,KAAK,EAAE;YACV,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;SACxE;QAED,OAAO,eAAe,CAAC,GAAG,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;KAC1C;IAED,MAAM,kBAAkB,GAAG,MAAM,qBAAqB,CAGpD,WAAW,EAAE,IAAI,CAAC,CAAC;IACrB,MAAM,QAAQ,GAAG,MAAM,QAAQ,CAAC,WAAW,CAAC,kBAAkB,CAAC,CAAC;IAChE,OAAO,eAAe,CAAC,EAAE,GAAG,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;AAChD,CAAC,CAAC"}
|
package/dist/agents/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
export { AgentAction, AgentFinish, AgentStep, StoppingMethod, SerializedAgentT, } from "./types";
|
|
2
|
-
export { Agent, StaticAgent, staticImplements, AgentInput } from "./agent";
|
|
3
|
-
export { AgentExecutor } from "./executor";
|
|
4
|
-
export { ZeroShotAgent, SerializedZeroShotAgent } from "./mrkl";
|
|
5
|
-
export { Tool } from "./tools";
|
|
6
|
-
export { initializeAgentExecutor } from "./initialize";
|
|
7
|
-
export { loadAgent } from "./load";
|
|
1
|
+
export { AgentAction, AgentFinish, AgentStep, StoppingMethod, SerializedAgentT, } from "./types.js";
|
|
2
|
+
export { Agent, StaticAgent, staticImplements, AgentInput } from "./agent.js";
|
|
3
|
+
export { AgentExecutor } from "./executor.js";
|
|
4
|
+
export { ZeroShotAgent, SerializedZeroShotAgent } from "./mrkl/index.js";
|
|
5
|
+
export { Tool } from "./tools/index.js";
|
|
6
|
+
export { initializeAgentExecutor } from "./initialize.js";
|
|
7
|
+
export { loadAgent } from "./load.js";
|
|
8
|
+
export { SqlToolkit, JsonToolkit, RequestsToolkit, OpenApiToolkit, createSqlAgent, createJsonAgent, createOpenApiAgent, } from "./agent_toolkits/index.js";
|
package/dist/agents/index.js
CHANGED
|
@@ -1,17 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
Object.defineProperty(exports, "AgentExecutor", { enumerable: true, get: function () { return executor_1.AgentExecutor; } });
|
|
9
|
-
var mrkl_1 = require("./mrkl");
|
|
10
|
-
Object.defineProperty(exports, "ZeroShotAgent", { enumerable: true, get: function () { return mrkl_1.ZeroShotAgent; } });
|
|
11
|
-
var tools_1 = require("./tools");
|
|
12
|
-
Object.defineProperty(exports, "Tool", { enumerable: true, get: function () { return tools_1.Tool; } });
|
|
13
|
-
var initialize_1 = require("./initialize");
|
|
14
|
-
Object.defineProperty(exports, "initializeAgentExecutor", { enumerable: true, get: function () { return initialize_1.initializeAgentExecutor; } });
|
|
15
|
-
var load_1 = require("./load");
|
|
16
|
-
Object.defineProperty(exports, "loadAgent", { enumerable: true, get: function () { return load_1.loadAgent; } });
|
|
1
|
+
export { Agent, staticImplements } from "./agent.js";
|
|
2
|
+
export { AgentExecutor } from "./executor.js";
|
|
3
|
+
export { ZeroShotAgent } from "./mrkl/index.js";
|
|
4
|
+
export { Tool } from "./tools/index.js";
|
|
5
|
+
export { initializeAgentExecutor } from "./initialize.js";
|
|
6
|
+
export { loadAgent } from "./load.js";
|
|
7
|
+
export { SqlToolkit, JsonToolkit, RequestsToolkit, OpenApiToolkit, createSqlAgent, createJsonAgent, createOpenApiAgent, } from "./agent_toolkits/index.js";
|
|
17
8
|
//# sourceMappingURL=index.js.map
|
package/dist/agents/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../agents/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/agents/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,EAAe,gBAAgB,EAAc,MAAM,YAAY,CAAC;AAC9E,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,aAAa,EAA2B,MAAM,iBAAiB,CAAC;AACzE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAE1D,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,OAAO,EACL,UAAU,EACV,WAAW,EACX,eAAe,EACf,cAAc,EACd,cAAc,EACd,eAAe,EACf,kBAAkB,GACnB,MAAM,2BAA2B,CAAC"}
|