-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
load.ts
35 lines (32 loc) · 1.04 KB
/
load.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import type { BaseLanguageModelInterface } from "@langchain/core/language_models/base";
import type { ToolInterface } from "@langchain/core/tools";
import { Agent } from "./agent.js";
import { loadFromHub } from "../util/hub.js";
import { FileLoader, loadFromFile } from "../util/load.js";
import { parseFileConfig } from "../util/parse.js";
/** @deprecated */
const loadAgentFromFile: FileLoader<Agent> = async (
file: string,
path: string,
llmAndTools?: { llm?: BaseLanguageModelInterface; tools?: ToolInterface[] }
) => {
const serialized = parseFileConfig(file, path);
return Agent.deserialize({ ...serialized, ...llmAndTools });
};
/** @deprecated */
export const loadAgent = async (
uri: string,
llmAndTools?: { llm?: BaseLanguageModelInterface; tools?: ToolInterface[] }
): Promise<Agent> => {
const hubResult = await loadFromHub(
uri,
loadAgentFromFile,
"agents",
new Set(["json", "yaml"]),
llmAndTools
);
if (hubResult) {
return hubResult;
}
return loadFromFile(uri, loadAgentFromFile, llmAndTools);
};