langchain 0.0.204-rc.0 → 0.0.204-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agents/toolkits/aws_sfn.cjs +3 -75
- package/dist/agents/toolkits/aws_sfn.d.ts +2 -45
- package/dist/agents/toolkits/aws_sfn.js +2 -73
- package/dist/agents/toolkits/base.cjs +15 -9
- package/dist/agents/toolkits/base.d.ts +1 -9
- package/dist/agents/toolkits/base.js +1 -7
- package/dist/agents/toolkits/connery/index.cjs +15 -37
- package/dist/agents/toolkits/connery/index.d.ts +1 -23
- package/dist/agents/toolkits/connery/index.js +1 -35
- package/dist/cache/ioredis.cjs +15 -77
- package/dist/cache/ioredis.d.ts +1 -40
- package/dist/cache/ioredis.js +1 -75
- package/dist/memory/chat_memory.cjs +15 -61
- package/dist/memory/chat_memory.d.ts +1 -36
- package/dist/memory/chat_memory.js +1 -59
- package/dist/memory/motorhead_memory.cjs +15 -161
- package/dist/memory/motorhead_memory.d.ts +1 -63
- package/dist/memory/motorhead_memory.js +1 -159
- package/dist/memory/zep.cjs +15 -222
- package/dist/memory/zep.d.ts +1 -86
- package/dist/memory/zep.js +1 -220
- package/dist/stores/message/in_memory.cjs +15 -49
- package/dist/stores/message/in_memory.d.ts +1 -28
- package/dist/stores/message/in_memory.js +1 -47
- package/dist/tools/aws_lambda.cjs +15 -83
- package/dist/tools/aws_lambda.d.ts +1 -25
- package/dist/tools/aws_lambda.js +1 -82
- package/dist/tools/dynamic.cjs +15 -87
- package/dist/tools/dynamic.d.ts +1 -48
- package/dist/tools/dynamic.js +1 -84
- package/dist/util/convex.cjs +15 -75
- package/dist/util/convex.d.ts +1 -26
- package/dist/util/convex.js +1 -74
- package/dist/vectorstores/memory.cjs +143 -15
- package/dist/vectorstores/memory.d.ts +92 -1
- package/dist/vectorstores/memory.js +141 -1
- package/package.json +2 -241
- package/dist/util/chunk.cjs +0 -11
- package/dist/util/chunk.d.ts +0 -1
- package/dist/util/chunk.js +0 -7
- package/dist/util/googlevertexai-gauth.cjs +0 -36
- package/dist/util/googlevertexai-gauth.d.ts +0 -8
- package/dist/util/googlevertexai-gauth.js +0 -32
- package/dist/util/googlevertexai-webauth.cjs +0 -96
- package/dist/util/googlevertexai-webauth.d.ts +0 -22
- package/dist/util/googlevertexai-webauth.js +0 -92
- package/dist/util/iflytek_websocket_stream.cjs +0 -81
- package/dist/util/iflytek_websocket_stream.d.ts +0 -27
- package/dist/util/iflytek_websocket_stream.js +0 -77
- package/dist/util/llama_cpp.cjs +0 -34
- package/dist/util/llama_cpp.d.ts +0 -46
- package/dist/util/llama_cpp.js +0 -28
- package/dist/util/momento.cjs +0 -26
- package/dist/util/momento.d.ts +0 -9
- package/dist/util/momento.js +0 -22
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createAWSSfnAgent = exports.
|
|
4
|
-
const
|
|
5
|
-
|
|
3
|
+
exports.createAWSSfnAgent = exports.SFN_SUFFIX = exports.SFN_PREFIX = exports.AWSSfnToolkit = void 0;
|
|
4
|
+
const aws_sfn_1 = require("@langchain/community/agents/toolkits/aws_sfn");
|
|
5
|
+
Object.defineProperty(exports, "AWSSfnToolkit", { enumerable: true, get: function () { return aws_sfn_1.AWSSfnToolkit; } });
|
|
6
6
|
const template_js_1 = require("../../prompts/template.cjs");
|
|
7
7
|
const llm_chain_js_1 = require("../../chains/llm_chain.cjs");
|
|
8
8
|
const index_js_1 = require("../mrkl/index.cjs");
|
|
@@ -19,78 +19,6 @@ exports.SFN_SUFFIX = `Begin!
|
|
|
19
19
|
Question: {input}
|
|
20
20
|
Thought: I should look at state machines within AWS Step Functions to see what actions I can perform.
|
|
21
21
|
{agent_scratchpad}`;
|
|
22
|
-
/**
|
|
23
|
-
* Class representing a toolkit for interacting with AWS Step Functions.
|
|
24
|
-
* It initializes the AWS Step Functions tools and provides them as tools
|
|
25
|
-
* for the agent.
|
|
26
|
-
* @example
|
|
27
|
-
* ```typescript
|
|
28
|
-
*
|
|
29
|
-
* const toolkit = new AWSSfnToolkit({
|
|
30
|
-
* name: "onboard-new-client-workflow",
|
|
31
|
-
* description:
|
|
32
|
-
* "Onboard new client workflow. Can also be used to get status of any executing workflow or state machine.",
|
|
33
|
-
* stateMachineArn:
|
|
34
|
-
* "arn:aws:states:us-east-1:1234567890:stateMachine:my-state-machine",
|
|
35
|
-
* region: "<your Sfn's region>",
|
|
36
|
-
* accessKeyId: "<your access key id>",
|
|
37
|
-
* secretAccessKey: "<your secret access key>",
|
|
38
|
-
* });
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* const result = await toolkit.invoke({
|
|
42
|
-
* input: "Onboard john doe (john@example.com) as a new client.",
|
|
43
|
-
* });
|
|
44
|
-
*
|
|
45
|
-
* ```
|
|
46
|
-
*/
|
|
47
|
-
class AWSSfnToolkit extends base_js_1.Toolkit {
|
|
48
|
-
constructor(args) {
|
|
49
|
-
super();
|
|
50
|
-
Object.defineProperty(this, "tools", {
|
|
51
|
-
enumerable: true,
|
|
52
|
-
configurable: true,
|
|
53
|
-
writable: true,
|
|
54
|
-
value: void 0
|
|
55
|
-
});
|
|
56
|
-
Object.defineProperty(this, "stateMachineArn", {
|
|
57
|
-
enumerable: true,
|
|
58
|
-
configurable: true,
|
|
59
|
-
writable: true,
|
|
60
|
-
value: void 0
|
|
61
|
-
});
|
|
62
|
-
Object.defineProperty(this, "asl", {
|
|
63
|
-
enumerable: true,
|
|
64
|
-
configurable: true,
|
|
65
|
-
writable: true,
|
|
66
|
-
value: void 0
|
|
67
|
-
});
|
|
68
|
-
this.stateMachineArn = args.stateMachineArn;
|
|
69
|
-
if (args.asl) {
|
|
70
|
-
this.asl = args.asl;
|
|
71
|
-
}
|
|
72
|
-
this.tools = [
|
|
73
|
-
new aws_sfn_js_1.StartExecutionAWSSfnTool({
|
|
74
|
-
name: args.name,
|
|
75
|
-
description: aws_sfn_js_1.StartExecutionAWSSfnTool.formatDescription(args.name, args.description),
|
|
76
|
-
stateMachineArn: args.stateMachineArn,
|
|
77
|
-
}),
|
|
78
|
-
new aws_sfn_js_1.DescribeExecutionAWSSfnTool(Object.assign(args.region ? { region: args.region } : {}, args.accessKeyId && args.secretAccessKey
|
|
79
|
-
? {
|
|
80
|
-
accessKeyId: args.accessKeyId,
|
|
81
|
-
secretAccessKey: args.secretAccessKey,
|
|
82
|
-
}
|
|
83
|
-
: {})),
|
|
84
|
-
new aws_sfn_js_1.SendTaskSuccessAWSSfnTool(Object.assign(args.region ? { region: args.region } : {}, args.accessKeyId && args.secretAccessKey
|
|
85
|
-
? {
|
|
86
|
-
accessKeyId: args.accessKeyId,
|
|
87
|
-
secretAccessKey: args.secretAccessKey,
|
|
88
|
-
}
|
|
89
|
-
: {})),
|
|
90
|
-
];
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
exports.AWSSfnToolkit = AWSSfnToolkit;
|
|
94
22
|
function createAWSSfnAgent(llm, toolkit, args) {
|
|
95
23
|
const { prefix = exports.SFN_PREFIX, suffix = exports.SFN_SUFFIX, inputVariables = ["input", "agent_scratchpad"], } = args ?? {};
|
|
96
24
|
const { tools } = toolkit;
|
|
@@ -1,53 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { SfnConfig } from "../../tools/aws_sfn.js";
|
|
3
|
-
import { Toolkit } from "./base.js";
|
|
1
|
+
import { type AWSSfnToolkitArgs, AWSSfnToolkit } from "@langchain/community/agents/toolkits/aws_sfn";
|
|
4
2
|
import { BaseLanguageModel } from "../../base_language/index.js";
|
|
5
3
|
import { ZeroShotCreatePromptArgs } from "../mrkl/index.js";
|
|
6
4
|
import { AgentExecutor } from "../executor.js";
|
|
5
|
+
export { AWSSfnToolkit, type AWSSfnToolkitArgs };
|
|
7
6
|
export declare const SFN_PREFIX = "You are an agent designed to interact with AWS Step Functions state machines to execute and coordinate asynchronous workflows and tasks.\nGiven an input question, command, or task use the appropriate tool to execute a command to interact with AWS Step Functions and return the result.\nYou have access to tools for interacting with AWS Step Functions.\nGiven an input question, command, or task use the correct tool to complete the task.\nOnly use the below tools. Only use the information returned by the below tools to construct your final answer.\n\nIf the question does not seem related to AWS Step Functions or an existing state machine, just return \"I don't know\" as the answer.";
|
|
8
7
|
export declare const SFN_SUFFIX = "Begin!\n\nQuestion: {input}\nThought: I should look at state machines within AWS Step Functions to see what actions I can perform.\n{agent_scratchpad}";
|
|
9
8
|
export interface AWSSfnCreatePromptArgs extends ZeroShotCreatePromptArgs {
|
|
10
9
|
}
|
|
11
|
-
/**
|
|
12
|
-
* Interface for the arguments required to create an AWS Step Functions
|
|
13
|
-
* toolkit.
|
|
14
|
-
*/
|
|
15
|
-
export interface AWSSfnToolkitArgs {
|
|
16
|
-
name: string;
|
|
17
|
-
description: string;
|
|
18
|
-
stateMachineArn: string;
|
|
19
|
-
asl?: string;
|
|
20
|
-
llm?: BaseLanguageModel;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Class representing a toolkit for interacting with AWS Step Functions.
|
|
24
|
-
* It initializes the AWS Step Functions tools and provides them as tools
|
|
25
|
-
* for the agent.
|
|
26
|
-
* @example
|
|
27
|
-
* ```typescript
|
|
28
|
-
*
|
|
29
|
-
* const toolkit = new AWSSfnToolkit({
|
|
30
|
-
* name: "onboard-new-client-workflow",
|
|
31
|
-
* description:
|
|
32
|
-
* "Onboard new client workflow. Can also be used to get status of any executing workflow or state machine.",
|
|
33
|
-
* stateMachineArn:
|
|
34
|
-
* "arn:aws:states:us-east-1:1234567890:stateMachine:my-state-machine",
|
|
35
|
-
* region: "<your Sfn's region>",
|
|
36
|
-
* accessKeyId: "<your access key id>",
|
|
37
|
-
* secretAccessKey: "<your secret access key>",
|
|
38
|
-
* });
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* const result = await toolkit.invoke({
|
|
42
|
-
* input: "Onboard john doe (john@example.com) as a new client.",
|
|
43
|
-
* });
|
|
44
|
-
*
|
|
45
|
-
* ```
|
|
46
|
-
*/
|
|
47
|
-
export declare class AWSSfnToolkit extends Toolkit {
|
|
48
|
-
tools: Tool[];
|
|
49
|
-
stateMachineArn: string;
|
|
50
|
-
asl: string;
|
|
51
|
-
constructor(args: AWSSfnToolkitArgs & SfnConfig);
|
|
52
|
-
}
|
|
53
10
|
export declare function createAWSSfnAgent(llm: BaseLanguageModel, toolkit: AWSSfnToolkit, args?: AWSSfnCreatePromptArgs): AgentExecutor;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Toolkit } from "./base.js";
|
|
1
|
+
import { AWSSfnToolkit, } from "@langchain/community/agents/toolkits/aws_sfn";
|
|
3
2
|
import { renderTemplate } from "../../prompts/template.js";
|
|
4
3
|
import { LLMChain } from "../../chains/llm_chain.js";
|
|
5
4
|
import { ZeroShotAgent } from "../mrkl/index.js";
|
|
6
5
|
import { AgentExecutor } from "../executor.js";
|
|
6
|
+
export { AWSSfnToolkit };
|
|
7
7
|
export const SFN_PREFIX = `You are an agent designed to interact with AWS Step Functions state machines to execute and coordinate asynchronous workflows and tasks.
|
|
8
8
|
Given an input question, command, or task use the appropriate tool to execute a command to interact with AWS Step Functions and return the result.
|
|
9
9
|
You have access to tools for interacting with AWS Step Functions.
|
|
@@ -16,77 +16,6 @@ export const SFN_SUFFIX = `Begin!
|
|
|
16
16
|
Question: {input}
|
|
17
17
|
Thought: I should look at state machines within AWS Step Functions to see what actions I can perform.
|
|
18
18
|
{agent_scratchpad}`;
|
|
19
|
-
/**
|
|
20
|
-
* Class representing a toolkit for interacting with AWS Step Functions.
|
|
21
|
-
* It initializes the AWS Step Functions tools and provides them as tools
|
|
22
|
-
* for the agent.
|
|
23
|
-
* @example
|
|
24
|
-
* ```typescript
|
|
25
|
-
*
|
|
26
|
-
* const toolkit = new AWSSfnToolkit({
|
|
27
|
-
* name: "onboard-new-client-workflow",
|
|
28
|
-
* description:
|
|
29
|
-
* "Onboard new client workflow. Can also be used to get status of any executing workflow or state machine.",
|
|
30
|
-
* stateMachineArn:
|
|
31
|
-
* "arn:aws:states:us-east-1:1234567890:stateMachine:my-state-machine",
|
|
32
|
-
* region: "<your Sfn's region>",
|
|
33
|
-
* accessKeyId: "<your access key id>",
|
|
34
|
-
* secretAccessKey: "<your secret access key>",
|
|
35
|
-
* });
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* const result = await toolkit.invoke({
|
|
39
|
-
* input: "Onboard john doe (john@example.com) as a new client.",
|
|
40
|
-
* });
|
|
41
|
-
*
|
|
42
|
-
* ```
|
|
43
|
-
*/
|
|
44
|
-
export class AWSSfnToolkit extends Toolkit {
|
|
45
|
-
constructor(args) {
|
|
46
|
-
super();
|
|
47
|
-
Object.defineProperty(this, "tools", {
|
|
48
|
-
enumerable: true,
|
|
49
|
-
configurable: true,
|
|
50
|
-
writable: true,
|
|
51
|
-
value: void 0
|
|
52
|
-
});
|
|
53
|
-
Object.defineProperty(this, "stateMachineArn", {
|
|
54
|
-
enumerable: true,
|
|
55
|
-
configurable: true,
|
|
56
|
-
writable: true,
|
|
57
|
-
value: void 0
|
|
58
|
-
});
|
|
59
|
-
Object.defineProperty(this, "asl", {
|
|
60
|
-
enumerable: true,
|
|
61
|
-
configurable: true,
|
|
62
|
-
writable: true,
|
|
63
|
-
value: void 0
|
|
64
|
-
});
|
|
65
|
-
this.stateMachineArn = args.stateMachineArn;
|
|
66
|
-
if (args.asl) {
|
|
67
|
-
this.asl = args.asl;
|
|
68
|
-
}
|
|
69
|
-
this.tools = [
|
|
70
|
-
new StartExecutionAWSSfnTool({
|
|
71
|
-
name: args.name,
|
|
72
|
-
description: StartExecutionAWSSfnTool.formatDescription(args.name, args.description),
|
|
73
|
-
stateMachineArn: args.stateMachineArn,
|
|
74
|
-
}),
|
|
75
|
-
new DescribeExecutionAWSSfnTool(Object.assign(args.region ? { region: args.region } : {}, args.accessKeyId && args.secretAccessKey
|
|
76
|
-
? {
|
|
77
|
-
accessKeyId: args.accessKeyId,
|
|
78
|
-
secretAccessKey: args.secretAccessKey,
|
|
79
|
-
}
|
|
80
|
-
: {})),
|
|
81
|
-
new SendTaskSuccessAWSSfnTool(Object.assign(args.region ? { region: args.region } : {}, args.accessKeyId && args.secretAccessKey
|
|
82
|
-
? {
|
|
83
|
-
accessKeyId: args.accessKeyId,
|
|
84
|
-
secretAccessKey: args.secretAccessKey,
|
|
85
|
-
}
|
|
86
|
-
: {})),
|
|
87
|
-
];
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
19
|
export function createAWSSfnAgent(llm, toolkit, args) {
|
|
91
20
|
const { prefix = SFN_PREFIX, suffix = SFN_SUFFIX, inputVariables = ["input", "agent_scratchpad"], } = args ?? {};
|
|
92
21
|
const { tools } = toolkit;
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports
|
|
4
|
-
/**
|
|
5
|
-
* Abstract base class for toolkits in LangChain. Toolkits are collections
|
|
6
|
-
* of tools that agents can use. Subclasses must implement the `tools`
|
|
7
|
-
* property to provide the specific tools for the toolkit.
|
|
8
|
-
*/
|
|
9
|
-
class Toolkit {
|
|
10
|
-
}
|
|
11
|
-
exports.Toolkit = Toolkit;
|
|
17
|
+
__exportStar(require("@langchain/community/agents/toolkits/base"), exports);
|
|
@@ -1,9 +1 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* Abstract base class for toolkits in LangChain. Toolkits are collections
|
|
4
|
-
* of tools that agents can use. Subclasses must implement the `tools`
|
|
5
|
-
* property to provide the specific tools for the toolkit.
|
|
6
|
-
*/
|
|
7
|
-
export declare abstract class Toolkit {
|
|
8
|
-
abstract tools: Tool[];
|
|
9
|
-
}
|
|
1
|
+
export * from "@langchain/community/agents/toolkits/base";
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* Abstract base class for toolkits in LangChain. Toolkits are collections
|
|
3
|
-
* of tools that agents can use. Subclasses must implement the `tools`
|
|
4
|
-
* property to provide the specific tools for the toolkit.
|
|
5
|
-
*/
|
|
6
|
-
export class Toolkit {
|
|
7
|
-
}
|
|
1
|
+
export * from "@langchain/community/agents/toolkits/base";
|
|
@@ -1,39 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
*
|
|
8
|
-
* Connery is an open-source plugin infrastructure for AI.
|
|
9
|
-
* Source code: https://github.com/connery-io/connery-platform
|
|
10
|
-
*
|
|
11
|
-
* See an example of using this toolkit here: `./examples/src/agents/connery_mrkl.ts`
|
|
12
|
-
* @extends Toolkit
|
|
13
|
-
*/
|
|
14
|
-
class ConneryToolkit extends base_js_1.Toolkit {
|
|
15
|
-
constructor() {
|
|
16
|
-
super(...arguments);
|
|
17
|
-
Object.defineProperty(this, "tools", {
|
|
18
|
-
enumerable: true,
|
|
19
|
-
configurable: true,
|
|
20
|
-
writable: true,
|
|
21
|
-
value: void 0
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Creates a ConneryToolkit instance based on the provided ConneryService instance.
|
|
26
|
-
* It populates the tools property of the ConneryToolkit instance with the list of
|
|
27
|
-
* available tools from the ConneryService instance.
|
|
28
|
-
* @param conneryService The ConneryService instance.
|
|
29
|
-
* @returns A Promise that resolves to a ConneryToolkit instance.
|
|
30
|
-
*/
|
|
31
|
-
static async createInstance(conneryService) {
|
|
32
|
-
const toolkit = new ConneryToolkit();
|
|
33
|
-
toolkit.tools = [];
|
|
34
|
-
const actions = await conneryService.listActions();
|
|
35
|
-
toolkit.tools.push(...actions);
|
|
36
|
-
return toolkit;
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
37
7
|
}
|
|
38
|
-
|
|
39
|
-
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("@langchain/community/agents/toolkits/connery"), exports);
|
|
@@ -1,23 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { Toolkit } from "../base.js";
|
|
3
|
-
import { ConneryService } from "../../../tools/connery.js";
|
|
4
|
-
/**
|
|
5
|
-
* A toolkit for working with Connery actions.
|
|
6
|
-
*
|
|
7
|
-
* Connery is an open-source plugin infrastructure for AI.
|
|
8
|
-
* Source code: https://github.com/connery-io/connery-platform
|
|
9
|
-
*
|
|
10
|
-
* See an example of using this toolkit here: `./examples/src/agents/connery_mrkl.ts`
|
|
11
|
-
* @extends Toolkit
|
|
12
|
-
*/
|
|
13
|
-
export declare class ConneryToolkit extends Toolkit {
|
|
14
|
-
tools: Tool[];
|
|
15
|
-
/**
|
|
16
|
-
* Creates a ConneryToolkit instance based on the provided ConneryService instance.
|
|
17
|
-
* It populates the tools property of the ConneryToolkit instance with the list of
|
|
18
|
-
* available tools from the ConneryService instance.
|
|
19
|
-
* @param conneryService The ConneryService instance.
|
|
20
|
-
* @returns A Promise that resolves to a ConneryToolkit instance.
|
|
21
|
-
*/
|
|
22
|
-
static createInstance(conneryService: ConneryService): Promise<ConneryToolkit>;
|
|
23
|
-
}
|
|
1
|
+
export * from "@langchain/community/agents/toolkits/connery";
|
|
@@ -1,35 +1 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* A toolkit for working with Connery actions.
|
|
4
|
-
*
|
|
5
|
-
* Connery is an open-source plugin infrastructure for AI.
|
|
6
|
-
* Source code: https://github.com/connery-io/connery-platform
|
|
7
|
-
*
|
|
8
|
-
* See an example of using this toolkit here: `./examples/src/agents/connery_mrkl.ts`
|
|
9
|
-
* @extends Toolkit
|
|
10
|
-
*/
|
|
11
|
-
export class ConneryToolkit extends Toolkit {
|
|
12
|
-
constructor() {
|
|
13
|
-
super(...arguments);
|
|
14
|
-
Object.defineProperty(this, "tools", {
|
|
15
|
-
enumerable: true,
|
|
16
|
-
configurable: true,
|
|
17
|
-
writable: true,
|
|
18
|
-
value: void 0
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Creates a ConneryToolkit instance based on the provided ConneryService instance.
|
|
23
|
-
* It populates the tools property of the ConneryToolkit instance with the list of
|
|
24
|
-
* available tools from the ConneryService instance.
|
|
25
|
-
* @param conneryService The ConneryService instance.
|
|
26
|
-
* @returns A Promise that resolves to a ConneryToolkit instance.
|
|
27
|
-
*/
|
|
28
|
-
static async createInstance(conneryService) {
|
|
29
|
-
const toolkit = new ConneryToolkit();
|
|
30
|
-
toolkit.tools = [];
|
|
31
|
-
const actions = await conneryService.listActions();
|
|
32
|
-
toolkit.tools.push(...actions);
|
|
33
|
-
return toolkit;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
1
|
+
export * from "@langchain/community/agents/toolkits/connery";
|
package/dist/cache/ioredis.cjs
CHANGED
|
@@ -1,79 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* Cache LLM results using Redis.
|
|
8
|
-
* @example
|
|
9
|
-
* ```typescript
|
|
10
|
-
* const model = new ChatOpenAI({
|
|
11
|
-
* cache: new RedisCache(new Redis(), { ttl: 60 }),
|
|
12
|
-
* });
|
|
13
|
-
*
|
|
14
|
-
* // Invoke the model with a prompt
|
|
15
|
-
* const response = await model.invoke("Do something random!");
|
|
16
|
-
* console.log(response);
|
|
17
|
-
*
|
|
18
|
-
* // Remember to disconnect the Redis client when done
|
|
19
|
-
* await redisClient.disconnect();
|
|
20
|
-
* ```
|
|
21
|
-
*/
|
|
22
|
-
class RedisCache extends index_js_1.BaseCache {
|
|
23
|
-
constructor(redisClient, config) {
|
|
24
|
-
super();
|
|
25
|
-
Object.defineProperty(this, "redisClient", {
|
|
26
|
-
enumerable: true,
|
|
27
|
-
configurable: true,
|
|
28
|
-
writable: true,
|
|
29
|
-
value: void 0
|
|
30
|
-
});
|
|
31
|
-
Object.defineProperty(this, "ttl", {
|
|
32
|
-
enumerable: true,
|
|
33
|
-
configurable: true,
|
|
34
|
-
writable: true,
|
|
35
|
-
value: void 0
|
|
36
|
-
});
|
|
37
|
-
this.redisClient = redisClient;
|
|
38
|
-
this.ttl = config?.ttl;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Retrieves data from the Redis server using a prompt and an LLM key. If
|
|
42
|
-
* the data is not found, it returns null.
|
|
43
|
-
* @param prompt The prompt used to find the data.
|
|
44
|
-
* @param llmKey The LLM key used to find the data.
|
|
45
|
-
* @returns The corresponding data as an array of Generation objects, or null if not found.
|
|
46
|
-
*/
|
|
47
|
-
async lookup(prompt, llmKey) {
|
|
48
|
-
let idx = 0;
|
|
49
|
-
let key = (0, base_js_1.getCacheKey)(prompt, llmKey, String(idx));
|
|
50
|
-
let value = await this.redisClient.get(key);
|
|
51
|
-
const generations = [];
|
|
52
|
-
while (value) {
|
|
53
|
-
const storedGeneration = JSON.parse(value);
|
|
54
|
-
generations.push((0, base_js_1.deserializeStoredGeneration)(storedGeneration));
|
|
55
|
-
idx += 1;
|
|
56
|
-
key = (0, base_js_1.getCacheKey)(prompt, llmKey, String(idx));
|
|
57
|
-
value = await this.redisClient.get(key);
|
|
58
|
-
}
|
|
59
|
-
return generations.length > 0 ? generations : null;
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
60
7
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
await this.redisClient.set(key, JSON.stringify((0, base_js_1.serializeGeneration)(value[i])), "EX", this.ttl);
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
await this.redisClient.set(key, JSON.stringify((0, base_js_1.serializeGeneration)(value[i])));
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
exports.RedisCache = RedisCache;
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("@langchain/community/caches/ioredis"), exports);
|
package/dist/cache/ioredis.d.ts
CHANGED
|
@@ -1,40 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { BaseCache, Generation } from "../schema/index.js";
|
|
3
|
-
/**
|
|
4
|
-
* Cache LLM results using Redis.
|
|
5
|
-
* @example
|
|
6
|
-
* ```typescript
|
|
7
|
-
* const model = new ChatOpenAI({
|
|
8
|
-
* cache: new RedisCache(new Redis(), { ttl: 60 }),
|
|
9
|
-
* });
|
|
10
|
-
*
|
|
11
|
-
* // Invoke the model with a prompt
|
|
12
|
-
* const response = await model.invoke("Do something random!");
|
|
13
|
-
* console.log(response);
|
|
14
|
-
*
|
|
15
|
-
* // Remember to disconnect the Redis client when done
|
|
16
|
-
* await redisClient.disconnect();
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
19
|
-
export declare class RedisCache extends BaseCache {
|
|
20
|
-
protected redisClient: Redis;
|
|
21
|
-
protected ttl?: number;
|
|
22
|
-
constructor(redisClient: Redis, config?: {
|
|
23
|
-
ttl?: number;
|
|
24
|
-
});
|
|
25
|
-
/**
|
|
26
|
-
* Retrieves data from the Redis server using a prompt and an LLM key. If
|
|
27
|
-
* the data is not found, it returns null.
|
|
28
|
-
* @param prompt The prompt used to find the data.
|
|
29
|
-
* @param llmKey The LLM key used to find the data.
|
|
30
|
-
* @returns The corresponding data as an array of Generation objects, or null if not found.
|
|
31
|
-
*/
|
|
32
|
-
lookup(prompt: string, llmKey: string): Promise<Generation[] | null>;
|
|
33
|
-
/**
|
|
34
|
-
* Updates the data in the Redis server using a prompt and an LLM key.
|
|
35
|
-
* @param prompt The prompt used to store the data.
|
|
36
|
-
* @param llmKey The LLM key used to store the data.
|
|
37
|
-
* @param value The data to be stored, represented as an array of Generation objects.
|
|
38
|
-
*/
|
|
39
|
-
update(prompt: string, llmKey: string, value: Generation[]): Promise<void>;
|
|
40
|
-
}
|
|
1
|
+
export * from "@langchain/community/caches/ioredis";
|
package/dist/cache/ioredis.js
CHANGED
|
@@ -1,75 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { serializeGeneration, deserializeStoredGeneration, getCacheKey, } from "./base.js";
|
|
3
|
-
/**
|
|
4
|
-
* Cache LLM results using Redis.
|
|
5
|
-
* @example
|
|
6
|
-
* ```typescript
|
|
7
|
-
* const model = new ChatOpenAI({
|
|
8
|
-
* cache: new RedisCache(new Redis(), { ttl: 60 }),
|
|
9
|
-
* });
|
|
10
|
-
*
|
|
11
|
-
* // Invoke the model with a prompt
|
|
12
|
-
* const response = await model.invoke("Do something random!");
|
|
13
|
-
* console.log(response);
|
|
14
|
-
*
|
|
15
|
-
* // Remember to disconnect the Redis client when done
|
|
16
|
-
* await redisClient.disconnect();
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
19
|
-
export class RedisCache extends BaseCache {
|
|
20
|
-
constructor(redisClient, config) {
|
|
21
|
-
super();
|
|
22
|
-
Object.defineProperty(this, "redisClient", {
|
|
23
|
-
enumerable: true,
|
|
24
|
-
configurable: true,
|
|
25
|
-
writable: true,
|
|
26
|
-
value: void 0
|
|
27
|
-
});
|
|
28
|
-
Object.defineProperty(this, "ttl", {
|
|
29
|
-
enumerable: true,
|
|
30
|
-
configurable: true,
|
|
31
|
-
writable: true,
|
|
32
|
-
value: void 0
|
|
33
|
-
});
|
|
34
|
-
this.redisClient = redisClient;
|
|
35
|
-
this.ttl = config?.ttl;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Retrieves data from the Redis server using a prompt and an LLM key. If
|
|
39
|
-
* the data is not found, it returns null.
|
|
40
|
-
* @param prompt The prompt used to find the data.
|
|
41
|
-
* @param llmKey The LLM key used to find the data.
|
|
42
|
-
* @returns The corresponding data as an array of Generation objects, or null if not found.
|
|
43
|
-
*/
|
|
44
|
-
async lookup(prompt, llmKey) {
|
|
45
|
-
let idx = 0;
|
|
46
|
-
let key = getCacheKey(prompt, llmKey, String(idx));
|
|
47
|
-
let value = await this.redisClient.get(key);
|
|
48
|
-
const generations = [];
|
|
49
|
-
while (value) {
|
|
50
|
-
const storedGeneration = JSON.parse(value);
|
|
51
|
-
generations.push(deserializeStoredGeneration(storedGeneration));
|
|
52
|
-
idx += 1;
|
|
53
|
-
key = getCacheKey(prompt, llmKey, String(idx));
|
|
54
|
-
value = await this.redisClient.get(key);
|
|
55
|
-
}
|
|
56
|
-
return generations.length > 0 ? generations : null;
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Updates the data in the Redis server using a prompt and an LLM key.
|
|
60
|
-
* @param prompt The prompt used to store the data.
|
|
61
|
-
* @param llmKey The LLM key used to store the data.
|
|
62
|
-
* @param value The data to be stored, represented as an array of Generation objects.
|
|
63
|
-
*/
|
|
64
|
-
async update(prompt, llmKey, value) {
|
|
65
|
-
for (let i = 0; i < value.length; i += 1) {
|
|
66
|
-
const key = getCacheKey(prompt, llmKey, String(i));
|
|
67
|
-
if (this.ttl !== undefined) {
|
|
68
|
-
await this.redisClient.set(key, JSON.stringify(serializeGeneration(value[i])), "EX", this.ttl);
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
71
|
-
await this.redisClient.set(key, JSON.stringify(serializeGeneration(value[i])));
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
1
|
+
export * from "@langchain/community/caches/ioredis";
|