langchain 0.0.156 → 0.0.158
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/chains/graph_qa/cypher.cjs +1 -0
- package/chains/graph_qa/cypher.d.ts +1 -0
- package/chains/graph_qa/cypher.js +1 -0
- package/dist/agents/index.d.ts +12 -12
- package/dist/agents/toolkits/index.d.ts +2 -2
- package/dist/cache/upstash_redis.cjs +1 -1
- package/dist/cache/upstash_redis.js +1 -1
- package/dist/callbacks/index.d.ts +3 -3
- package/dist/chains/graph_qa/cypher.cjs +151 -0
- package/dist/chains/graph_qa/cypher.d.ts +45 -0
- package/dist/chains/graph_qa/cypher.js +147 -0
- package/dist/chains/graph_qa/prompts.cjs +34 -0
- package/dist/chains/graph_qa/prompts.d.ts +9 -0
- package/dist/chains/graph_qa/prompts.js +31 -0
- package/dist/chains/index.d.ts +19 -19
- package/dist/chains/index.js +2 -2
- package/dist/chains/openai_functions/index.d.ts +3 -3
- package/dist/chains/query_constructor/index.d.ts +1 -1
- package/dist/chat_models/googlevertexai/index.cjs +1 -3
- package/dist/chat_models/googlevertexai/index.d.ts +1 -1
- package/dist/chat_models/googlevertexai/index.js +0 -1
- package/dist/chat_models/googlevertexai/web.cjs +1 -3
- package/dist/chat_models/googlevertexai/web.d.ts +1 -1
- package/dist/chat_models/googlevertexai/web.js +0 -1
- package/dist/chat_models/openai.d.ts +1 -1
- package/dist/experimental/autogpt/index.d.ts +3 -3
- package/dist/experimental/babyagi/index.d.ts +1 -1
- package/dist/experimental/plan_and_execute/index.d.ts +1 -1
- package/dist/graphs/neo4j_graph.cjs +112 -0
- package/dist/graphs/neo4j_graph.d.ts +18 -0
- package/dist/graphs/neo4j_graph.js +105 -0
- package/dist/llms/openai-chat.d.ts +1 -1
- package/dist/llms/openai.d.ts +1 -1
- package/dist/load/import_constants.cjs +2 -0
- package/dist/load/import_constants.js +2 -0
- package/dist/memory/index.d.ts +8 -8
- package/dist/memory/index.js +1 -1
- package/dist/output_parsers/index.d.ts +3 -3
- package/dist/prompts/index.d.ts +8 -8
- package/dist/retrievers/remote/index.d.ts +3 -3
- package/dist/schema/runnable/index.d.ts +3 -3
- package/dist/sql_db.d.ts +1 -1
- package/dist/tools/index.d.ts +12 -12
- package/graphs/neo4j_graph.cjs +1 -0
- package/graphs/neo4j_graph.d.ts +1 -0
- package/graphs/neo4j_graph.js +1 -0
- package/package.json +25 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('../../dist/chains/graph_qa/cypher.cjs');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../../dist/chains/graph_qa/cypher.js'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../../dist/chains/graph_qa/cypher.js'
|
package/dist/agents/index.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
export { Agent, AgentArgs, BaseSingleActionAgent, LLMSingleActionAgent, LLMSingleActionAgentInput, OutputParserArgs, } from "./agent.js";
|
|
2
|
-
export { JsonToolkit, OpenApiToolkit, RequestsToolkit, VectorStoreInfo, VectorStoreRouterToolkit, VectorStoreToolkit, ZapierToolKit, createJsonAgent, createOpenApiAgent, createVectorStoreAgent, createVectorStoreRouterAgent, } from "./toolkits/index.js";
|
|
1
|
+
export { Agent, type AgentArgs, BaseSingleActionAgent, LLMSingleActionAgent, type LLMSingleActionAgentInput, type OutputParserArgs, } from "./agent.js";
|
|
2
|
+
export { JsonToolkit, OpenApiToolkit, RequestsToolkit, type VectorStoreInfo, VectorStoreRouterToolkit, VectorStoreToolkit, ZapierToolKit, createJsonAgent, createOpenApiAgent, createVectorStoreAgent, createVectorStoreRouterAgent, } from "./toolkits/index.js";
|
|
3
3
|
export { Toolkit } from "./toolkits/base.js";
|
|
4
|
-
export { ChatAgent, ChatAgentInput, ChatCreatePromptArgs, } from "./chat/index.js";
|
|
4
|
+
export { ChatAgent, type ChatAgentInput, type ChatCreatePromptArgs, } from "./chat/index.js";
|
|
5
5
|
export { ChatAgentOutputParser } from "./chat/outputParser.js";
|
|
6
|
-
export { ChatConversationalAgent, ChatConversationalAgentInput, ChatConversationalCreatePromptArgs, } from "./chat_convo/index.js";
|
|
7
|
-
export { ChatConversationalAgentOutputParser, ChatConversationalAgentOutputParserArgs, ChatConversationalAgentOutputParserWithRetries, ChatConversationalAgentOutputParserFormatInstructionsOptions, } from "./chat_convo/outputParser.js";
|
|
8
|
-
export { AgentExecutor, AgentExecutorInput } from "./executor.js";
|
|
9
|
-
export { initializeAgentExecutor, initializeAgentExecutorWithOptions, InitializeAgentExecutorOptions, } from "./initialize.js";
|
|
10
|
-
export { ZeroShotAgent, ZeroShotAgentInput, ZeroShotCreatePromptArgs, } from "./mrkl/index.js";
|
|
6
|
+
export { ChatConversationalAgent, type ChatConversationalAgentInput, type ChatConversationalCreatePromptArgs, } from "./chat_convo/index.js";
|
|
7
|
+
export { ChatConversationalAgentOutputParser, type ChatConversationalAgentOutputParserArgs, ChatConversationalAgentOutputParserWithRetries, type ChatConversationalAgentOutputParserFormatInstructionsOptions, } from "./chat_convo/outputParser.js";
|
|
8
|
+
export { AgentExecutor, type AgentExecutorInput } from "./executor.js";
|
|
9
|
+
export { initializeAgentExecutor, initializeAgentExecutorWithOptions, type InitializeAgentExecutorOptions, } from "./initialize.js";
|
|
10
|
+
export { ZeroShotAgent, type ZeroShotAgentInput, type ZeroShotCreatePromptArgs, } from "./mrkl/index.js";
|
|
11
11
|
export { ZeroShotAgentOutputParser } from "./mrkl/outputParser.js";
|
|
12
|
-
export { AgentActionOutputParser, AgentInput, SerializedAgent, SerializedAgentT, SerializedZeroShotAgent, StoppingMethod, } from "./types.js";
|
|
13
|
-
export { StructuredChatAgent, StructuredChatAgentInput, StructuredChatCreatePromptArgs, } from "./structured_chat/index.js";
|
|
14
|
-
export { StructuredChatOutputParser, StructuredChatOutputParserArgs, StructuredChatOutputParserWithRetries, } from "./structured_chat/outputParser.js";
|
|
15
|
-
export { OpenAIAgent, OpenAIAgentInput, OpenAIAgentCreatePromptArgs, } from "./openai/index.js";
|
|
12
|
+
export { AgentActionOutputParser, type AgentInput, type SerializedAgent, type SerializedAgentT, type SerializedZeroShotAgent, type StoppingMethod, } from "./types.js";
|
|
13
|
+
export { StructuredChatAgent, type StructuredChatAgentInput, type StructuredChatCreatePromptArgs, } from "./structured_chat/index.js";
|
|
14
|
+
export { StructuredChatOutputParser, type StructuredChatOutputParserArgs, StructuredChatOutputParserWithRetries, } from "./structured_chat/outputParser.js";
|
|
15
|
+
export { OpenAIAgent, type OpenAIAgentInput, type OpenAIAgentCreatePromptArgs, } from "./openai/index.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { JsonToolkit, createJsonAgent } from "./json/json.js";
|
|
2
2
|
export { RequestsToolkit, OpenApiToolkit, createOpenApiAgent, } from "./openapi/openapi.js";
|
|
3
|
-
export { VectorStoreInfo, VectorStoreToolkit, VectorStoreRouterToolkit, createVectorStoreAgent, createVectorStoreRouterAgent, } from "./vectorstore/vectorstore.js";
|
|
3
|
+
export { type VectorStoreInfo, VectorStoreToolkit, VectorStoreRouterToolkit, createVectorStoreAgent, createVectorStoreRouterAgent, } from "./vectorstore/vectorstore.js";
|
|
4
4
|
export { ZapierToolKit } from "./zapier/zapier.js";
|
|
5
5
|
export { createRetrieverTool } from "./conversational_retrieval/tool.js";
|
|
6
|
-
export { createConversationalRetrievalAgent, ConversationalRetrievalAgentOptions, } from "./conversational_retrieval/openai_functions.js";
|
|
6
|
+
export { createConversationalRetrievalAgent, type ConversationalRetrievalAgentOptions, } from "./conversational_retrieval/openai_functions.js";
|
|
7
7
|
export { OpenAIAgentTokenBufferMemory } from "./conversational_retrieval/token_buffer_memory.js";
|
|
@@ -37,7 +37,7 @@ class UpstashRedisCache extends index_js_1.BaseCache {
|
|
|
37
37
|
let value = await this.redisClient.get(key);
|
|
38
38
|
const generations = [];
|
|
39
39
|
while (value) {
|
|
40
|
-
generations.push((0, base_js_1.deserializeStoredGeneration)(
|
|
40
|
+
generations.push((0, base_js_1.deserializeStoredGeneration)(value));
|
|
41
41
|
idx += 1;
|
|
42
42
|
key = (0, base_js_1.getCacheKey)(prompt, llmKey, String(idx));
|
|
43
43
|
value = await this.redisClient.get(key);
|
|
@@ -34,7 +34,7 @@ export class UpstashRedisCache extends BaseCache {
|
|
|
34
34
|
let value = await this.redisClient.get(key);
|
|
35
35
|
const generations = [];
|
|
36
36
|
while (value) {
|
|
37
|
-
generations.push(deserializeStoredGeneration(
|
|
37
|
+
generations.push(deserializeStoredGeneration(value));
|
|
38
38
|
idx += 1;
|
|
39
39
|
key = getCacheKey(prompt, llmKey, String(idx));
|
|
40
40
|
value = await this.redisClient.get(key);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export { BaseCallbackHandler, CallbackHandlerMethods, BaseCallbackHandlerInput, NewTokenIndices, } from "./base.js";
|
|
2
|
-
export { Run, RunType, BaseTracer } from "./handlers/tracer.js";
|
|
1
|
+
export { BaseCallbackHandler, type CallbackHandlerMethods, type BaseCallbackHandlerInput, type NewTokenIndices, } from "./base.js";
|
|
2
|
+
export { type Run, type RunType, BaseTracer } from "./handlers/tracer.js";
|
|
3
3
|
export { ConsoleCallbackHandler } from "./handlers/console.js";
|
|
4
4
|
export { RunCollectorCallbackHandler } from "./handlers/run_collector.js";
|
|
5
5
|
export { LangChainTracer } from "./handlers/tracer_langchain.js";
|
|
6
6
|
export { LangChainTracerV1 } from "./handlers/tracer_langchain_v1.js";
|
|
7
7
|
export { getTracingCallbackHandler, getTracingV2CallbackHandler, } from "./handlers/initialize.js";
|
|
8
|
-
export { CallbackManager, CallbackManagerForRetrieverRun, CallbackManagerForChainRun, CallbackManagerForLLMRun, CallbackManagerForToolRun, CallbackManagerOptions, Callbacks, TraceGroup, traceAsGroup, } from "./manager.js";
|
|
8
|
+
export { CallbackManager, CallbackManagerForRetrieverRun, CallbackManagerForChainRun, CallbackManagerForLLMRun, CallbackManagerForToolRun, type CallbackManagerOptions, type Callbacks, TraceGroup, traceAsGroup, } from "./manager.js";
|
|
9
9
|
export { awaitAllCallbacks, consumeCallback } from "./promises.js";
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GraphCypherQAChain = exports.INTERMEDIATE_STEPS_KEY = void 0;
|
|
4
|
+
const llm_chain_js_1 = require("../../chains/llm_chain.cjs");
|
|
5
|
+
const base_js_1 = require("../base.cjs");
|
|
6
|
+
const prompts_js_1 = require("./prompts.cjs");
|
|
7
|
+
exports.INTERMEDIATE_STEPS_KEY = "intermediateSteps";
|
|
8
|
+
class GraphCypherQAChain extends base_js_1.BaseChain {
|
|
9
|
+
constructor(props) {
|
|
10
|
+
super(props);
|
|
11
|
+
Object.defineProperty(this, "graph", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
configurable: true,
|
|
14
|
+
writable: true,
|
|
15
|
+
value: void 0
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(this, "cypherGenerationChain", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
configurable: true,
|
|
20
|
+
writable: true,
|
|
21
|
+
value: void 0
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(this, "qaChain", {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
configurable: true,
|
|
26
|
+
writable: true,
|
|
27
|
+
value: void 0
|
|
28
|
+
});
|
|
29
|
+
Object.defineProperty(this, "inputKey", {
|
|
30
|
+
enumerable: true,
|
|
31
|
+
configurable: true,
|
|
32
|
+
writable: true,
|
|
33
|
+
value: "query"
|
|
34
|
+
});
|
|
35
|
+
Object.defineProperty(this, "outputKey", {
|
|
36
|
+
enumerable: true,
|
|
37
|
+
configurable: true,
|
|
38
|
+
writable: true,
|
|
39
|
+
value: "result"
|
|
40
|
+
});
|
|
41
|
+
Object.defineProperty(this, "topK", {
|
|
42
|
+
enumerable: true,
|
|
43
|
+
configurable: true,
|
|
44
|
+
writable: true,
|
|
45
|
+
value: 10
|
|
46
|
+
});
|
|
47
|
+
Object.defineProperty(this, "returnDirect", {
|
|
48
|
+
enumerable: true,
|
|
49
|
+
configurable: true,
|
|
50
|
+
writable: true,
|
|
51
|
+
value: false
|
|
52
|
+
});
|
|
53
|
+
Object.defineProperty(this, "returnIntermediateSteps", {
|
|
54
|
+
enumerable: true,
|
|
55
|
+
configurable: true,
|
|
56
|
+
writable: true,
|
|
57
|
+
value: false
|
|
58
|
+
});
|
|
59
|
+
const { graph, cypherGenerationChain, qaChain, inputKey, outputKey, topK, returnIntermediateSteps, returnDirect, } = props;
|
|
60
|
+
this.graph = graph;
|
|
61
|
+
this.cypherGenerationChain = cypherGenerationChain;
|
|
62
|
+
this.qaChain = qaChain;
|
|
63
|
+
if (inputKey) {
|
|
64
|
+
this.inputKey = inputKey;
|
|
65
|
+
}
|
|
66
|
+
if (outputKey) {
|
|
67
|
+
this.outputKey = outputKey;
|
|
68
|
+
}
|
|
69
|
+
if (topK) {
|
|
70
|
+
this.topK = topK;
|
|
71
|
+
}
|
|
72
|
+
if (returnIntermediateSteps) {
|
|
73
|
+
this.returnIntermediateSteps = returnIntermediateSteps;
|
|
74
|
+
}
|
|
75
|
+
if (returnDirect) {
|
|
76
|
+
this.returnDirect = returnDirect;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
_chainType() {
|
|
80
|
+
return "graph_cypher_chain";
|
|
81
|
+
}
|
|
82
|
+
get inputKeys() {
|
|
83
|
+
return [this.inputKey];
|
|
84
|
+
}
|
|
85
|
+
get outputKeys() {
|
|
86
|
+
return [this.outputKey];
|
|
87
|
+
}
|
|
88
|
+
static fromLLM(props) {
|
|
89
|
+
const { graph, qaPrompt = prompts_js_1.CYPHER_QA_PROMPT, cypherPrompt = prompts_js_1.CYPHER_GENERATION_PROMPT, llm, cypherLLM, qaLLM, returnIntermediateSteps = false, returnDirect = false, } = props;
|
|
90
|
+
if (!cypherLLM && !llm) {
|
|
91
|
+
throw new Error("Either 'llm' or 'cypherLLM' parameters must be provided");
|
|
92
|
+
}
|
|
93
|
+
if (!qaLLM && !llm) {
|
|
94
|
+
throw new Error("Either 'llm' or 'qaLLM' parameters must be provided");
|
|
95
|
+
}
|
|
96
|
+
if (cypherLLM && qaLLM && llm) {
|
|
97
|
+
throw new Error("You can specify up to two of 'cypherLLM', 'qaLLM', and 'llm', but not all three simultaneously.");
|
|
98
|
+
}
|
|
99
|
+
const qaChain = new llm_chain_js_1.LLMChain({
|
|
100
|
+
llm: (qaLLM || llm),
|
|
101
|
+
prompt: qaPrompt,
|
|
102
|
+
});
|
|
103
|
+
const cypherGenerationChain = new llm_chain_js_1.LLMChain({
|
|
104
|
+
llm: (cypherLLM || llm),
|
|
105
|
+
prompt: cypherPrompt,
|
|
106
|
+
});
|
|
107
|
+
return new GraphCypherQAChain({
|
|
108
|
+
cypherGenerationChain,
|
|
109
|
+
qaChain,
|
|
110
|
+
graph,
|
|
111
|
+
returnIntermediateSteps,
|
|
112
|
+
returnDirect,
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
extractCypher(text) {
|
|
116
|
+
const pattern = /```(.*?)```/s;
|
|
117
|
+
const matches = text.match(pattern);
|
|
118
|
+
return matches ? matches[1] : text;
|
|
119
|
+
}
|
|
120
|
+
async _call(values, runManager) {
|
|
121
|
+
const callbacks = runManager?.getChild();
|
|
122
|
+
const question = values[this.inputKey];
|
|
123
|
+
const intermediateSteps = [];
|
|
124
|
+
const generatedCypher = await this.cypherGenerationChain.call({ question, schema: this.graph.getSchema() }, callbacks);
|
|
125
|
+
const extractedCypher = this.extractCypher(generatedCypher.text);
|
|
126
|
+
await runManager?.handleText(`Generated Cypher:\n`);
|
|
127
|
+
await runManager?.handleText(`${extractedCypher} green\n`);
|
|
128
|
+
intermediateSteps.push({ query: extractedCypher });
|
|
129
|
+
let chainResult;
|
|
130
|
+
const context = await this.graph.query(extractedCypher, {
|
|
131
|
+
topK: this.topK,
|
|
132
|
+
});
|
|
133
|
+
if (this.returnDirect) {
|
|
134
|
+
chainResult = { [this.outputKey]: context };
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
await runManager?.handleText("Full Context:\n");
|
|
138
|
+
await runManager?.handleText(`${context} green\n`);
|
|
139
|
+
intermediateSteps.push({ context });
|
|
140
|
+
const result = await this.qaChain.call({ question, context: JSON.stringify(context) }, callbacks);
|
|
141
|
+
chainResult = {
|
|
142
|
+
[this.outputKey]: result[this.qaChain.outputKey],
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
if (this.returnIntermediateSteps) {
|
|
146
|
+
chainResult[exports.INTERMEDIATE_STEPS_KEY] = intermediateSteps;
|
|
147
|
+
}
|
|
148
|
+
return chainResult;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
exports.GraphCypherQAChain = GraphCypherQAChain;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { LLMChain } from "../../chains/llm_chain.js";
|
|
2
|
+
import { ChainValues } from "../../schema/index.js";
|
|
3
|
+
import { BasePromptTemplate } from "../../prompts/base.js";
|
|
4
|
+
import { BaseChain, ChainInputs } from "../base.js";
|
|
5
|
+
import { BaseLanguageModel } from "../../base_language/index.js";
|
|
6
|
+
import { CallbackManagerForChainRun } from "../../callbacks/manager.js";
|
|
7
|
+
import { Neo4jGraph } from "../../graphs/neo4j_graph.js";
|
|
8
|
+
export declare const INTERMEDIATE_STEPS_KEY = "intermediateSteps";
|
|
9
|
+
export interface GraphCypherQAChainInput extends ChainInputs {
|
|
10
|
+
graph: Neo4jGraph;
|
|
11
|
+
cypherGenerationChain: LLMChain;
|
|
12
|
+
qaChain: LLMChain;
|
|
13
|
+
inputKey?: string;
|
|
14
|
+
outputKey?: string;
|
|
15
|
+
topK?: number;
|
|
16
|
+
returnIntermediateSteps?: boolean;
|
|
17
|
+
returnDirect?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface FromLLMInput {
|
|
20
|
+
graph: Neo4jGraph;
|
|
21
|
+
llm?: BaseLanguageModel;
|
|
22
|
+
cypherLLM?: BaseLanguageModel;
|
|
23
|
+
qaLLM?: BaseLanguageModel;
|
|
24
|
+
qaPrompt?: BasePromptTemplate;
|
|
25
|
+
cypherPrompt?: BasePromptTemplate;
|
|
26
|
+
returnIntermediateSteps?: boolean;
|
|
27
|
+
returnDirect?: boolean;
|
|
28
|
+
}
|
|
29
|
+
export declare class GraphCypherQAChain extends BaseChain {
|
|
30
|
+
private graph;
|
|
31
|
+
private cypherGenerationChain;
|
|
32
|
+
private qaChain;
|
|
33
|
+
private inputKey;
|
|
34
|
+
private outputKey;
|
|
35
|
+
private topK;
|
|
36
|
+
private returnDirect;
|
|
37
|
+
private returnIntermediateSteps;
|
|
38
|
+
constructor(props: GraphCypherQAChainInput);
|
|
39
|
+
_chainType(): "graph_cypher_chain";
|
|
40
|
+
get inputKeys(): string[];
|
|
41
|
+
get outputKeys(): string[];
|
|
42
|
+
static fromLLM(props: FromLLMInput): GraphCypherQAChain;
|
|
43
|
+
private extractCypher;
|
|
44
|
+
_call(values: ChainValues, runManager?: CallbackManagerForChainRun): Promise<ChainValues>;
|
|
45
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { LLMChain } from "../../chains/llm_chain.js";
|
|
2
|
+
import { BaseChain } from "../base.js";
|
|
3
|
+
import { CYPHER_GENERATION_PROMPT, CYPHER_QA_PROMPT } from "./prompts.js";
|
|
4
|
+
export const INTERMEDIATE_STEPS_KEY = "intermediateSteps";
|
|
5
|
+
export class GraphCypherQAChain extends BaseChain {
|
|
6
|
+
constructor(props) {
|
|
7
|
+
super(props);
|
|
8
|
+
Object.defineProperty(this, "graph", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
configurable: true,
|
|
11
|
+
writable: true,
|
|
12
|
+
value: void 0
|
|
13
|
+
});
|
|
14
|
+
Object.defineProperty(this, "cypherGenerationChain", {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
configurable: true,
|
|
17
|
+
writable: true,
|
|
18
|
+
value: void 0
|
|
19
|
+
});
|
|
20
|
+
Object.defineProperty(this, "qaChain", {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
configurable: true,
|
|
23
|
+
writable: true,
|
|
24
|
+
value: void 0
|
|
25
|
+
});
|
|
26
|
+
Object.defineProperty(this, "inputKey", {
|
|
27
|
+
enumerable: true,
|
|
28
|
+
configurable: true,
|
|
29
|
+
writable: true,
|
|
30
|
+
value: "query"
|
|
31
|
+
});
|
|
32
|
+
Object.defineProperty(this, "outputKey", {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
configurable: true,
|
|
35
|
+
writable: true,
|
|
36
|
+
value: "result"
|
|
37
|
+
});
|
|
38
|
+
Object.defineProperty(this, "topK", {
|
|
39
|
+
enumerable: true,
|
|
40
|
+
configurable: true,
|
|
41
|
+
writable: true,
|
|
42
|
+
value: 10
|
|
43
|
+
});
|
|
44
|
+
Object.defineProperty(this, "returnDirect", {
|
|
45
|
+
enumerable: true,
|
|
46
|
+
configurable: true,
|
|
47
|
+
writable: true,
|
|
48
|
+
value: false
|
|
49
|
+
});
|
|
50
|
+
Object.defineProperty(this, "returnIntermediateSteps", {
|
|
51
|
+
enumerable: true,
|
|
52
|
+
configurable: true,
|
|
53
|
+
writable: true,
|
|
54
|
+
value: false
|
|
55
|
+
});
|
|
56
|
+
const { graph, cypherGenerationChain, qaChain, inputKey, outputKey, topK, returnIntermediateSteps, returnDirect, } = props;
|
|
57
|
+
this.graph = graph;
|
|
58
|
+
this.cypherGenerationChain = cypherGenerationChain;
|
|
59
|
+
this.qaChain = qaChain;
|
|
60
|
+
if (inputKey) {
|
|
61
|
+
this.inputKey = inputKey;
|
|
62
|
+
}
|
|
63
|
+
if (outputKey) {
|
|
64
|
+
this.outputKey = outputKey;
|
|
65
|
+
}
|
|
66
|
+
if (topK) {
|
|
67
|
+
this.topK = topK;
|
|
68
|
+
}
|
|
69
|
+
if (returnIntermediateSteps) {
|
|
70
|
+
this.returnIntermediateSteps = returnIntermediateSteps;
|
|
71
|
+
}
|
|
72
|
+
if (returnDirect) {
|
|
73
|
+
this.returnDirect = returnDirect;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
_chainType() {
|
|
77
|
+
return "graph_cypher_chain";
|
|
78
|
+
}
|
|
79
|
+
get inputKeys() {
|
|
80
|
+
return [this.inputKey];
|
|
81
|
+
}
|
|
82
|
+
get outputKeys() {
|
|
83
|
+
return [this.outputKey];
|
|
84
|
+
}
|
|
85
|
+
static fromLLM(props) {
|
|
86
|
+
const { graph, qaPrompt = CYPHER_QA_PROMPT, cypherPrompt = CYPHER_GENERATION_PROMPT, llm, cypherLLM, qaLLM, returnIntermediateSteps = false, returnDirect = false, } = props;
|
|
87
|
+
if (!cypherLLM && !llm) {
|
|
88
|
+
throw new Error("Either 'llm' or 'cypherLLM' parameters must be provided");
|
|
89
|
+
}
|
|
90
|
+
if (!qaLLM && !llm) {
|
|
91
|
+
throw new Error("Either 'llm' or 'qaLLM' parameters must be provided");
|
|
92
|
+
}
|
|
93
|
+
if (cypherLLM && qaLLM && llm) {
|
|
94
|
+
throw new Error("You can specify up to two of 'cypherLLM', 'qaLLM', and 'llm', but not all three simultaneously.");
|
|
95
|
+
}
|
|
96
|
+
const qaChain = new LLMChain({
|
|
97
|
+
llm: (qaLLM || llm),
|
|
98
|
+
prompt: qaPrompt,
|
|
99
|
+
});
|
|
100
|
+
const cypherGenerationChain = new LLMChain({
|
|
101
|
+
llm: (cypherLLM || llm),
|
|
102
|
+
prompt: cypherPrompt,
|
|
103
|
+
});
|
|
104
|
+
return new GraphCypherQAChain({
|
|
105
|
+
cypherGenerationChain,
|
|
106
|
+
qaChain,
|
|
107
|
+
graph,
|
|
108
|
+
returnIntermediateSteps,
|
|
109
|
+
returnDirect,
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
extractCypher(text) {
|
|
113
|
+
const pattern = /```(.*?)```/s;
|
|
114
|
+
const matches = text.match(pattern);
|
|
115
|
+
return matches ? matches[1] : text;
|
|
116
|
+
}
|
|
117
|
+
async _call(values, runManager) {
|
|
118
|
+
const callbacks = runManager?.getChild();
|
|
119
|
+
const question = values[this.inputKey];
|
|
120
|
+
const intermediateSteps = [];
|
|
121
|
+
const generatedCypher = await this.cypherGenerationChain.call({ question, schema: this.graph.getSchema() }, callbacks);
|
|
122
|
+
const extractedCypher = this.extractCypher(generatedCypher.text);
|
|
123
|
+
await runManager?.handleText(`Generated Cypher:\n`);
|
|
124
|
+
await runManager?.handleText(`${extractedCypher} green\n`);
|
|
125
|
+
intermediateSteps.push({ query: extractedCypher });
|
|
126
|
+
let chainResult;
|
|
127
|
+
const context = await this.graph.query(extractedCypher, {
|
|
128
|
+
topK: this.topK,
|
|
129
|
+
});
|
|
130
|
+
if (this.returnDirect) {
|
|
131
|
+
chainResult = { [this.outputKey]: context };
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
await runManager?.handleText("Full Context:\n");
|
|
135
|
+
await runManager?.handleText(`${context} green\n`);
|
|
136
|
+
intermediateSteps.push({ context });
|
|
137
|
+
const result = await this.qaChain.call({ question, context: JSON.stringify(context) }, callbacks);
|
|
138
|
+
chainResult = {
|
|
139
|
+
[this.outputKey]: result[this.qaChain.outputKey],
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
if (this.returnIntermediateSteps) {
|
|
143
|
+
chainResult[INTERMEDIATE_STEPS_KEY] = intermediateSteps;
|
|
144
|
+
}
|
|
145
|
+
return chainResult;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CYPHER_QA_PROMPT = exports.CYPHER_GENERATION_PROMPT = void 0;
|
|
4
|
+
const prompt_js_1 = require("../../prompts/prompt.cjs");
|
|
5
|
+
const CYPHER_GENERATION_TEMPLATE = `Task:Generate Cypher statement to query a graph database.
|
|
6
|
+
Instructions:
|
|
7
|
+
Use only the provided relationship types and properties in the schema.
|
|
8
|
+
Do not use any other relationship types or properties that are not provided.
|
|
9
|
+
Schema:
|
|
10
|
+
{schema}
|
|
11
|
+
Note: Do not include any explanations or apologies in your responses.
|
|
12
|
+
Do not respond to any questions that might ask anything else than for you to construct a Cypher statement.
|
|
13
|
+
Do not include any text except the generated Cypher statement.
|
|
14
|
+
|
|
15
|
+
The question is:
|
|
16
|
+
{question}`;
|
|
17
|
+
exports.CYPHER_GENERATION_PROMPT = new prompt_js_1.PromptTemplate({
|
|
18
|
+
template: CYPHER_GENERATION_TEMPLATE,
|
|
19
|
+
inputVariables: ["schema", "question"],
|
|
20
|
+
});
|
|
21
|
+
const CYPHER_QA_TEMPLATE = `You are an assistant that helps to form nice and human understandable answers.
|
|
22
|
+
The information part contains the provided information that you must use to construct an answer.
|
|
23
|
+
The provided information is authoritative, you must never doubt it or try to use your internal knowledge to correct it.
|
|
24
|
+
Make the answer sound as a response to the question. Do not mention that you based the result on the given information.
|
|
25
|
+
If the provided information is empty, say that you don't know the answer.
|
|
26
|
+
Information:
|
|
27
|
+
{context}
|
|
28
|
+
|
|
29
|
+
Question: {question}
|
|
30
|
+
Helpful Answer:`;
|
|
31
|
+
exports.CYPHER_QA_PROMPT = new prompt_js_1.PromptTemplate({
|
|
32
|
+
template: CYPHER_QA_TEMPLATE,
|
|
33
|
+
inputVariables: ["context", "question"],
|
|
34
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { PromptTemplate } from "../../prompts/prompt.js";
|
|
2
|
+
export declare const CYPHER_GENERATION_PROMPT: PromptTemplate<{
|
|
3
|
+
schema: any;
|
|
4
|
+
question: any;
|
|
5
|
+
}, any>;
|
|
6
|
+
export declare const CYPHER_QA_PROMPT: PromptTemplate<{
|
|
7
|
+
context: any;
|
|
8
|
+
question: any;
|
|
9
|
+
}, any>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { PromptTemplate } from "../../prompts/prompt.js";
|
|
2
|
+
const CYPHER_GENERATION_TEMPLATE = `Task:Generate Cypher statement to query a graph database.
|
|
3
|
+
Instructions:
|
|
4
|
+
Use only the provided relationship types and properties in the schema.
|
|
5
|
+
Do not use any other relationship types or properties that are not provided.
|
|
6
|
+
Schema:
|
|
7
|
+
{schema}
|
|
8
|
+
Note: Do not include any explanations or apologies in your responses.
|
|
9
|
+
Do not respond to any questions that might ask anything else than for you to construct a Cypher statement.
|
|
10
|
+
Do not include any text except the generated Cypher statement.
|
|
11
|
+
|
|
12
|
+
The question is:
|
|
13
|
+
{question}`;
|
|
14
|
+
export const CYPHER_GENERATION_PROMPT = /* #__PURE__ */ new PromptTemplate({
|
|
15
|
+
template: CYPHER_GENERATION_TEMPLATE,
|
|
16
|
+
inputVariables: ["schema", "question"],
|
|
17
|
+
});
|
|
18
|
+
const CYPHER_QA_TEMPLATE = `You are an assistant that helps to form nice and human understandable answers.
|
|
19
|
+
The information part contains the provided information that you must use to construct an answer.
|
|
20
|
+
The provided information is authoritative, you must never doubt it or try to use your internal knowledge to correct it.
|
|
21
|
+
Make the answer sound as a response to the question. Do not mention that you based the result on the given information.
|
|
22
|
+
If the provided information is empty, say that you don't know the answer.
|
|
23
|
+
Information:
|
|
24
|
+
{context}
|
|
25
|
+
|
|
26
|
+
Question: {question}
|
|
27
|
+
Helpful Answer:`;
|
|
28
|
+
export const CYPHER_QA_PROMPT = /* #__PURE__ */ new PromptTemplate({
|
|
29
|
+
template: CYPHER_QA_TEMPLATE,
|
|
30
|
+
inputVariables: ["context", "question"],
|
|
31
|
+
});
|
package/dist/chains/index.d.ts
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
export { BaseChain, ChainInputs } from "./base.js";
|
|
2
|
-
export { LLMChain, LLMChainInput } from "./llm_chain.js";
|
|
3
|
-
export { APIChain, APIChainInput, APIChainOptions } from "./api/api_chain.js";
|
|
1
|
+
export { BaseChain, type ChainInputs } from "./base.js";
|
|
2
|
+
export { LLMChain, type LLMChainInput } from "./llm_chain.js";
|
|
3
|
+
export { APIChain, type APIChainInput, type APIChainOptions, } from "./api/api_chain.js";
|
|
4
4
|
export { ConversationChain } from "./conversation.js";
|
|
5
|
-
export { SequentialChain, SequentialChainInput, SimpleSequentialChain, SimpleSequentialChainInput, } from "./sequential_chain.js";
|
|
6
|
-
export { StuffDocumentsChain, StuffDocumentsChainInput, MapReduceDocumentsChain, MapReduceDocumentsChainInput, RefineDocumentsChain, RefineDocumentsChainInput, } from "./combine_docs_chain.js";
|
|
7
|
-
export { ChatVectorDBQAChain, ChatVectorDBQAChainInput, } from "./chat_vector_db_chain.js";
|
|
8
|
-
export { AnalyzeDocumentChain, AnalyzeDocumentChainInput, } from "./analyze_documents_chain.js";
|
|
9
|
-
export { VectorDBQAChain, VectorDBQAChainInput } from "./vector_db_qa.js";
|
|
10
|
-
export { loadQAChain, QAChainParams, loadQAStuffChain, StuffQAChainParams, loadQAMapReduceChain, MapReduceQAChainParams, loadQARefineChain, RefineQAChainParams, } from "./question_answering/load.js";
|
|
11
|
-
export { loadSummarizationChain, SummarizationChainParams, } from "./summarization/load.js";
|
|
12
|
-
export { ConversationalRetrievalQAChain, ConversationalRetrievalQAChainInput, } from "./conversational_retrieval_chain.js";
|
|
13
|
-
export { RetrievalQAChain, RetrievalQAChainInput } from "./retrieval_qa.js";
|
|
14
|
-
export { ConstitutionalChainInput, ConstitutionalChain, } from "./constitutional_ai/constitutional_chain.js";
|
|
5
|
+
export { SequentialChain, type SequentialChainInput, SimpleSequentialChain, type SimpleSequentialChainInput, } from "./sequential_chain.js";
|
|
6
|
+
export { StuffDocumentsChain, type StuffDocumentsChainInput, MapReduceDocumentsChain, type MapReduceDocumentsChainInput, RefineDocumentsChain, type RefineDocumentsChainInput, } from "./combine_docs_chain.js";
|
|
7
|
+
export { ChatVectorDBQAChain, type ChatVectorDBQAChainInput, } from "./chat_vector_db_chain.js";
|
|
8
|
+
export { AnalyzeDocumentChain, type AnalyzeDocumentChainInput, } from "./analyze_documents_chain.js";
|
|
9
|
+
export { VectorDBQAChain, type VectorDBQAChainInput } from "./vector_db_qa.js";
|
|
10
|
+
export { loadQAChain, type QAChainParams, loadQAStuffChain, type StuffQAChainParams, loadQAMapReduceChain, type MapReduceQAChainParams, loadQARefineChain, type RefineQAChainParams, } from "./question_answering/load.js";
|
|
11
|
+
export { loadSummarizationChain, type SummarizationChainParams, } from "./summarization/load.js";
|
|
12
|
+
export { ConversationalRetrievalQAChain, type ConversationalRetrievalQAChainInput, } from "./conversational_retrieval_chain.js";
|
|
13
|
+
export { RetrievalQAChain, type RetrievalQAChainInput, } from "./retrieval_qa.js";
|
|
14
|
+
export { type ConstitutionalChainInput, ConstitutionalChain, } from "./constitutional_ai/constitutional_chain.js";
|
|
15
15
|
export { ConstitutionalPrinciple, PRINCIPLES, } from "./constitutional_ai/constitutional_principle.js";
|
|
16
|
-
export { SerializedLLMChain, SerializedSequentialChain, SerializedSimpleSequentialChain, SerializedAnalyzeDocumentChain, SerializedAPIChain, SerializedBaseChain, SerializedChatVectorDBQAChain, SerializedMapReduceDocumentsChain, SerializedStuffDocumentsChain, SerializedVectorDBQAChain, SerializedRefineDocumentsChain, } from "./serde.js";
|
|
16
|
+
export type { SerializedLLMChain, SerializedSequentialChain, SerializedSimpleSequentialChain, SerializedAnalyzeDocumentChain, SerializedAPIChain, SerializedBaseChain, SerializedChatVectorDBQAChain, SerializedMapReduceDocumentsChain, SerializedStuffDocumentsChain, SerializedVectorDBQAChain, SerializedRefineDocumentsChain, } from "./serde.js";
|
|
17
17
|
export { OpenAIModerationChain } from "./openai_moderation.js";
|
|
18
|
-
export { MultiRouteChain, MultiRouteChainInput, RouterChain, } from "./router/multi_route.js";
|
|
19
|
-
export { LLMRouterChain, LLMRouterChainInput, RouterOutputSchema, } from "./router/llm_router.js";
|
|
18
|
+
export { MultiRouteChain, type MultiRouteChainInput, RouterChain, } from "./router/multi_route.js";
|
|
19
|
+
export { LLMRouterChain, type LLMRouterChainInput, type RouterOutputSchema, } from "./router/llm_router.js";
|
|
20
20
|
export { MultiPromptChain } from "./router/multi_prompt.js";
|
|
21
21
|
export { MultiRetrievalQAChain } from "./router/multi_retrieval_qa.js";
|
|
22
|
-
export { TransformChain, TransformChainFields } from "./transform.js";
|
|
22
|
+
export { TransformChain, type TransformChainFields } from "./transform.js";
|
|
23
23
|
export { createExtractionChain, createExtractionChainFromZod, } from "./openai_functions/extraction.js";
|
|
24
|
-
export { TaggingChainOptions, createTaggingChain, createTaggingChainFromZod, } from "./openai_functions/tagging.js";
|
|
25
|
-
export { OpenAPIChainOptions, createOpenAPIChain, } from "./openai_functions/openapi.js";
|
|
24
|
+
export { type TaggingChainOptions, createTaggingChain, createTaggingChainFromZod, } from "./openai_functions/tagging.js";
|
|
25
|
+
export { type OpenAPIChainOptions, createOpenAPIChain, } from "./openai_functions/openapi.js";
|
package/dist/chains/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { BaseChain } from "./base.js";
|
|
2
2
|
export { LLMChain } from "./llm_chain.js";
|
|
3
|
-
export { APIChain } from "./api/api_chain.js";
|
|
3
|
+
export { APIChain, } from "./api/api_chain.js";
|
|
4
4
|
export { ConversationChain } from "./conversation.js";
|
|
5
5
|
export { SequentialChain, SimpleSequentialChain, } from "./sequential_chain.js";
|
|
6
6
|
export { StuffDocumentsChain, MapReduceDocumentsChain, RefineDocumentsChain, } from "./combine_docs_chain.js";
|
|
@@ -10,7 +10,7 @@ export { VectorDBQAChain } from "./vector_db_qa.js";
|
|
|
10
10
|
export { loadQAChain, loadQAStuffChain, loadQAMapReduceChain, loadQARefineChain, } from "./question_answering/load.js";
|
|
11
11
|
export { loadSummarizationChain, } from "./summarization/load.js";
|
|
12
12
|
export { ConversationalRetrievalQAChain, } from "./conversational_retrieval_chain.js";
|
|
13
|
-
export { RetrievalQAChain } from "./retrieval_qa.js";
|
|
13
|
+
export { RetrievalQAChain, } from "./retrieval_qa.js";
|
|
14
14
|
export { ConstitutionalChain, } from "./constitutional_ai/constitutional_chain.js";
|
|
15
15
|
export { ConstitutionalPrinciple, PRINCIPLES, } from "./constitutional_ai/constitutional_principle.js";
|
|
16
16
|
export { OpenAIModerationChain } from "./openai_moderation.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { createExtractionChain, createExtractionChainFromZod, } from "./extraction.js";
|
|
2
|
-
export { TaggingChainOptions, createTaggingChain, createTaggingChainFromZod, } from "./tagging.js";
|
|
3
|
-
export { OpenAPIChainOptions, createOpenAPIChain } from "./openapi.js";
|
|
4
|
-
export { StructuredOutputChainInput, createStructuredOutputChain, createStructuredOutputChainFromZod, } from "./structured_output.js";
|
|
2
|
+
export { type TaggingChainOptions, createTaggingChain, createTaggingChainFromZod, } from "./tagging.js";
|
|
3
|
+
export { type OpenAPIChainOptions, createOpenAPIChain } from "./openapi.js";
|
|
4
|
+
export { type StructuredOutputChainInput, createStructuredOutputChain, createStructuredOutputChainFromZod, } from "./structured_output.js";
|
|
@@ -7,7 +7,7 @@ import { LLMChain } from "../llm_chain.js";
|
|
|
7
7
|
import { BaseLanguageModel } from "../../base_language/index.js";
|
|
8
8
|
import { AsymmetricStructuredOutputParser } from "../../output_parsers/structured.js";
|
|
9
9
|
import { AttributeInfo } from "../../schema/query_constructor.js";
|
|
10
|
-
export { QueryTransformer, TraverseType };
|
|
10
|
+
export { QueryTransformer, type TraverseType };
|
|
11
11
|
export { DEFAULT_EXAMPLES, DEFAULT_PREFIX, DEFAULT_SCHEMA, DEFAULT_SUFFIX, EXAMPLE_PROMPT, };
|
|
12
12
|
declare const queryInputSchema: z.ZodObject<{
|
|
13
13
|
query: z.ZodString;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.ChatGoogleVertexAI = void 0;
|
|
4
4
|
const google_auth_library_1 = require("google-auth-library");
|
|
5
5
|
const common_js_1 = require("./common.cjs");
|
|
6
6
|
const googlevertexai_connection_js_1 = require("../../util/googlevertexai-connection.cjs");
|
|
@@ -32,5 +32,3 @@ class ChatGoogleVertexAI extends common_js_1.BaseChatGoogleVertexAI {
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
exports.ChatGoogleVertexAI = ChatGoogleVertexAI;
|
|
35
|
-
var common_js_2 = require("./common.cjs");
|
|
36
|
-
Object.defineProperty(exports, "GoogleVertexAIChatMessage", { enumerable: true, get: function () { return common_js_2.GoogleVertexAIChatMessage; } });
|
|
@@ -18,4 +18,4 @@ export declare class ChatGoogleVertexAI extends BaseChatGoogleVertexAI<GoogleAut
|
|
|
18
18
|
static lc_name(): string;
|
|
19
19
|
constructor(fields?: GoogleVertexAIChatInput<GoogleAuthOptions>);
|
|
20
20
|
}
|
|
21
|
-
export { ChatExample, GoogleVertexAIChatAuthor, GoogleVertexAIChatInput, GoogleVertexAIChatInstance, GoogleVertexAIChatMessage, GoogleVertexAIChatMessageFields, GoogleVertexAIChatPrediction, } from "./common.js";
|
|
21
|
+
export type { ChatExample, GoogleVertexAIChatAuthor, GoogleVertexAIChatInput, GoogleVertexAIChatInstance, GoogleVertexAIChatMessage, GoogleVertexAIChatMessageFields, GoogleVertexAIChatPrediction, } from "./common.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.ChatGoogleVertexAI = void 0;
|
|
4
4
|
const googlevertexai_connection_js_1 = require("../../util/googlevertexai-connection.cjs");
|
|
5
5
|
const googlevertexai_webauth_js_1 = require("../../util/googlevertexai-webauth.cjs");
|
|
6
6
|
const common_js_1 = require("./common.cjs");
|
|
@@ -29,5 +29,3 @@ class ChatGoogleVertexAI extends common_js_1.BaseChatGoogleVertexAI {
|
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
exports.ChatGoogleVertexAI = ChatGoogleVertexAI;
|
|
32
|
-
var common_js_2 = require("./common.cjs");
|
|
33
|
-
Object.defineProperty(exports, "GoogleVertexAIChatMessage", { enumerable: true, get: function () { return common_js_2.GoogleVertexAIChatMessage; } });
|
|
@@ -16,4 +16,4 @@ export declare class ChatGoogleVertexAI extends BaseChatGoogleVertexAI<WebGoogle
|
|
|
16
16
|
};
|
|
17
17
|
constructor(fields?: GoogleVertexAIChatInput<WebGoogleAuthOptions>);
|
|
18
18
|
}
|
|
19
|
-
export { ChatExample, GoogleVertexAIChatAuthor, GoogleVertexAIChatInput, GoogleVertexAIChatInstance, GoogleVertexAIChatMessage, GoogleVertexAIChatMessageFields, GoogleVertexAIChatPrediction, } from "./common.js";
|
|
19
|
+
export type { ChatExample, GoogleVertexAIChatAuthor, GoogleVertexAIChatInput, GoogleVertexAIChatInstance, GoogleVertexAIChatMessage, GoogleVertexAIChatMessageFields, GoogleVertexAIChatPrediction, } from "./common.js";
|
|
@@ -5,7 +5,7 @@ import { StructuredTool } from "../tools/base.js";
|
|
|
5
5
|
import { AzureOpenAIInput, OpenAICallOptions, OpenAIChatInput, OpenAICoreRequestOptions, LegacyOpenAIInput } from "../types/openai-types.js";
|
|
6
6
|
import { BaseChatModel, BaseChatModelParams } from "./base.js";
|
|
7
7
|
import { BaseFunctionCallOptions } from "../base_language/index.js";
|
|
8
|
-
export { AzureOpenAIInput, OpenAICallOptions, OpenAIChatInput };
|
|
8
|
+
export type { AzureOpenAIInput, OpenAICallOptions, OpenAIChatInput };
|
|
9
9
|
interface TokenUsage {
|
|
10
10
|
completionTokens?: number;
|
|
11
11
|
promptTokens?: number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { AutoGPTPrompt, AutoGPTPromptInput } from "./prompt.js";
|
|
1
|
+
export { AutoGPTPrompt, type AutoGPTPromptInput } from "./prompt.js";
|
|
2
2
|
export { AutoGPTOutputParser, preprocessJsonInput } from "./output_parser.js";
|
|
3
|
-
export { AutoGPT, AutoGPTInput } from "./agent.js";
|
|
4
|
-
export { AutoGPTAction } from "./schema.js";
|
|
3
|
+
export { AutoGPT, type AutoGPTInput } from "./agent.js";
|
|
4
|
+
export type { AutoGPTAction } from "./schema.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { TaskCreationChain } from "./task_creation.js";
|
|
2
2
|
export { TaskExecutionChain } from "./task_execution.js";
|
|
3
3
|
export { TaskPrioritizationChain } from "./task_prioritization.js";
|
|
4
|
-
export { BabyAGI, Task, BabyAGIInputs } from "./agent.js";
|
|
4
|
+
export { BabyAGI, type Task, type BabyAGIInputs } from "./agent.js";
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { PlanAndExecuteAgentExecutor } from "./agent_executor.js";
|
|
2
|
-
export { BasePlanner, BaseStepContainer, BaseStepExecutor, StepAction, StepResult, Step, Plan, ListStepContainer, LLMPlanner, ChainStepExecutor, } from "./base.js";
|
|
2
|
+
export { BasePlanner, BaseStepContainer, BaseStepExecutor, type StepAction, type StepResult, type Step, type Plan, ListStepContainer, LLMPlanner, ChainStepExecutor, } from "./base.js";
|
|
3
3
|
export { PlanOutputParser } from "./outputParser.js";
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Neo4jGraph = void 0;
|
|
7
|
+
const neo4j_driver_1 = __importDefault(require("neo4j-driver"));
|
|
8
|
+
class Neo4jGraph {
|
|
9
|
+
constructor({ url, username, password, database = "neo4j", }) {
|
|
10
|
+
Object.defineProperty(this, "driver", {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
configurable: true,
|
|
13
|
+
writable: true,
|
|
14
|
+
value: void 0
|
|
15
|
+
});
|
|
16
|
+
Object.defineProperty(this, "database", {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
configurable: true,
|
|
19
|
+
writable: true,
|
|
20
|
+
value: void 0
|
|
21
|
+
});
|
|
22
|
+
Object.defineProperty(this, "schema", {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
configurable: true,
|
|
25
|
+
writable: true,
|
|
26
|
+
value: ""
|
|
27
|
+
});
|
|
28
|
+
try {
|
|
29
|
+
this.driver = neo4j_driver_1.default.driver(url, neo4j_driver_1.default.auth.basic(username, password));
|
|
30
|
+
this.database = database;
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
throw new Error("Could not create a Neo4j driver instance. Please check the connection details.");
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
static async initialize(config) {
|
|
37
|
+
const graph = new Neo4jGraph(config);
|
|
38
|
+
try {
|
|
39
|
+
await graph.verifyConnectivity();
|
|
40
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
console.log("Failed to verify connection.");
|
|
44
|
+
}
|
|
45
|
+
try {
|
|
46
|
+
await graph.refreshSchema();
|
|
47
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
throw new Error(`Error: ${error.message}`);
|
|
51
|
+
}
|
|
52
|
+
finally {
|
|
53
|
+
console.log("Schema refreshed successfully.");
|
|
54
|
+
}
|
|
55
|
+
return graph;
|
|
56
|
+
}
|
|
57
|
+
getSchema() {
|
|
58
|
+
return this.schema;
|
|
59
|
+
}
|
|
60
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
61
|
+
async query(query, params = {}) {
|
|
62
|
+
const session = this.driver.session({ database: this.database });
|
|
63
|
+
try {
|
|
64
|
+
const result = await session.run(query, params);
|
|
65
|
+
return result.records.map((record) => record.toObject());
|
|
66
|
+
}
|
|
67
|
+
finally {
|
|
68
|
+
await session.close();
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
async verifyConnectivity() {
|
|
72
|
+
const session = this.driver.session({ database: this.database });
|
|
73
|
+
await session.close();
|
|
74
|
+
}
|
|
75
|
+
async refreshSchema() {
|
|
76
|
+
const nodePropertiesQuery = `
|
|
77
|
+
CALL apoc.meta.data()
|
|
78
|
+
YIELD label, other, elementType, type, property
|
|
79
|
+
WHERE NOT type = "RELATIONSHIP" AND elementType = "node"
|
|
80
|
+
WITH label AS nodeLabels, collect({property:property, type:type}) AS properties
|
|
81
|
+
RETURN {labels: nodeLabels, properties: properties} AS output
|
|
82
|
+
`;
|
|
83
|
+
const relPropertiesQuery = `
|
|
84
|
+
CALL apoc.meta.data()
|
|
85
|
+
YIELD label, other, elementType, type, property
|
|
86
|
+
WHERE NOT type = "RELATIONSHIP" AND elementType = "relationship"
|
|
87
|
+
WITH label AS nodeLabels, collect({property:property, type:type}) AS properties
|
|
88
|
+
RETURN {type: nodeLabels, properties: properties} AS output
|
|
89
|
+
`;
|
|
90
|
+
const relQuery = `
|
|
91
|
+
CALL apoc.meta.data()
|
|
92
|
+
YIELD label, other, elementType, type, property
|
|
93
|
+
WHERE type = "RELATIONSHIP" AND elementType = "node"
|
|
94
|
+
UNWIND other AS other_node
|
|
95
|
+
RETURN "(:" + label + ")-[:" + property + "]->(:" + toString(other_node) + ")" AS output
|
|
96
|
+
`;
|
|
97
|
+
const nodeProperties = await this.query(nodePropertiesQuery);
|
|
98
|
+
const relationshipsProperties = await this.query(relPropertiesQuery);
|
|
99
|
+
const relationships = await this.query(relQuery);
|
|
100
|
+
this.schema = `
|
|
101
|
+
Node properties are the following:
|
|
102
|
+
${nodeProperties.map((el) => el.output)}
|
|
103
|
+
|
|
104
|
+
Relationship properties are the following:
|
|
105
|
+
${relationshipsProperties.map((el) => el.output)}
|
|
106
|
+
|
|
107
|
+
The relationships are the following:
|
|
108
|
+
${relationships.map((el) => el.output)}
|
|
109
|
+
`;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
exports.Neo4jGraph = Neo4jGraph;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
interface Neo4jGraphConfig {
|
|
2
|
+
url: string;
|
|
3
|
+
username: string;
|
|
4
|
+
password: string;
|
|
5
|
+
database?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare class Neo4jGraph {
|
|
8
|
+
private driver;
|
|
9
|
+
private database;
|
|
10
|
+
private schema;
|
|
11
|
+
constructor({ url, username, password, database, }: Neo4jGraphConfig);
|
|
12
|
+
static initialize(config: Neo4jGraphConfig): Promise<Neo4jGraph>;
|
|
13
|
+
getSchema(): string;
|
|
14
|
+
query(query: string, params?: any): Promise<any[]>;
|
|
15
|
+
verifyConnectivity(): Promise<void>;
|
|
16
|
+
refreshSchema(): Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import neo4j from "neo4j-driver";
|
|
2
|
+
export class Neo4jGraph {
|
|
3
|
+
constructor({ url, username, password, database = "neo4j", }) {
|
|
4
|
+
Object.defineProperty(this, "driver", {
|
|
5
|
+
enumerable: true,
|
|
6
|
+
configurable: true,
|
|
7
|
+
writable: true,
|
|
8
|
+
value: void 0
|
|
9
|
+
});
|
|
10
|
+
Object.defineProperty(this, "database", {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
configurable: true,
|
|
13
|
+
writable: true,
|
|
14
|
+
value: void 0
|
|
15
|
+
});
|
|
16
|
+
Object.defineProperty(this, "schema", {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
configurable: true,
|
|
19
|
+
writable: true,
|
|
20
|
+
value: ""
|
|
21
|
+
});
|
|
22
|
+
try {
|
|
23
|
+
this.driver = neo4j.driver(url, neo4j.auth.basic(username, password));
|
|
24
|
+
this.database = database;
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
throw new Error("Could not create a Neo4j driver instance. Please check the connection details.");
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
static async initialize(config) {
|
|
31
|
+
const graph = new Neo4jGraph(config);
|
|
32
|
+
try {
|
|
33
|
+
await graph.verifyConnectivity();
|
|
34
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
console.log("Failed to verify connection.");
|
|
38
|
+
}
|
|
39
|
+
try {
|
|
40
|
+
await graph.refreshSchema();
|
|
41
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
throw new Error(`Error: ${error.message}`);
|
|
45
|
+
}
|
|
46
|
+
finally {
|
|
47
|
+
console.log("Schema refreshed successfully.");
|
|
48
|
+
}
|
|
49
|
+
return graph;
|
|
50
|
+
}
|
|
51
|
+
getSchema() {
|
|
52
|
+
return this.schema;
|
|
53
|
+
}
|
|
54
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
55
|
+
async query(query, params = {}) {
|
|
56
|
+
const session = this.driver.session({ database: this.database });
|
|
57
|
+
try {
|
|
58
|
+
const result = await session.run(query, params);
|
|
59
|
+
return result.records.map((record) => record.toObject());
|
|
60
|
+
}
|
|
61
|
+
finally {
|
|
62
|
+
await session.close();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
async verifyConnectivity() {
|
|
66
|
+
const session = this.driver.session({ database: this.database });
|
|
67
|
+
await session.close();
|
|
68
|
+
}
|
|
69
|
+
async refreshSchema() {
|
|
70
|
+
const nodePropertiesQuery = `
|
|
71
|
+
CALL apoc.meta.data()
|
|
72
|
+
YIELD label, other, elementType, type, property
|
|
73
|
+
WHERE NOT type = "RELATIONSHIP" AND elementType = "node"
|
|
74
|
+
WITH label AS nodeLabels, collect({property:property, type:type}) AS properties
|
|
75
|
+
RETURN {labels: nodeLabels, properties: properties} AS output
|
|
76
|
+
`;
|
|
77
|
+
const relPropertiesQuery = `
|
|
78
|
+
CALL apoc.meta.data()
|
|
79
|
+
YIELD label, other, elementType, type, property
|
|
80
|
+
WHERE NOT type = "RELATIONSHIP" AND elementType = "relationship"
|
|
81
|
+
WITH label AS nodeLabels, collect({property:property, type:type}) AS properties
|
|
82
|
+
RETURN {type: nodeLabels, properties: properties} AS output
|
|
83
|
+
`;
|
|
84
|
+
const relQuery = `
|
|
85
|
+
CALL apoc.meta.data()
|
|
86
|
+
YIELD label, other, elementType, type, property
|
|
87
|
+
WHERE type = "RELATIONSHIP" AND elementType = "node"
|
|
88
|
+
UNWIND other AS other_node
|
|
89
|
+
RETURN "(:" + label + ")-[:" + property + "]->(:" + toString(other_node) + ")" AS output
|
|
90
|
+
`;
|
|
91
|
+
const nodeProperties = await this.query(nodePropertiesQuery);
|
|
92
|
+
const relationshipsProperties = await this.query(relPropertiesQuery);
|
|
93
|
+
const relationships = await this.query(relQuery);
|
|
94
|
+
this.schema = `
|
|
95
|
+
Node properties are the following:
|
|
96
|
+
${nodeProperties.map((el) => el.output)}
|
|
97
|
+
|
|
98
|
+
Relationship properties are the following:
|
|
99
|
+
${relationshipsProperties.map((el) => el.output)}
|
|
100
|
+
|
|
101
|
+
The relationships are the following:
|
|
102
|
+
${relationships.map((el) => el.output)}
|
|
103
|
+
`;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
@@ -3,7 +3,7 @@ import { CallbackManagerForLLMRun } from "../callbacks/manager.js";
|
|
|
3
3
|
import { GenerationChunk, LLMResult } from "../schema/index.js";
|
|
4
4
|
import { AzureOpenAIInput, OpenAICallOptions, OpenAIChatInput, OpenAICoreRequestOptions, LegacyOpenAIInput } from "../types/openai-types.js";
|
|
5
5
|
import { BaseLLMParams, LLM } from "./base.js";
|
|
6
|
-
export { AzureOpenAIInput, OpenAIChatInput };
|
|
6
|
+
export { type AzureOpenAIInput, type OpenAIChatInput };
|
|
7
7
|
/**
|
|
8
8
|
* Interface that extends the OpenAICallOptions interface and includes an
|
|
9
9
|
* optional promptIndex property. It represents the options that can be
|
package/dist/llms/openai.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { CallbackManagerForLLMRun } from "../callbacks/manager.js";
|
|
|
3
3
|
import { GenerationChunk, LLMResult } from "../schema/index.js";
|
|
4
4
|
import { AzureOpenAIInput, OpenAICallOptions, OpenAICoreRequestOptions, OpenAIInput, LegacyOpenAIInput } from "../types/openai-types.js";
|
|
5
5
|
import { BaseLLM, BaseLLMParams } from "./base.js";
|
|
6
|
-
export { AzureOpenAIInput, OpenAICallOptions, OpenAIInput };
|
|
6
|
+
export type { AzureOpenAIInput, OpenAICallOptions, OpenAIInput };
|
|
7
7
|
/**
|
|
8
8
|
* Wrapper around OpenAI large language models.
|
|
9
9
|
*
|
|
@@ -15,6 +15,7 @@ exports.optionalImportEntrypoints = [
|
|
|
15
15
|
"langchain/chains/query_constructor",
|
|
16
16
|
"langchain/chains/query_constructor/ir",
|
|
17
17
|
"langchain/chains/sql_db",
|
|
18
|
+
"langchain/chains/graph_qa/cypher",
|
|
18
19
|
"langchain/embeddings/cloudflare_workersai",
|
|
19
20
|
"langchain/embeddings/cohere",
|
|
20
21
|
"langchain/embeddings/tensorflow",
|
|
@@ -133,6 +134,7 @@ exports.optionalImportEntrypoints = [
|
|
|
133
134
|
"langchain/stores/message/planetscale",
|
|
134
135
|
"langchain/stores/message/xata",
|
|
135
136
|
"langchain/storage/ioredis",
|
|
137
|
+
"langchain/graphs/neo4j_graph",
|
|
136
138
|
"langchain/hub",
|
|
137
139
|
"langchain/experimental/multimodal_embeddings/googlevertexai",
|
|
138
140
|
"langchain/experimental/chat_models/anthropic_functions",
|
|
@@ -12,6 +12,7 @@ export const optionalImportEntrypoints = [
|
|
|
12
12
|
"langchain/chains/query_constructor",
|
|
13
13
|
"langchain/chains/query_constructor/ir",
|
|
14
14
|
"langchain/chains/sql_db",
|
|
15
|
+
"langchain/chains/graph_qa/cypher",
|
|
15
16
|
"langchain/embeddings/cloudflare_workersai",
|
|
16
17
|
"langchain/embeddings/cohere",
|
|
17
18
|
"langchain/embeddings/tensorflow",
|
|
@@ -130,6 +131,7 @@ export const optionalImportEntrypoints = [
|
|
|
130
131
|
"langchain/stores/message/planetscale",
|
|
131
132
|
"langchain/stores/message/xata",
|
|
132
133
|
"langchain/storage/ioredis",
|
|
134
|
+
"langchain/graphs/neo4j_graph",
|
|
133
135
|
"langchain/hub",
|
|
134
136
|
"langchain/experimental/multimodal_embeddings/googlevertexai",
|
|
135
137
|
"langchain/experimental/chat_models/anthropic_functions",
|
package/dist/memory/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
export { BufferMemory, BufferMemoryInput } from "./buffer_memory.js";
|
|
1
|
+
export { BufferMemory, type BufferMemoryInput } from "./buffer_memory.js";
|
|
2
2
|
export { BaseMemory, getInputValue, getBufferString } from "./base.js";
|
|
3
|
-
export { ConversationSummaryMemory, ConversationSummaryMemoryInput, BaseConversationSummaryMemory, BaseConversationSummaryMemoryInput, } from "./summary.js";
|
|
4
|
-
export { BufferWindowMemory, BufferWindowMemoryInput, } from "./buffer_window_memory.js";
|
|
5
|
-
export { BaseChatMemory, BaseChatMemoryInput } from "./chat_memory.js";
|
|
3
|
+
export { ConversationSummaryMemory, type ConversationSummaryMemoryInput, BaseConversationSummaryMemory, type BaseConversationSummaryMemoryInput, } from "./summary.js";
|
|
4
|
+
export { BufferWindowMemory, type BufferWindowMemoryInput, } from "./buffer_window_memory.js";
|
|
5
|
+
export { BaseChatMemory, type BaseChatMemoryInput } from "./chat_memory.js";
|
|
6
6
|
export { ChatMessageHistory } from "../stores/message/in_memory.js";
|
|
7
|
-
export { MotorheadMemory, MotorheadMemoryInput } from "./motorhead_memory.js";
|
|
8
|
-
export { VectorStoreRetrieverMemory, VectorStoreRetrieverMemoryParams, } from "./vector_store.js";
|
|
7
|
+
export { MotorheadMemory, type MotorheadMemoryInput, } from "./motorhead_memory.js";
|
|
8
|
+
export { VectorStoreRetrieverMemory, type VectorStoreRetrieverMemoryParams, } from "./vector_store.js";
|
|
9
9
|
export { EntityMemory } from "./entity_memory.js";
|
|
10
10
|
export { ENTITY_MEMORY_CONVERSATION_TEMPLATE } from "./prompt.js";
|
|
11
|
-
export { CombinedMemoryInput, CombinedMemory } from "./combined_memory.js";
|
|
12
|
-
export { ConversationSummaryBufferMemory, ConversationSummaryBufferMemoryInput, } from "./summary_buffer.js";
|
|
11
|
+
export { type CombinedMemoryInput, CombinedMemory } from "./combined_memory.js";
|
|
12
|
+
export { ConversationSummaryBufferMemory, type ConversationSummaryBufferMemoryInput, } from "./summary_buffer.js";
|
package/dist/memory/index.js
CHANGED
|
@@ -4,7 +4,7 @@ export { ConversationSummaryMemory, BaseConversationSummaryMemory, } from "./sum
|
|
|
4
4
|
export { BufferWindowMemory, } from "./buffer_window_memory.js";
|
|
5
5
|
export { BaseChatMemory } from "./chat_memory.js";
|
|
6
6
|
export { ChatMessageHistory } from "../stores/message/in_memory.js";
|
|
7
|
-
export { MotorheadMemory } from "./motorhead_memory.js";
|
|
7
|
+
export { MotorheadMemory, } from "./motorhead_memory.js";
|
|
8
8
|
export { VectorStoreRetrieverMemory, } from "./vector_store.js";
|
|
9
9
|
export { EntityMemory } from "./entity_memory.js";
|
|
10
10
|
export { ENTITY_MEMORY_CONVERSATION_TEMPLATE } from "./prompt.js";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { ListOutputParser, CommaSeparatedListOutputParser } from "./list.js";
|
|
2
2
|
export { RegexParser } from "./regex.js";
|
|
3
|
-
export { StructuredOutputParser, AsymmetricStructuredOutputParser, JsonMarkdownStructuredOutputParser, JsonMarkdownFormatInstructionsOptions, JsonMarkdownStructuredOutputParserInput, } from "./structured.js";
|
|
3
|
+
export { StructuredOutputParser, AsymmetricStructuredOutputParser, JsonMarkdownStructuredOutputParser, type JsonMarkdownFormatInstructionsOptions, type JsonMarkdownStructuredOutputParserInput, } from "./structured.js";
|
|
4
4
|
export { OutputFixingParser } from "./fix.js";
|
|
5
5
|
export { CombiningOutputParser } from "./combining.js";
|
|
6
|
-
export { RouterOutputParser, RouterOutputParserInput } from "./router.js";
|
|
6
|
+
export { RouterOutputParser, type RouterOutputParserInput } from "./router.js";
|
|
7
7
|
export { CustomListOutputParser } from "./list.js";
|
|
8
|
-
export { FunctionParameters, OutputFunctionsParser, JsonOutputFunctionsParser, JsonKeyOutputFunctionsParser, } from "../output_parsers/openai_functions.js";
|
|
8
|
+
export { type FunctionParameters, OutputFunctionsParser, JsonOutputFunctionsParser, JsonKeyOutputFunctionsParser, } from "../output_parsers/openai_functions.js";
|
package/dist/prompts/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export { BaseExampleSelector, BasePromptTemplate, BasePromptTemplateInput, StringPromptValue, BaseStringPromptTemplate, } from "./base.js";
|
|
2
|
-
export { PromptTemplate, PromptTemplateInput } from "./prompt.js";
|
|
1
|
+
export { BaseExampleSelector, BasePromptTemplate, type BasePromptTemplateInput, StringPromptValue, BaseStringPromptTemplate, } from "./base.js";
|
|
2
|
+
export { PromptTemplate, type PromptTemplateInput } from "./prompt.js";
|
|
3
3
|
export { BasePromptSelector, ConditionalPromptSelector, isChatModel, isLLM, } from "./selectors/conditional.js";
|
|
4
|
-
export { LengthBasedExampleSelector, LengthBasedExampleSelectorInput, } from "./selectors/LengthBasedExampleSelector.js";
|
|
5
|
-
export { SemanticSimilarityExampleSelector, SemanticSimilarityExampleSelectorInput, } from "./selectors/SemanticSimilarityExampleSelector.js";
|
|
6
|
-
export { FewShotPromptTemplate, FewShotPromptTemplateInput, } from "./few_shot.js";
|
|
4
|
+
export { LengthBasedExampleSelector, type LengthBasedExampleSelectorInput, } from "./selectors/LengthBasedExampleSelector.js";
|
|
5
|
+
export { SemanticSimilarityExampleSelector, type SemanticSimilarityExampleSelectorInput, } from "./selectors/SemanticSimilarityExampleSelector.js";
|
|
6
|
+
export { FewShotPromptTemplate, type FewShotPromptTemplateInput, } from "./few_shot.js";
|
|
7
7
|
export { ChatPromptTemplate, HumanMessagePromptTemplate, AIMessagePromptTemplate, SystemMessagePromptTemplate, ChatMessagePromptTemplate, MessagesPlaceholder, BaseChatPromptTemplate, } from "./chat.js";
|
|
8
|
-
export { SerializedPromptTemplate, SerializedBasePromptTemplate, SerializedFewShotTemplate, } from "./serde.js";
|
|
9
|
-
export { parseTemplate, renderTemplate, checkValidTemplate, TemplateFormat, } from "./template.js";
|
|
10
|
-
export { PipelinePromptParams, PipelinePromptTemplate, PipelinePromptTemplateInput, } from "./pipeline.js";
|
|
8
|
+
export { type SerializedPromptTemplate, type SerializedBasePromptTemplate, type SerializedFewShotTemplate, } from "./serde.js";
|
|
9
|
+
export { parseTemplate, renderTemplate, checkValidTemplate, type TemplateFormat, } from "./template.js";
|
|
10
|
+
export { type PipelinePromptParams, PipelinePromptTemplate, type PipelinePromptTemplateInput, } from "./pipeline.js";
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { RemoteRetriever, RemoteRetrieverParams, RemoteRetrieverAuth, RemoteRetrieverValues, } from "./base.js";
|
|
2
|
-
export { ChatGPTPluginRetriever, ChatGPTPluginRetrieverFilter, ChatGPTPluginRetrieverParams, } from "./chatgpt-plugin.js";
|
|
3
|
-
export { RemoteLangChainRetriever, RemoteLangChainRetrieverParams, } from "./remote-retriever.js";
|
|
1
|
+
export { RemoteRetriever, type RemoteRetrieverParams, type RemoteRetrieverAuth, type RemoteRetrieverValues, } from "./base.js";
|
|
2
|
+
export { ChatGPTPluginRetriever, type ChatGPTPluginRetrieverFilter, type ChatGPTPluginRetrieverParams, } from "./chatgpt-plugin.js";
|
|
3
|
+
export { RemoteLangChainRetriever, type RemoteLangChainRetrieverParams, } from "./remote-retriever.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { RunnableFunc, RunnableLike, RunnableBatchOptions, RunnableRetryFailedAttemptHandler, Runnable, RunnableBindingArgs, RunnableBinding, RunnableEach, RunnableRetry, RunnableSequence, RunnableMap, RunnableLambda, RunnableWithFallbacks, } from "./base.js";
|
|
2
|
-
export { RunnableConfig } from "./config.js";
|
|
1
|
+
export { type RunnableFunc, type RunnableLike, type RunnableBatchOptions, type RunnableRetryFailedAttemptHandler, Runnable, type RunnableBindingArgs, RunnableBinding, RunnableEach, RunnableRetry, RunnableSequence, RunnableMap, RunnableLambda, RunnableWithFallbacks, } from "./base.js";
|
|
2
|
+
export type { RunnableConfig } from "./config.js";
|
|
3
3
|
export { RunnablePassthrough } from "./passthrough.js";
|
|
4
4
|
export { RouterRunnable } from "./router.js";
|
|
5
|
-
export { RunnableBranch, Branch, BranchLike } from "./branch.js";
|
|
5
|
+
export { RunnableBranch, type Branch, type BranchLike } from "./branch.js";
|
package/dist/sql_db.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { DataSource as DataSourceT, DataSourceOptions } from "typeorm";
|
|
2
2
|
import { SerializedSqlDatabase, SqlDatabaseDataSourceParams, SqlDatabaseOptionsParams, SqlTable } from "./util/sql_utils.js";
|
|
3
3
|
import { Serializable } from "./load/serializable.js";
|
|
4
|
-
export { SqlDatabaseDataSourceParams, SqlDatabaseOptionsParams };
|
|
4
|
+
export type { SqlDatabaseDataSourceParams, SqlDatabaseOptionsParams };
|
|
5
5
|
export declare class SqlDatabase extends Serializable implements SqlDatabaseOptionsParams, SqlDatabaseDataSourceParams {
|
|
6
6
|
lc_namespace: string[];
|
|
7
7
|
toJSON(): import("./load/serializable.js").SerializedNotImplemented;
|
package/dist/tools/index.d.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
export { SerpAPI, SerpAPIParameters } from "./serpapi.js";
|
|
1
|
+
export { SerpAPI, type SerpAPIParameters } from "./serpapi.js";
|
|
2
2
|
export { DadJokeAPI } from "./dadjokeapi.js";
|
|
3
3
|
export { BingSerpAPI } from "./bingserpapi.js";
|
|
4
|
-
export { Tool, ToolParams, StructuredTool } from "./base.js";
|
|
5
|
-
export { DynamicTool, DynamicToolInput, DynamicStructuredTool, DynamicStructuredToolInput, } from "./dynamic.js";
|
|
4
|
+
export { Tool, type ToolParams, StructuredTool } from "./base.js";
|
|
5
|
+
export { DynamicTool, type DynamicToolInput, DynamicStructuredTool, type DynamicStructuredToolInput, } from "./dynamic.js";
|
|
6
6
|
export { IFTTTWebhook } from "./IFTTTWebhook.js";
|
|
7
|
-
export { ChainTool, ChainToolInput } from "./chain.js";
|
|
8
|
-
export { JsonSpec, JsonListKeysTool, JsonGetValueTool, JsonObject, Json, } from "./json.js";
|
|
7
|
+
export { ChainTool, type ChainToolInput } from "./chain.js";
|
|
8
|
+
export { JsonSpec, JsonListKeysTool, JsonGetValueTool, type JsonObject, type Json, } from "./json.js";
|
|
9
9
|
export { RequestsGetTool, RequestsPostTool } from "./requests.js";
|
|
10
10
|
export { VectorStoreQATool } from "./vectorstore.js";
|
|
11
|
-
export { ZapierNLARunAction, ZapierNLAWrapper, ZapierNLAWrapperParams, } from "./zapier.js";
|
|
12
|
-
export { Serper, SerperParameters } from "./serper.js";
|
|
13
|
-
export { GoogleCustomSearch, GoogleCustomSearchParams, } from "./google_custom_search.js";
|
|
11
|
+
export { ZapierNLARunAction, ZapierNLAWrapper, type ZapierNLAWrapperParams, } from "./zapier.js";
|
|
12
|
+
export { Serper, type SerperParameters } from "./serper.js";
|
|
13
|
+
export { GoogleCustomSearch, type GoogleCustomSearchParams, } from "./google_custom_search.js";
|
|
14
14
|
export { AIPluginTool } from "./aiplugin.js";
|
|
15
15
|
export { ReadFileTool, WriteFileTool } from "./fs.js";
|
|
16
|
-
export { BraveSearch, BraveSearchParams } from "./brave_search.js";
|
|
17
|
-
export { WikipediaQueryRun, WikipediaQueryRunParams, } from "./wikipedia_query_run.js";
|
|
16
|
+
export { BraveSearch, type BraveSearchParams } from "./brave_search.js";
|
|
17
|
+
export { WikipediaQueryRun, type WikipediaQueryRunParams, } from "./wikipedia_query_run.js";
|
|
18
18
|
export { WolframAlphaTool } from "./wolframalpha.js";
|
|
19
|
-
export { DataForSeoAPISearch, DataForSeoApiConfig, } from "./dataforseo_api_search.js";
|
|
19
|
+
export { DataForSeoAPISearch, type DataForSeoApiConfig, } from "./dataforseo_api_search.js";
|
|
20
20
|
export { SearxngSearch } from "./searxng_search.js";
|
|
21
|
-
export { SearchApi, SearchApiParameters } from "./searchapi.js";
|
|
21
|
+
export { SearchApi, type SearchApiParameters } from "./searchapi.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('../dist/graphs/neo4j_graph.cjs');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../dist/graphs/neo4j_graph.js'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../dist/graphs/neo4j_graph.js'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "langchain",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.158",
|
|
4
4
|
"description": "Typescript bindings for langchain",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -70,6 +70,9 @@
|
|
|
70
70
|
"chains/sql_db.cjs",
|
|
71
71
|
"chains/sql_db.js",
|
|
72
72
|
"chains/sql_db.d.ts",
|
|
73
|
+
"chains/graph_qa/cypher.cjs",
|
|
74
|
+
"chains/graph_qa/cypher.js",
|
|
75
|
+
"chains/graph_qa/cypher.d.ts",
|
|
73
76
|
"embeddings/base.cjs",
|
|
74
77
|
"embeddings/base.js",
|
|
75
78
|
"embeddings/base.d.ts",
|
|
@@ -601,6 +604,9 @@
|
|
|
601
604
|
"storage/ioredis.cjs",
|
|
602
605
|
"storage/ioredis.js",
|
|
603
606
|
"storage/ioredis.d.ts",
|
|
607
|
+
"graphs/neo4j_graph.cjs",
|
|
608
|
+
"graphs/neo4j_graph.js",
|
|
609
|
+
"graphs/neo4j_graph.d.ts",
|
|
604
610
|
"hub.cjs",
|
|
605
611
|
"hub.js",
|
|
606
612
|
"hub.d.ts",
|
|
@@ -698,6 +704,8 @@
|
|
|
698
704
|
"@smithy/util-utf8": "^2.0.0",
|
|
699
705
|
"@supabase/postgrest-js": "^1.1.1",
|
|
700
706
|
"@supabase/supabase-js": "^2.10.0",
|
|
707
|
+
"@swc/core": "^1.3.90",
|
|
708
|
+
"@swc/jest": "^0.2.29",
|
|
701
709
|
"@tensorflow-models/universal-sentence-encoder": "^1.3.3",
|
|
702
710
|
"@tensorflow/tfjs-backend-cpu": "^3",
|
|
703
711
|
"@tensorflow/tfjs-converter": "^3.6.0",
|
|
@@ -755,6 +763,7 @@
|
|
|
755
763
|
"ml-matrix": "^6.10.4",
|
|
756
764
|
"mongodb": "^5.2.0",
|
|
757
765
|
"mysql2": "^3.3.3",
|
|
766
|
+
"neo4j-driver": "^5.12.0",
|
|
758
767
|
"node-llama-cpp": "^2.1.2",
|
|
759
768
|
"notion-to-md": "^3.1.0",
|
|
760
769
|
"pdf-parse": "1.1.1",
|
|
@@ -846,6 +855,7 @@
|
|
|
846
855
|
"mammoth": "*",
|
|
847
856
|
"mongodb": "^5.2.0",
|
|
848
857
|
"mysql2": "^3.3.3",
|
|
858
|
+
"neo4j-driver": "*",
|
|
849
859
|
"node-llama-cpp": "*",
|
|
850
860
|
"notion-to-md": "^3.1.0",
|
|
851
861
|
"pdf-parse": "1.1.1",
|
|
@@ -1050,6 +1060,9 @@
|
|
|
1050
1060
|
"mysql2": {
|
|
1051
1061
|
"optional": true
|
|
1052
1062
|
},
|
|
1063
|
+
"neo4j-driver": {
|
|
1064
|
+
"optional": true
|
|
1065
|
+
},
|
|
1053
1066
|
"node-llama-cpp": {
|
|
1054
1067
|
"optional": true
|
|
1055
1068
|
},
|
|
@@ -1138,7 +1151,7 @@
|
|
|
1138
1151
|
"p-retry": "4",
|
|
1139
1152
|
"uuid": "^9.0.0",
|
|
1140
1153
|
"yaml": "^2.2.1",
|
|
1141
|
-
"zod": "^3.
|
|
1154
|
+
"zod": "^3.22.2",
|
|
1142
1155
|
"zod-to-json-schema": "^3.20.4"
|
|
1143
1156
|
},
|
|
1144
1157
|
"publishConfig": {
|
|
@@ -1259,6 +1272,11 @@
|
|
|
1259
1272
|
"import": "./chains/sql_db.js",
|
|
1260
1273
|
"require": "./chains/sql_db.cjs"
|
|
1261
1274
|
},
|
|
1275
|
+
"./chains/graph_qa/cypher": {
|
|
1276
|
+
"types": "./chains/graph_qa/cypher.d.ts",
|
|
1277
|
+
"import": "./chains/graph_qa/cypher.js",
|
|
1278
|
+
"require": "./chains/graph_qa/cypher.cjs"
|
|
1279
|
+
},
|
|
1262
1280
|
"./embeddings/base": {
|
|
1263
1281
|
"types": "./embeddings/base.d.ts",
|
|
1264
1282
|
"import": "./embeddings/base.js",
|
|
@@ -2144,6 +2162,11 @@
|
|
|
2144
2162
|
"import": "./storage/ioredis.js",
|
|
2145
2163
|
"require": "./storage/ioredis.cjs"
|
|
2146
2164
|
},
|
|
2165
|
+
"./graphs/neo4j_graph": {
|
|
2166
|
+
"types": "./graphs/neo4j_graph.d.ts",
|
|
2167
|
+
"import": "./graphs/neo4j_graph.js",
|
|
2168
|
+
"require": "./graphs/neo4j_graph.cjs"
|
|
2169
|
+
},
|
|
2147
2170
|
"./hub": {
|
|
2148
2171
|
"types": "./hub.d.ts",
|
|
2149
2172
|
"import": "./hub.js",
|