@delofarag/ai-utils 1.7.0 → 1.7.2
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/heart/deepAgent.d.ts +1 -0
- package/dist/heart/deepAgent.d.ts.map +1 -1
- package/dist/heart/deepAgent.js +1 -0
- package/dist/heart/deepAgent.js.map +1 -1
- package/dist/heart/hermesAgent.d.ts +22 -0
- package/dist/heart/hermesAgent.d.ts.map +1 -0
- package/dist/heart/hermesAgent.js +21 -0
- package/dist/heart/hermesAgent.js.map +1 -0
- package/dist/heart/routine.d.ts +15 -0
- package/dist/heart/routine.d.ts.map +1 -0
- package/dist/heart/routine.js +67 -0
- package/dist/heart/routine.js.map +1 -0
- package/dist/heart/tools/ToolRegistry.d.ts +7 -1
- package/dist/heart/tools/ToolRegistry.d.ts.map +1 -1
- package/dist/heart/tools/ToolRegistry.js.map +1 -1
- package/dist/helpers/cli-llms.d.ts +192 -0
- package/dist/helpers/cli-llms.d.ts.map +1 -0
- package/dist/helpers/cli-llms.js +737 -0
- package/dist/helpers/cli-llms.js.map +1 -0
- package/dist/helpers/llms.d.ts +45 -5
- package/dist/helpers/llms.d.ts.map +1 -1
- package/dist/helpers/llms.js +47 -9
- package/dist/helpers/llms.js.map +1 -1
- package/dist/imports.d.ts +10 -4
- package/dist/imports.d.ts.map +1 -1
- package/dist/imports.js +6 -3
- package/dist/imports.js.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/package.json +4 -2
- package/dist/chatbot.d.ts +0 -33
- package/dist/chatbot.d.ts.map +0 -1
- package/dist/chatbot.js +0 -72
- package/dist/chatbot.js.map +0 -1
- package/dist/functions/answerers/ask.d.ts +0 -6
- package/dist/functions/answerers/ask.d.ts.map +0 -1
- package/dist/functions/answerers/ask.js +0 -14
- package/dist/functions/answerers/ask.js.map +0 -1
- package/dist/functions/answerers/websearch.d.ts +0 -2
- package/dist/functions/answerers/websearch.d.ts.map +0 -1
- package/dist/functions/answerers/websearch.js +0 -19
- package/dist/functions/answerers/websearch.js.map +0 -1
- package/dist/functions/evaluators/classify.d.ts +0 -23
- package/dist/functions/evaluators/classify.d.ts.map +0 -1
- package/dist/functions/evaluators/classify.js +0 -61
- package/dist/functions/evaluators/classify.js.map +0 -1
- package/dist/functions/evaluators/decide.d.ts +0 -22
- package/dist/functions/evaluators/decide.d.ts.map +0 -1
- package/dist/functions/evaluators/decide.js +0 -52
- package/dist/functions/evaluators/decide.js.map +0 -1
- package/dist/functions/optimizers/promptify.d.ts +0 -8
- package/dist/functions/optimizers/promptify.d.ts.map +0 -1
- package/dist/functions/optimizers/promptify.js +0 -48
- package/dist/functions/optimizers/promptify.js.map +0 -1
- package/dist/functions/optimizers/ragify.d.ts +0 -6
- package/dist/functions/optimizers/ragify.d.ts.map +0 -1
- package/dist/functions/optimizers/ragify.js +0 -40
- package/dist/functions/optimizers/ragify.js.map +0 -1
- package/dist/functions/parsers/extract.d.ts +0 -9
- package/dist/functions/parsers/extract.d.ts.map +0 -1
- package/dist/functions/parsers/extract.js +0 -37
- package/dist/functions/parsers/extract.js.map +0 -1
- package/dist/functions/parsers/normalize.d.ts +0 -9
- package/dist/functions/parsers/normalize.d.ts.map +0 -1
- package/dist/functions/parsers/normalize.js +0 -63
- package/dist/functions/parsers/normalize.js.map +0 -1
- package/dist/functions/parsers/structure.d.ts +0 -9
- package/dist/functions/parsers/structure.d.ts.map +0 -1
- package/dist/functions/parsers/structure.js +0 -36
- package/dist/functions/parsers/structure.js.map +0 -1
- package/dist/functions/parsers/summarize.d.ts +0 -8
- package/dist/functions/parsers/summarize.d.ts.map +0 -1
- package/dist/functions/parsers/summarize.js +0 -46
- package/dist/functions/parsers/summarize.js.map +0 -1
- package/dist/heart/chatbot.d.ts +0 -55
- package/dist/heart/chatbot.d.ts.map +0 -1
- package/dist/heart/chatbot.js +0 -99
- package/dist/heart/chatbot.js.map +0 -1
- package/dist/heart/memorychain.d.ts +0 -60
- package/dist/heart/memorychain.d.ts.map +0 -1
- package/dist/heart/memorychain.js +0 -190
- package/dist/heart/memorychain.js.map +0 -1
- package/dist/heart/tools/BasicToolRegistry.d.ts +0 -22
- package/dist/heart/tools/BasicToolRegistry.d.ts.map +0 -1
- package/dist/heart/tools/BasicToolRegistry.js +0 -45
- package/dist/heart/tools/BasicToolRegistry.js.map +0 -1
- package/dist/heart/tools/CombinedRegistry.d.ts +0 -41
- package/dist/heart/tools/CombinedRegistry.d.ts.map +0 -1
- package/dist/heart/tools/CombinedRegistry.js +0 -46
- package/dist/heart/tools/CombinedRegistry.js.map +0 -1
- package/dist/heart/tools/RAGTool 2.d.ts +0 -1
- package/dist/heart/tools/RAGTool 2.d.ts.map +0 -1
- package/dist/heart/tools/RAGTool 2.js +0 -2
- package/dist/heart/tools/RAGTool 2.js.map +0 -1
- package/dist/heart/tools/ZodiosToolRegistry.d.ts +0 -22
- package/dist/heart/tools/ZodiosToolRegistry.d.ts.map +0 -1
- package/dist/heart/tools/ZodiosToolRegistry.js +0 -80
- package/dist/heart/tools/ZodiosToolRegistry.js.map +0 -1
- package/dist/heart/tools/zodios/CombinedRegistry.d.ts +0 -41
- package/dist/heart/tools/zodios/CombinedRegistry.d.ts.map +0 -1
- package/dist/heart/tools/zodios/CombinedRegistry.js +0 -58
- package/dist/heart/tools/zodios/CombinedRegistry.js.map +0 -1
- package/dist/heart/tools/zodios/ZodiosToolRegistry.d.ts +0 -22
- package/dist/heart/tools/zodios/ZodiosToolRegistry.d.ts.map +0 -1
- package/dist/heart/tools/zodios/ZodiosToolRegistry.js +0 -80
- package/dist/heart/tools/zodios/ZodiosToolRegistry.js.map +0 -1
- package/dist/helpers.d.ts +0 -51
- package/dist/helpers.d.ts.map +0 -1
- package/dist/helpers.js +0 -70
- package/dist/helpers.js.map +0 -1
- package/dist/magic-funcs/decide.d.ts +0 -1
- package/dist/magic-funcs/decide.d.ts.map +0 -1
- package/dist/magic-funcs/decide.js +0 -2
- package/dist/magic-funcs/decide.js.map +0 -1
- package/dist/magic-funcs/extract.d.ts +0 -1
- package/dist/magic-funcs/extract.d.ts.map +0 -1
- package/dist/magic-funcs/extract.js +0 -2
- package/dist/magic-funcs/extract.js.map +0 -1
- package/dist/magic-funcs/structure.d.ts +0 -1
- package/dist/magic-funcs/structure.d.ts.map +0 -1
- package/dist/magic-funcs/structure.js +0 -2
- package/dist/magic-funcs/structure.js.map +0 -1
- package/dist/magic-funcs/summarize.d.ts +0 -1
- package/dist/magic-funcs/summarize.d.ts.map +0 -1
- package/dist/magic-funcs/summarize.js +0 -2
- package/dist/magic-funcs/summarize.js.map +0 -1
- package/dist/memory.d.ts +0 -91
- package/dist/memory.d.ts.map +0 -1
- package/dist/memory.js +0 -350
- package/dist/memory.js.map +0 -1
- package/dist/rag.d.ts +0 -42
- package/dist/rag.d.ts.map +0 -1
- package/dist/rag.js +0 -66
- package/dist/rag.js.map +0 -1
- package/dist/session.d.ts +0 -12
- package/dist/session.d.ts.map +0 -1
- package/dist/session.js +0 -31
- package/dist/session.js.map +0 -1
- package/dist/src/heart/agent.d.ts +0 -68
- package/dist/src/heart/agent.d.ts.map +0 -1
- package/dist/src/heart/agent.js +0 -140
- package/dist/src/heart/agent.js.map +0 -1
- package/dist/src/heart/chain.d.ts +0 -42
- package/dist/src/heart/chain.d.ts.map +0 -1
- package/dist/src/heart/chain.js +0 -152
- package/dist/src/heart/chain.js.map +0 -1
- package/dist/src/heart/chatbot.d.ts +0 -27
- package/dist/src/heart/chatbot.d.ts.map +0 -1
- package/dist/src/heart/chatbot.js +0 -100
- package/dist/src/heart/chatbot.js.map +0 -1
- package/dist/src/heart/memorychain.d.ts +0 -59
- package/dist/src/heart/memorychain.d.ts.map +0 -1
- package/dist/src/heart/memorychain.js +0 -165
- package/dist/src/heart/memorychain.js.map +0 -1
- package/dist/src/heart/tools/BasicToolRegistry.d.ts +0 -22
- package/dist/src/heart/tools/BasicToolRegistry.d.ts.map +0 -1
- package/dist/src/heart/tools/BasicToolRegistry.js +0 -45
- package/dist/src/heart/tools/BasicToolRegistry.js.map +0 -1
- package/dist/src/heart/tools/CombinedRegistry.d.ts +0 -41
- package/dist/src/heart/tools/CombinedRegistry.d.ts.map +0 -1
- package/dist/src/heart/tools/CombinedRegistry.js +0 -46
- package/dist/src/heart/tools/CombinedRegistry.js.map +0 -1
- package/dist/src/heart/tools/ZodiosToolRegistry.d.ts +0 -22
- package/dist/src/heart/tools/ZodiosToolRegistry.d.ts.map +0 -1
- package/dist/src/heart/tools/ZodiosToolRegistry.js +0 -80
- package/dist/src/heart/tools/ZodiosToolRegistry.js.map +0 -1
- package/dist/src/helpers.d.ts +0 -31
- package/dist/src/helpers.d.ts.map +0 -1
- package/dist/src/helpers.js +0 -105
- package/dist/src/helpers.js.map +0 -1
- package/dist/src/imports.d.ts +0 -44
- package/dist/src/imports.d.ts.map +0 -1
- package/dist/src/imports.js +0 -56
- package/dist/src/imports.js.map +0 -1
- package/dist/src/memory.d.ts +0 -78
- package/dist/src/memory.d.ts.map +0 -1
- package/dist/src/memory.js +0 -282
- package/dist/src/memory.js.map +0 -1
- package/dist/src/rag.d.ts +0 -58
- package/dist/src/rag.d.ts.map +0 -1
- package/dist/src/rag.js +0 -72
- package/dist/src/rag.js.map +0 -1
package/dist/heart/chatbot.d.ts
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { BaseCheckpointSaver, VectorStore, DynamicStructuredTool } from "../imports";
|
|
2
|
-
import { BaseChatModel } from "../imports";
|
|
3
|
-
type ChatbotProps = {
|
|
4
|
-
llm: BaseChatModel;
|
|
5
|
-
prompt?: string | Array<string>;
|
|
6
|
-
tools?: DynamicStructuredTool[];
|
|
7
|
-
memory?: BaseCheckpointSaver;
|
|
8
|
-
} | {
|
|
9
|
-
llm: BaseChatModel;
|
|
10
|
-
prompt?: string | Array<string>;
|
|
11
|
-
memory?: BaseCheckpointSaver;
|
|
12
|
-
vectorStore?: VectorStore;
|
|
13
|
-
};
|
|
14
|
-
/**
|
|
15
|
-
* CONSTRUCTOR:
|
|
16
|
-
* @example
|
|
17
|
-
* constructor(props: ChatbotProps){
|
|
18
|
-
const llm = props.llm ?? getLLM({provider:"chatgroq", apikey: process.env.CHATGROQ_API_KEY ?? ""})
|
|
19
|
-
const memory = props.memory ?? new SmartCheckpointSaver(new MemorySaver(), { llm })
|
|
20
|
-
const prompt = props.prompt ?? "Du bist ein hilfreicher chatbot der mit dem User ein höffliches Gespräch führt"
|
|
21
|
-
|
|
22
|
-
if ("tools" in props) {
|
|
23
|
-
this.agent = new Agent({
|
|
24
|
-
memory,
|
|
25
|
-
tools: props.tools ?? [],
|
|
26
|
-
prompt,
|
|
27
|
-
llm,
|
|
28
|
-
})
|
|
29
|
-
} else {
|
|
30
|
-
const vectorStore = "vectorStore" in props ? props.vectorStore : undefined
|
|
31
|
-
this.chain = new MemoryChain({
|
|
32
|
-
memory,
|
|
33
|
-
prompt,
|
|
34
|
-
llm,
|
|
35
|
-
vectorStore
|
|
36
|
-
})
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
*/
|
|
40
|
-
export declare class Chatbot {
|
|
41
|
-
private chain;
|
|
42
|
-
private agent;
|
|
43
|
-
constructor(props: ChatbotProps);
|
|
44
|
-
chat({ input, thread_id }: {
|
|
45
|
-
input: string;
|
|
46
|
-
thread_id: string;
|
|
47
|
-
}): AsyncGenerator<string, string, unknown>;
|
|
48
|
-
session({ breakword, numberOfMessages, id }?: {
|
|
49
|
-
breakword?: string;
|
|
50
|
-
numberOfMessages?: number;
|
|
51
|
-
id?: string;
|
|
52
|
-
}): Promise<void>;
|
|
53
|
-
}
|
|
54
|
-
export {};
|
|
55
|
-
//# sourceMappingURL=chatbot.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"chatbot.d.ts","sourceRoot":"","sources":["../../src/heart/chatbot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AACpF,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAS1C,KAAK,YAAY,GAAG;IAChB,GAAG,EAAE,aAAa,CAAA;IAClB,MAAM,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAA;IAC/B,KAAK,CAAC,EAAE,qBAAqB,EAAE,CAAA;IAC/B,MAAM,CAAC,EAAE,mBAAmB,CAAA;CAC/B,GAAG;IACA,GAAG,EAAE,aAAa,CAAA;IAClB,MAAM,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAA;IAC/B,MAAM,CAAC,EAAE,mBAAmB,CAAA;IAC5B,WAAW,CAAC,EAAE,WAAW,CAAA;CAC5B,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,qBAAa,OAAO;IAChB,OAAO,CAAC,KAAK,CAAyB;IACtC,OAAO,CAAC,KAAK,CAAwB;gBAEzB,KAAK,EAAE,YAAY;IAuBjB,IAAI,CAAC,EAAC,KAAK,EAAC,SAAS,EAAC,EAAC;QAAC,KAAK,EAAC,MAAM,CAAC;QAAC,SAAS,EAAC,MAAM,CAAA;KAAC,GAAG,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC;IAWlG,OAAO,CAAC,EACjB,SAAkB,EAClB,gBAA2C,EAC3C,EAAoB,EACvB,GAAC;QACE,SAAS,CAAC,EAAC,MAAM,CAAC;QAClB,gBAAgB,CAAC,EAAC,MAAM,CAAC;QACzB,EAAE,CAAC,EAAC,MAAM,CAAA;KACR;CA2BT"}
|
package/dist/heart/chatbot.js
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import { getLLM } from "../helpers";
|
|
2
|
-
import { SmartCheckpointSaver } from "../memory";
|
|
3
|
-
import { MemorySaver } from "../imports";
|
|
4
|
-
import { logChunk } from "../helpers";
|
|
5
|
-
import { input } from "@delofarag/base-utils/server";
|
|
6
|
-
import { MemoryChain } from "./memorychain";
|
|
7
|
-
import { Agent } from "./agent";
|
|
8
|
-
/**
|
|
9
|
-
* CONSTRUCTOR:
|
|
10
|
-
* @example
|
|
11
|
-
* constructor(props: ChatbotProps){
|
|
12
|
-
const llm = props.llm ?? getLLM({type:"groq", apikey: process.env.CHATGROQ_API_KEY ?? ""})
|
|
13
|
-
const memory = props.memory ?? new SmartCheckpointSaver(new MemorySaver(), { llm })
|
|
14
|
-
const prompt = props.prompt ?? "Du bist ein hilfreicher chatbot der mit dem User ein höffliches Gespräch führt"
|
|
15
|
-
|
|
16
|
-
if ("tools" in props) {
|
|
17
|
-
this.agent = new Agent({
|
|
18
|
-
memory,
|
|
19
|
-
tools: props.tools ?? [],
|
|
20
|
-
prompt,
|
|
21
|
-
llm,
|
|
22
|
-
})
|
|
23
|
-
} else {
|
|
24
|
-
const vectorStore = "vectorStore" in props ? props.vectorStore : undefined
|
|
25
|
-
this.chain = new MemoryChain({
|
|
26
|
-
memory,
|
|
27
|
-
prompt,
|
|
28
|
-
llm,
|
|
29
|
-
vectorStore
|
|
30
|
-
})
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
*/
|
|
34
|
-
export class Chatbot {
|
|
35
|
-
chain;
|
|
36
|
-
agent;
|
|
37
|
-
constructor(props) {
|
|
38
|
-
const llm = props.llm ?? getLLM({ type: "groq" });
|
|
39
|
-
const memory = props.memory ?? new SmartCheckpointSaver(new MemorySaver(), { llm });
|
|
40
|
-
const prompt = props.prompt ?? "Du bist ein hilfreicher chatbot der mit dem User ein höffliches Gespräch führt";
|
|
41
|
-
if ("tools" in props) {
|
|
42
|
-
this.agent = new Agent({
|
|
43
|
-
memory,
|
|
44
|
-
tools: props.tools ?? [],
|
|
45
|
-
prompt,
|
|
46
|
-
llm,
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
const vectorStore = "vectorStore" in props ? props.vectorStore : undefined;
|
|
51
|
-
this.chain = new MemoryChain({
|
|
52
|
-
memory,
|
|
53
|
-
prompt,
|
|
54
|
-
llm,
|
|
55
|
-
vectorStore
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
async *chat({ input, thread_id }) {
|
|
60
|
-
const streamable = this.chain ? this.chain : this.agent;
|
|
61
|
-
if (!streamable)
|
|
62
|
-
throw new Error("kein streamable!");
|
|
63
|
-
let fullResponse = "";
|
|
64
|
-
for await (const chunk of streamable.stream({ input, thread_id })) {
|
|
65
|
-
fullResponse += chunk;
|
|
66
|
-
yield chunk;
|
|
67
|
-
}
|
|
68
|
-
return fullResponse;
|
|
69
|
-
}
|
|
70
|
-
async session({ breakword = "exit", numberOfMessages = Number.POSITIVE_INFINITY, id = `${Date.now()}` } = {}) {
|
|
71
|
-
let messages = 0;
|
|
72
|
-
while (true) {
|
|
73
|
-
try {
|
|
74
|
-
const message = await input("You: ");
|
|
75
|
-
if (message === breakword) {
|
|
76
|
-
break;
|
|
77
|
-
}
|
|
78
|
-
const response = this.chat({
|
|
79
|
-
input: message,
|
|
80
|
-
thread_id: id,
|
|
81
|
-
});
|
|
82
|
-
console.log("Assistant: ");
|
|
83
|
-
for await (const chunk of response) {
|
|
84
|
-
logChunk(chunk);
|
|
85
|
-
}
|
|
86
|
-
console.log(""); // Zeilenumbruch nach dem Streamen, damit Output nicht überschrieben wird
|
|
87
|
-
}
|
|
88
|
-
catch (e) {
|
|
89
|
-
console.error("Error: ", e);
|
|
90
|
-
}
|
|
91
|
-
messages = messages + 2;
|
|
92
|
-
if (messages > numberOfMessages) {
|
|
93
|
-
console.log(`Message-limit of ${numberOfMessages} reached, stopping session`);
|
|
94
|
-
break;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
//# sourceMappingURL=chatbot.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"chatbot.js","sourceRoot":"","sources":["../../src/heart/chatbot.ts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AyE;YAC7F,CAAC;YAAC,OAAM,CAAC,EAAC,CAAC;gBACP,OAAO,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC,CAAA;YAC/B,CAAC;YACD,QAAQ,GAAG,QAAQ,GAAG,CAAC,CAAA;YACvB,IAAG,QAAQ,GAAG,gBAAgB,EAAC,CAAC;gBAC5B,OAAO,CAAC,GAAG,CAAC,oBAAoB,gBAAgB,4BAA4B,CAAC,CAAA;gBAC7E,MAAK;YACT,CAAC;QACL,CAAC;IACL,CAAC;CACJ"}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { BaseCheckpointSaver, VectorStore, MessagesPlaceholder } from "../imports";
|
|
2
|
-
import { BaseChatModel } from "../imports";
|
|
3
|
-
import { Chain, DEFAULT_OUTPUT_SCHEMA, type InvokeInputBase, type OutputSchema } from "./chain";
|
|
4
|
-
import { z } from "zod/v3";
|
|
5
|
-
type MemoryChainProps<T extends OutputSchema = typeof DEFAULT_OUTPUT_SCHEMA> = {
|
|
6
|
-
llm?: BaseChatModel;
|
|
7
|
-
memory?: BaseCheckpointSaver;
|
|
8
|
-
} & ({
|
|
9
|
-
chain: Chain<T>;
|
|
10
|
-
} | {
|
|
11
|
-
prompt?: string | Array<string | MessagesPlaceholder<any>>;
|
|
12
|
-
output?: T;
|
|
13
|
-
vectorStore?: VectorStore;
|
|
14
|
-
});
|
|
15
|
-
/**
|
|
16
|
-
* CONSTRUCTOR
|
|
17
|
-
* @example
|
|
18
|
-
* constructor({memory, ...rest}: MemoryChainProps<T>){
|
|
19
|
-
this.memory = memory ?? new SmartCheckpointSaver(new MemorySaver(), { llm: rest.llm ?? getLLM({provider:"openrouter", apikey: process.env.OPENROUTER_API_KEY ?? "", model: "openai/gpt-5.4-mini"}) })
|
|
20
|
-
if ("chain" in rest){
|
|
21
|
-
this.chain = rest.chain
|
|
22
|
-
} else {
|
|
23
|
-
this.chain = new Chain<T>({
|
|
24
|
-
llm: rest.llm ?? getLLM({provider:"openrouter", apikey: process.env.OPENROUTER_API_KEY ?? "", model: "openai/gpt-5.4-mini"}),
|
|
25
|
-
prompt: rest.prompt ?? "Du bist ein hilfreicher Assistent der mit dem User ein höffliches und hilfreiches Gespräch führt",
|
|
26
|
-
output: (rest.output ?? DEFAULT_OUTPUT_SCHEMA) as unknown as T
|
|
27
|
-
vectorStore: rest.vectorStore ?? undefined
|
|
28
|
-
})
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
*
|
|
32
|
-
* @example entweder gibst du direkt eine chain + memory:
|
|
33
|
-
* @param props.memory
|
|
34
|
-
* @param props.chain
|
|
35
|
-
*
|
|
36
|
-
* @example oder eine chain wird anhand deines llms, prompts, usw... erstellt + memory:
|
|
37
|
-
* @param props.memory
|
|
38
|
-
* @param props.llm
|
|
39
|
-
* @param props.prompt
|
|
40
|
-
* @param props.output - Zod-Schema für den Rückgabewert von .invoke()
|
|
41
|
-
* @param props.vectorStore
|
|
42
|
-
*/
|
|
43
|
-
export declare class MemoryChain<T extends OutputSchema = typeof DEFAULT_OUTPUT_SCHEMA> {
|
|
44
|
-
private memory;
|
|
45
|
-
private chain;
|
|
46
|
-
constructor({ memory, ...rest }: MemoryChainProps<T>);
|
|
47
|
-
invoke(input: InvokeInputBase & {
|
|
48
|
-
thread_id: string;
|
|
49
|
-
}): Promise<z.infer<T>>;
|
|
50
|
-
stream(input: InvokeInputBase & {
|
|
51
|
-
thread_id: string;
|
|
52
|
-
}): AsyncGenerator<string, string, unknown>;
|
|
53
|
-
addContext(data: Array<any>): Promise<void>;
|
|
54
|
-
setContext(vectorStore: VectorStore): void;
|
|
55
|
-
clearContext(): void;
|
|
56
|
-
private messagesToHistoryText;
|
|
57
|
-
private saveResponse;
|
|
58
|
-
}
|
|
59
|
-
export {};
|
|
60
|
-
//# sourceMappingURL=memorychain.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"memorychain.d.ts","sourceRoot":"","sources":["../../src/heart/memorychain.ts"],"names":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AU,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC;IAIjC,UAAU,CAAC,WAAW,EAAE,WAAW;IAInC,YAAY;IAInB,OAAO,CAAC,qBAAqB;YAYf,YAAY;CA+C7B"}
|
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
import { HumanMessage, AIMessage } from "../imports";
|
|
2
|
-
import { SmartCheckpointSaver } from "../helpers/memory";
|
|
3
|
-
import { Chain, DEFAULT_OUTPUT_SCHEMA } from "./chain";
|
|
4
|
-
import { MemorySaver } from "../imports";
|
|
5
|
-
import { getLLM } from "../helpers/llms";
|
|
6
|
-
/**
|
|
7
|
-
* CONSTRUCTOR
|
|
8
|
-
* @example
|
|
9
|
-
* constructor({memory, ...rest}: MemoryChainProps<T>){
|
|
10
|
-
this.memory = memory ?? new SmartCheckpointSaver(new MemorySaver(), { llm: rest.llm ?? getLLM({provider:"openrouter", apikey: process.env.OPENROUTER_API_KEY ?? "", model: "openai/gpt-5.4-mini"}) })
|
|
11
|
-
if ("chain" in rest){
|
|
12
|
-
this.chain = rest.chain
|
|
13
|
-
} else {
|
|
14
|
-
this.chain = new Chain<T>({
|
|
15
|
-
llm: rest.llm ?? getLLM({provider:"openrouter", apikey: process.env.OPENROUTER_API_KEY ?? "", model: "openai/gpt-5.4-mini"}),
|
|
16
|
-
prompt: rest.prompt ?? "Du bist ein hilfreicher Assistent der mit dem User ein höffliches und hilfreiches Gespräch führt",
|
|
17
|
-
output: (rest.output ?? DEFAULT_OUTPUT_SCHEMA) as unknown as T
|
|
18
|
-
vectorStore: rest.vectorStore ?? undefined
|
|
19
|
-
})
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
*
|
|
23
|
-
* @example entweder gibst du direkt eine chain + memory:
|
|
24
|
-
* @param props.memory
|
|
25
|
-
* @param props.chain
|
|
26
|
-
*
|
|
27
|
-
* @example oder eine chain wird anhand deines llms, prompts, usw... erstellt + memory:
|
|
28
|
-
* @param props.memory
|
|
29
|
-
* @param props.llm
|
|
30
|
-
* @param props.prompt
|
|
31
|
-
* @param props.output - Zod-Schema für den Rückgabewert von .invoke()
|
|
32
|
-
* @param props.vectorStore
|
|
33
|
-
*/
|
|
34
|
-
export class MemoryChain {
|
|
35
|
-
memory;
|
|
36
|
-
chain;
|
|
37
|
-
constructor({ memory, ...rest }) {
|
|
38
|
-
this.memory = memory ?? new SmartCheckpointSaver(new MemorySaver(), { llm: rest.llm ?? getLLM({ provider: "openrouter", model: "openai/gpt-5.4-mini" }) });
|
|
39
|
-
if ("chain" in rest) {
|
|
40
|
-
this.chain = rest.chain;
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
this.chain = new Chain({
|
|
44
|
-
llm: rest.llm ?? getLLM({ provider: "openrouter", model: "openai/gpt-5.4-mini" }),
|
|
45
|
-
prompt: rest.prompt ?? "Du bist ein hilfreicher Assistent der mit dem User ein höffliches und hilfreiches Gespräch führt",
|
|
46
|
-
output: (rest.output ?? DEFAULT_OUTPUT_SCHEMA),
|
|
47
|
-
vectorStore: rest.vectorStore ?? undefined
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
async invoke(input) {
|
|
52
|
-
const config = {
|
|
53
|
-
configurable: { thread_id: input.thread_id }
|
|
54
|
-
};
|
|
55
|
-
const checkpoint = await this.memory.get(config);
|
|
56
|
-
let historyMessages = [];
|
|
57
|
-
if (checkpoint && checkpoint.channel_values && checkpoint.channel_values.messages) {
|
|
58
|
-
historyMessages = checkpoint.channel_values.messages;
|
|
59
|
-
}
|
|
60
|
-
const historyText = this.messagesToHistoryText(historyMessages);
|
|
61
|
-
const { thread_id, debug, promptVars, ...restInput } = input;
|
|
62
|
-
const invokeInput = {};
|
|
63
|
-
for (const key in restInput) {
|
|
64
|
-
const value = restInput[key];
|
|
65
|
-
if (historyText) {
|
|
66
|
-
invokeInput[key] = typeof value === 'string'
|
|
67
|
-
? `${historyText}\n\nUser: ${key} = ${value}`
|
|
68
|
-
: `${historyText}\n\nUser: ${key} = ${JSON.stringify(value)}`;
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
71
|
-
invokeInput[key] = value;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
if (debug) {
|
|
75
|
-
invokeInput.debug = true;
|
|
76
|
-
}
|
|
77
|
-
if (promptVars !== undefined) {
|
|
78
|
-
invokeInput.promptVars = promptVars;
|
|
79
|
-
}
|
|
80
|
-
const response = await this.chain.invoke(invokeInput);
|
|
81
|
-
const responseText = typeof response === 'object' && 'output' in response
|
|
82
|
-
? response.output
|
|
83
|
-
: typeof response === 'string'
|
|
84
|
-
? response
|
|
85
|
-
: JSON.stringify(response);
|
|
86
|
-
const userMessages = Object.entries(restInput).map(([key, value]) => new HumanMessage(`${key}: ${typeof value === 'string' ? value : JSON.stringify(value)}`));
|
|
87
|
-
await this.saveResponse(thread_id, userMessages, responseText, historyMessages);
|
|
88
|
-
return response;
|
|
89
|
-
}
|
|
90
|
-
async *stream(input) {
|
|
91
|
-
const config = {
|
|
92
|
-
configurable: { thread_id: input.thread_id }
|
|
93
|
-
};
|
|
94
|
-
const checkpoint = await this.memory.get(config);
|
|
95
|
-
let historyMessages = [];
|
|
96
|
-
if (checkpoint && checkpoint.channel_values && checkpoint.channel_values.messages) {
|
|
97
|
-
historyMessages = checkpoint.channel_values.messages;
|
|
98
|
-
}
|
|
99
|
-
const historyText = this.messagesToHistoryText(historyMessages);
|
|
100
|
-
const { thread_id, promptVars, debug, ...restInput } = input;
|
|
101
|
-
const userMessages = Object.entries(restInput).map(([key, value]) => new HumanMessage(`${key}: ${typeof value === 'string' ? value : JSON.stringify(value)}`));
|
|
102
|
-
const streamInput = {};
|
|
103
|
-
for (const key in restInput) {
|
|
104
|
-
if (historyText) {
|
|
105
|
-
streamInput[key] = typeof restInput[key] === 'string'
|
|
106
|
-
? `${historyText}\n\nUser: ${key} = ${restInput[key]}`
|
|
107
|
-
: `${historyText}\n\nUser: ${key} = ${JSON.stringify(restInput[key])}`;
|
|
108
|
-
}
|
|
109
|
-
else {
|
|
110
|
-
streamInput[key] = restInput[key];
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
if (debug) {
|
|
114
|
-
streamInput.debug = true;
|
|
115
|
-
}
|
|
116
|
-
if (promptVars !== undefined) {
|
|
117
|
-
streamInput.promptVars = promptVars;
|
|
118
|
-
}
|
|
119
|
-
const chunks = [];
|
|
120
|
-
try {
|
|
121
|
-
for await (const chunk of this.chain.stream(streamInput)) {
|
|
122
|
-
chunks.push(chunk);
|
|
123
|
-
yield chunk;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
finally {
|
|
127
|
-
const responseText = chunks.join('');
|
|
128
|
-
await this.saveResponse(thread_id, userMessages, responseText, historyMessages);
|
|
129
|
-
}
|
|
130
|
-
return chunks.join('');
|
|
131
|
-
}
|
|
132
|
-
async addContext(data) {
|
|
133
|
-
await this.chain.addContext(data);
|
|
134
|
-
}
|
|
135
|
-
setContext(vectorStore) {
|
|
136
|
-
this.chain.setContext(vectorStore);
|
|
137
|
-
}
|
|
138
|
-
clearContext() {
|
|
139
|
-
this.chain.clearContext();
|
|
140
|
-
}
|
|
141
|
-
messagesToHistoryText(messages) {
|
|
142
|
-
return messages.map(msg => {
|
|
143
|
-
if (msg instanceof HumanMessage) {
|
|
144
|
-
return `User: ${typeof msg.content === 'string' ? msg.content : JSON.stringify(msg.content)}`;
|
|
145
|
-
}
|
|
146
|
-
else if (msg instanceof AIMessage) {
|
|
147
|
-
return `Assistant: ${typeof msg.content === 'string' ? msg.content : JSON.stringify(msg.content)}`;
|
|
148
|
-
}
|
|
149
|
-
else {
|
|
150
|
-
return `System: ${typeof msg.content === 'string' ? msg.content : JSON.stringify(msg.content)}`;
|
|
151
|
-
}
|
|
152
|
-
}).join('\n\n');
|
|
153
|
-
}
|
|
154
|
-
async saveResponse(thread_id, userMessages, responseText, historyMessages) {
|
|
155
|
-
if (!responseText || responseText.length === 0)
|
|
156
|
-
return;
|
|
157
|
-
const config = {
|
|
158
|
-
configurable: { thread_id }
|
|
159
|
-
};
|
|
160
|
-
const checkpoint = await this.memory.get(config);
|
|
161
|
-
const aiMessage = new AIMessage(responseText);
|
|
162
|
-
const newMessages = [...historyMessages, ...userMessages, aiMessage];
|
|
163
|
-
const newCheckpoint = {
|
|
164
|
-
...checkpoint,
|
|
165
|
-
channel_values: {
|
|
166
|
-
...(checkpoint?.channel_values || {}),
|
|
167
|
-
messages: newMessages
|
|
168
|
-
},
|
|
169
|
-
channel_versions: {
|
|
170
|
-
...(checkpoint?.channel_versions || {}),
|
|
171
|
-
messages: newMessages.length
|
|
172
|
-
},
|
|
173
|
-
versions_seen: checkpoint?.versions_seen || {},
|
|
174
|
-
v: (checkpoint?.v || 0) + 1,
|
|
175
|
-
id: checkpoint?.id || `${thread_id}-${Date.now()}`,
|
|
176
|
-
ts: checkpoint?.ts || new Date().toISOString()
|
|
177
|
-
};
|
|
178
|
-
const metadata = {
|
|
179
|
-
source: "input",
|
|
180
|
-
step: (checkpoint?.v || 0) + 1,
|
|
181
|
-
parents: {}
|
|
182
|
-
};
|
|
183
|
-
const newCheckpointWithPendingSends = {
|
|
184
|
-
...newCheckpoint,
|
|
185
|
-
pending_sends: []
|
|
186
|
-
};
|
|
187
|
-
await this.memory.put(config, newCheckpointWithPendingSends, metadata, { messages: newMessages.length });
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
//# sourceMappingURL=memorychain.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"memorychain.js","sourceRoot":"","sources":["../../src/heart/memorychain.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,YAAY,EAAE,SAAS,EAA+G,MAAM,YAAY,CAAA;AAEtL,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAA;AACxD,OAAO,EAAE,KAAK,EAAE,qBAAqB,EAA2C,MAAM,SAAS,CAAA;AAC/F,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAEx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AG,CAAC,MAAM,EAAE,6BAA6B,EAAE,QAAQ,EAAE,EAAE,QAAQ,EAAE,WAAW,CAAC,MAAM,EAAE,CAAC,CAAA;IAC5G,CAAC;CAEJ"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { DynamicStructuredTool } from "@langchain/core/tools";
|
|
2
|
-
import type { ExtractToolNames } from "./CombinedRegistry";
|
|
3
|
-
import { z } from "zod/v3";
|
|
4
|
-
export interface Tool<T extends z.ZodObject<any, any>> {
|
|
5
|
-
name: string;
|
|
6
|
-
description: string;
|
|
7
|
-
schema: T;
|
|
8
|
-
func: (input: z.infer<T>) => any;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* vergiss nicht 'as const' am ende des input-arrays zu verwenden für perekten autocomplete!!!
|
|
12
|
-
*/
|
|
13
|
-
export declare class ToolRegistry<T extends readonly Tool<z.ZodObject<any, any>>[]> {
|
|
14
|
-
private tools;
|
|
15
|
-
constructor(tools: T);
|
|
16
|
-
getTool(name: ExtractToolNames<T>): DynamicStructuredTool | undefined;
|
|
17
|
-
getTools(...names: ExtractToolNames<T>[]): (DynamicStructuredTool<import("@langchain/core/tools").ToolSchemaBase, any, any, any> | undefined)[];
|
|
18
|
-
private turnToTool;
|
|
19
|
-
private checkDuplicatedTools;
|
|
20
|
-
get allTools(): DynamicStructuredTool[];
|
|
21
|
-
}
|
|
22
|
-
//# sourceMappingURL=BasicToolRegistry.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BasicToolRegistry.d.ts","sourceRoot":"","sources":["../../../src/heart/tools/BasicToolRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAA;AAC7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAC1D,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAA;AAE1B,MAAM,WAAW,IAAI,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,GAAG,EAAC,GAAG,CAAC;IAChD,IAAI,EAAC,MAAM,CAAA;IACX,WAAW,EAAC,MAAM,CAAA;IAClB,MAAM,EAAC,CAAC,CAAA;IACR,IAAI,EAAC,CAAC,KAAK,EAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,GAAG,CAAA;CACjC;AAED;;GAEG;AACH,qBAAa,YAAY,CAAC,CAAC,SAAS,SAAS,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,EAAC,GAAG,CAAC,CAAC,EAAE;IACrE,OAAO,CAAC,KAAK,CAAwB;gBACzB,KAAK,EAAC,CAAC;IAOZ,OAAO,CAAC,IAAI,EAAC,gBAAgB,CAAC,CAAC,CAAC,GAAG,qBAAqB,GAAG,SAAS;IAYpE,QAAQ,CAAC,GAAG,KAAK,EAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE;IAI9C,OAAO,CAAC,UAAU;IAUlB,OAAO,CAAC,oBAAoB;IAO5B,IAAW,QAAQ,IAAG,qBAAqB,EAAE,CAE5C;CACJ"}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { DynamicStructuredTool } from "@langchain/core/tools";
|
|
2
|
-
/**
|
|
3
|
-
* vergiss nicht 'as const' am ende des input-arrays zu verwenden für perekten autocomplete!!!
|
|
4
|
-
*/
|
|
5
|
-
export class ToolRegistry {
|
|
6
|
-
tools;
|
|
7
|
-
constructor(tools) {
|
|
8
|
-
this.tools = tools.map(tool => tool instanceof DynamicStructuredTool ? tool : this.turnToTool(tool));
|
|
9
|
-
if (this.checkDuplicatedTools()) {
|
|
10
|
-
throw new Error(`Error! mehrere tools wurden unter den gleichen Namen registriert!`);
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
getTool(name) {
|
|
14
|
-
const tools = this.tools.filter(tool => tool.name.toLowerCase() === name.toLowerCase());
|
|
15
|
-
if (tools.length > 1) {
|
|
16
|
-
throw new Error(`Error! mehrere tools wurden unter den gleichen Namen ${name} registriert!`);
|
|
17
|
-
}
|
|
18
|
-
if (tools.length !== 1) {
|
|
19
|
-
console.error(`unter ${name} wurde kein Tool gefunden`);
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
return tools[0];
|
|
23
|
-
}
|
|
24
|
-
getTools(...names) {
|
|
25
|
-
return names.map(name => this.getTool(name));
|
|
26
|
-
}
|
|
27
|
-
turnToTool(tool) {
|
|
28
|
-
return new DynamicStructuredTool({
|
|
29
|
-
name: tool.name,
|
|
30
|
-
description: tool.description,
|
|
31
|
-
schema: tool.schema,
|
|
32
|
-
func: tool.func
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
checkDuplicatedTools() {
|
|
36
|
-
const dublikaes = this.tools.filter((tool, index) => {
|
|
37
|
-
return this.tools.indexOf(tool) !== index;
|
|
38
|
-
});
|
|
39
|
-
return dublikaes.length > 0 ? true : false;
|
|
40
|
-
}
|
|
41
|
-
get allTools() {
|
|
42
|
-
return this.tools;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
//# sourceMappingURL=BasicToolRegistry.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BasicToolRegistry.js","sourceRoot":"","sources":["../../../src/heart/tools/BasicToolRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAA;AAW7D;;GAEG;AACH,MAAM,OAAO,YAAY;IACb,KAAK,CAAwB;IACrC,YAAY,KAAO;QACf,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,YAAY,qBAAqB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAA;QACpG,IAAI,IAAI,CAAC,oBAAoB,EAAE,EAAC,CAAC;YAC7B,MAAM,IAAI,KAAK,CAAC,mEAAmE,CAAC,CAAA;Q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9C,CAAC;IAED,IAAW,QAAQ;QACf,OAAO,IAAI,CAAC,KAAK,CAAA;IACrB,CAAC;CACJ"}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { type Tool } from "./BasicToolRegistry";
|
|
2
|
-
import type { DynamicStructuredTool } from "@langchain/core/tools";
|
|
3
|
-
import { Zodios, type ApiOf } from "zodios";
|
|
4
|
-
export type ExtractToolNames<T extends readonly {
|
|
5
|
-
name: string;
|
|
6
|
-
}[]> = {
|
|
7
|
-
[K in keyof T]: T[K] extends {
|
|
8
|
-
name: string;
|
|
9
|
-
} ? T[K]['name'] : never;
|
|
10
|
-
}[number];
|
|
11
|
-
type ExtractToolNamesFromZodiosApi<Api extends readonly any[]> = {
|
|
12
|
-
[K in keyof Api]: Api[K] extends {
|
|
13
|
-
name: infer N;
|
|
14
|
-
} ? N extends string ? N : Api[K] extends {
|
|
15
|
-
method: infer M;
|
|
16
|
-
path: infer P;
|
|
17
|
-
} ? `call api ${M & string} ${P & string}` : never : Api[K] extends {
|
|
18
|
-
method: infer M;
|
|
19
|
-
path: infer P;
|
|
20
|
-
} ? `call api ${M & string} ${P & string}` : never;
|
|
21
|
-
}[number];
|
|
22
|
-
type ExtractToolNamesFromInput<T extends readonly (Tool<any> | Zodios<any>)[]> = {
|
|
23
|
-
[K in keyof T]: T[K] extends Tool<any> ? T[K]['name'] : T[K] extends Zodios<infer Api> ? ExtractToolNamesFromZodiosApi<ApiOf<T[K]>> : never;
|
|
24
|
-
}[number];
|
|
25
|
-
/**
|
|
26
|
-
* needs testing!!!
|
|
27
|
-
*/
|
|
28
|
-
/**
|
|
29
|
-
* vergiss nicht 'as const' am ende des input-arrays zu verwenden für perekten autocomplete!!!
|
|
30
|
-
*/
|
|
31
|
-
export declare class CombinedToolRegistry<T extends readonly (Tool<any> | Zodios<any>)[]> {
|
|
32
|
-
private BaseToolRegistry;
|
|
33
|
-
private ZodiosToolRegistry;
|
|
34
|
-
private tools;
|
|
35
|
-
constructor(input: T);
|
|
36
|
-
getTool(name: ExtractToolNamesFromInput<T>): DynamicStructuredTool | undefined;
|
|
37
|
-
getTools(...names: ExtractToolNamesFromInput<T>[]): DynamicStructuredTool[];
|
|
38
|
-
get allTools(): DynamicStructuredTool[];
|
|
39
|
-
}
|
|
40
|
-
export {};
|
|
41
|
-
//# sourceMappingURL=CombinedRegistry.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CombinedRegistry.d.ts","sourceRoot":"","sources":["../../../src/heart/tools/CombinedRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,IAAI,EAAE,MAAM,qBAAqB,CAAA;AAG7D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAA;AAClE,OAAO,EAAE,MAAM,EAAE,KAAK,KAAK,EAAE,MAAM,QAAQ,CAAA;AAG3C,MAAM,MAAM,gBAAgB,CAAC,CAAC,SAAS,SAAS;IAAC,IAAI,EAAC,MAAM,CAAA;CAAC,EAAE,IAAI;KAC9D,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS;QAAC,IAAI,EAAC,MAAM,CAAA;KAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,KAAK;CACpE,CAAC,MAAM,CAAC,CAAA;AAET,KAAK,6BAA6B,CAAC,GAAG,SAAS,SAAS,GAAG,EAAE,IAAI;KAC5D,CAAC,IAAI,MAAM,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,SAAS;QAAC,IAAI,EAAE,MAAM,CAAC,CAAA;KAAC,GAC1C,CAAC,SAAS,MAAM,GACZ,CAAC,GACD,GAAG,CAAC,CAAC,CAAC,SAAS;QAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC,CAAA;KAAC,GAC/C,YAAY,CAAC,GAAG,MAAM,IAAI,CAAC,GAAG,MAAM,EAAE,GACtC,KAAK,GACT,G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ZodiosToolRegistry } from "./ZodiosToolRegistry";
|
|
3
|
-
import { Zodios } from "zodios";
|
|
4
|
-
/**
|
|
5
|
-
* needs testing!!!
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* vergiss nicht 'as const' am ende des input-arrays zu verwenden für perekten autocomplete!!!
|
|
9
|
-
*/
|
|
10
|
-
export class CombinedToolRegistry {
|
|
11
|
-
BaseToolRegistry;
|
|
12
|
-
ZodiosToolRegistry;
|
|
13
|
-
tools;
|
|
14
|
-
constructor(input) {
|
|
15
|
-
//getting and checking the tools
|
|
16
|
-
const baseTools = input.filter((tool) => {
|
|
17
|
-
return typeof tool === "object" && tool !== null && "name" in tool && "description" in tool && "schema" in tool && "func" in tool;
|
|
18
|
-
});
|
|
19
|
-
if (baseTools.length > 0) {
|
|
20
|
-
this.BaseToolRegistry = new ToolRegistry(baseTools);
|
|
21
|
-
}
|
|
22
|
-
//getting and checking the zodios clients
|
|
23
|
-
const zodiosClients = input.filter((item) => {
|
|
24
|
-
return item instanceof Zodios;
|
|
25
|
-
});
|
|
26
|
-
if (zodiosClients.length > 1) {
|
|
27
|
-
throw new Error("Only one Zodios client can be registered");
|
|
28
|
-
}
|
|
29
|
-
const zodiosClient = zodiosClients[0];
|
|
30
|
-
if (zodiosClient) {
|
|
31
|
-
this.ZodiosToolRegistry = new ZodiosToolRegistry(zodiosClient);
|
|
32
|
-
}
|
|
33
|
-
//combining the tools
|
|
34
|
-
this.tools = [...(this.BaseToolRegistry?.allTools || []), ...(this.ZodiosToolRegistry?.allTools || [])];
|
|
35
|
-
}
|
|
36
|
-
getTool(name) {
|
|
37
|
-
return this.tools.find((tool) => tool.name === name);
|
|
38
|
-
}
|
|
39
|
-
getTools(...names) {
|
|
40
|
-
return names.map((name) => this.getTool(name)).filter((tool) => tool !== undefined);
|
|
41
|
-
}
|
|
42
|
-
get allTools() {
|
|
43
|
-
return this.tools;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
//# sourceMapping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AC,YAAY,CAAC,CAAA;QAClE,CAAC;QAED,qBAAqB;QACrB,IAAI,CAAC,KAAK,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,gBAAgB,EAAE,QAAQ,IAAI,EAAE,CAAC,EAAE,GAAG,CAAC,IAAI,CAAC,kBAAkB,EAAE,QAAQ,IAAI,EAAE,CAAC,CAAC,CAAA;IAC3G,CAAC;IAED,OAAO,CAAC,IAAkC;QACtC,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,CAAA;IACxD,CAAC;IAED,QAAQ,CAAC,GAAG,KAAqC;QAC7C,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAiC,EAAE,CAAC,IAAI,KAAK,SAAS,CAAC,CAAA;IACtH,CAAC;IAED,IAAI,QAAQ;QACR,OAAO,IAAI,CAAC,KAAK,CAAA;IACrB,CAAC;CACJ"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=RAGTool%202.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RAGTool 2.d.ts","sourceRoot":"","sources":["../../../src/heart/tools/RAGTool 2.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RAGTool 2.js","sourceRoot":"","sources":["../../../src/heart/tools/RAGTool 2.ts"],"names":[],"mappings":""}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { Zodios, ZodiosEndpointDescription, ApiOf } from "zodios";
|
|
2
|
-
import { DynamicStructuredTool } from "../../imports";
|
|
3
|
-
import { Prettify } from "../../helpers";
|
|
4
|
-
import type { ExtractToolNames } from "./CombinedRegistry";
|
|
5
|
-
export type ZodiosEndpointWithAlias<R> = Prettify<ZodiosEndpointDescription<R> & {
|
|
6
|
-
name?: string;
|
|
7
|
-
}>;
|
|
8
|
-
/**
|
|
9
|
-
* needs testing!!!
|
|
10
|
-
*/
|
|
11
|
-
export declare class ZodiosToolRegistry<Z extends Zodios<any>> {
|
|
12
|
-
private apiSchema;
|
|
13
|
-
private tools;
|
|
14
|
-
private zodiosClient;
|
|
15
|
-
constructor(zodiosClient: Z);
|
|
16
|
-
getTool(name: ExtractToolNames<ApiOf<Z>>): DynamicStructuredTool | undefined;
|
|
17
|
-
getTools(...names: ExtractToolNames<ApiOf<Z>>[]): (DynamicStructuredTool | undefined)[];
|
|
18
|
-
get allTools(): DynamicStructuredTool[];
|
|
19
|
-
private turnApiIntoTools;
|
|
20
|
-
private buildToolSchema;
|
|
21
|
-
}
|
|
22
|
-
//# sourceMappingURL=ZodiosToolRegistry.d.ts.map
|