modelfusion 0.40.0 → 0.41.0
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/README.md +14 -7
- package/composed-function/summarize/summarizeRecursivelyWithTextGenerationAndTokenSplitting.d.ts +3 -3
- package/core/FunctionEvent.d.ts +1 -1
- package/model-function/AsyncIterableResultPromise.d.ts +1 -1
- package/model-function/Delta.d.ts +8 -0
- package/model-function/ModelCallEvent.d.ts +1 -1
- package/model-function/ModelCallMetadata.d.ts +13 -0
- package/model-function/describe-image/ImageDescriptionEvent.d.ts +1 -1
- package/model-function/describe-image/ImageDescriptionModel.d.ts +6 -4
- package/model-function/describe-image/describeImage.cjs +7 -2
- package/model-function/describe-image/describeImage.d.ts +2 -2
- package/model-function/describe-image/describeImage.js +7 -2
- package/model-function/embed/EmbeddingEvent.d.ts +1 -1
- package/model-function/embed/EmbeddingModel.d.ts +6 -4
- package/model-function/embed/embed.cjs +16 -11
- package/model-function/embed/embed.d.ts +3 -3
- package/model-function/embed/embed.js +16 -11
- package/model-function/executeCall.cjs +26 -30
- package/model-function/executeCall.d.ts +19 -28
- package/model-function/executeCall.js +26 -30
- package/model-function/generate-image/ImageGenerationEvent.d.ts +1 -1
- package/model-function/generate-image/ImageGenerationModel.d.ts +6 -4
- package/model-function/generate-image/generateImage.cjs +7 -2
- package/model-function/generate-image/generateImage.d.ts +2 -2
- package/model-function/generate-image/generateImage.js +7 -2
- package/model-function/generate-structure/StructureFromTextGenerationModel.cjs +6 -5
- package/model-function/generate-structure/StructureFromTextGenerationModel.d.ts +7 -5
- package/model-function/generate-structure/StructureFromTextGenerationModel.js +6 -5
- package/model-function/generate-structure/StructureGenerationEvent.d.ts +1 -1
- package/model-function/generate-structure/StructureGenerationModel.d.ts +15 -18
- package/model-function/generate-structure/StructureOrTextGenerationModel.d.ts +19 -17
- package/model-function/generate-structure/generateStructure.cjs +10 -8
- package/model-function/generate-structure/generateStructure.d.ts +2 -2
- package/model-function/generate-structure/generateStructure.js +10 -8
- package/model-function/generate-structure/generateStructureOrText.cjs +15 -8
- package/model-function/generate-structure/generateStructureOrText.d.ts +4 -4
- package/model-function/generate-structure/generateStructureOrText.js +15 -8
- package/model-function/generate-structure/streamStructure.cjs +4 -16
- package/model-function/generate-structure/streamStructure.d.ts +3 -7
- package/model-function/generate-structure/streamStructure.js +4 -16
- package/model-function/generate-text/TextGenerationEvent.d.ts +1 -1
- package/model-function/generate-text/TextGenerationModel.d.ts +18 -19
- package/model-function/generate-text/generateText.cjs +8 -9
- package/model-function/generate-text/generateText.d.ts +2 -2
- package/model-function/generate-text/generateText.js +8 -9
- package/model-function/generate-text/streamText.cjs +8 -21
- package/model-function/generate-text/streamText.d.ts +3 -7
- package/model-function/generate-text/streamText.js +8 -21
- package/model-function/index.cjs +2 -2
- package/model-function/index.d.ts +2 -2
- package/model-function/index.js +2 -2
- package/model-function/synthesize-speech/SpeechSynthesisEvent.d.ts +1 -1
- package/model-function/synthesize-speech/SpeechSynthesisModel.d.ts +3 -3
- package/model-function/synthesize-speech/synthesizeSpeech.cjs +7 -2
- package/model-function/synthesize-speech/synthesizeSpeech.d.ts +2 -2
- package/model-function/synthesize-speech/synthesizeSpeech.js +7 -2
- package/model-function/transcribe-speech/TranscriptionEvent.d.ts +1 -1
- package/model-function/transcribe-speech/TranscriptionModel.d.ts +6 -4
- package/model-function/transcribe-speech/transcribe.cjs +7 -2
- package/model-function/transcribe-speech/transcribe.d.ts +2 -2
- package/model-function/transcribe-speech/transcribe.js +7 -2
- package/model-provider/automatic1111/Automatic1111ImageGenerationModel.cjs +14 -18
- package/model-provider/automatic1111/Automatic1111ImageGenerationModel.d.ts +11 -9
- package/model-provider/automatic1111/Automatic1111ImageGenerationModel.js +14 -18
- package/model-provider/cohere/CohereTextEmbeddingModel.cjs +13 -16
- package/model-provider/cohere/CohereTextEmbeddingModel.d.ts +12 -10
- package/model-provider/cohere/CohereTextEmbeddingModel.js +13 -16
- package/model-provider/cohere/CohereTextGenerationModel.cjs +29 -29
- package/model-provider/cohere/CohereTextGenerationModel.d.ts +24 -22
- package/model-provider/cohere/CohereTextGenerationModel.js +29 -29
- package/model-provider/elevenlabs/ElevenLabsSpeechSynthesisModel.cjs +10 -17
- package/model-provider/elevenlabs/ElevenLabsSpeechSynthesisModel.d.ts +2 -2
- package/model-provider/elevenlabs/ElevenLabsSpeechSynthesisModel.js +10 -17
- package/model-provider/huggingface/HuggingFaceImageDescriptionModel.cjs +13 -16
- package/model-provider/huggingface/HuggingFaceImageDescriptionModel.d.ts +9 -7
- package/model-provider/huggingface/HuggingFaceImageDescriptionModel.js +13 -16
- package/model-provider/huggingface/HuggingFaceTextEmbeddingModel.cjs +19 -25
- package/model-provider/huggingface/HuggingFaceTextEmbeddingModel.d.ts +8 -6
- package/model-provider/huggingface/HuggingFaceTextEmbeddingModel.js +19 -25
- package/model-provider/huggingface/HuggingFaceTextGenerationModel.cjs +18 -24
- package/model-provider/huggingface/HuggingFaceTextGenerationModel.d.ts +10 -8
- package/model-provider/huggingface/HuggingFaceTextGenerationModel.js +18 -24
- package/model-provider/llamacpp/LlamaCppTextEmbeddingModel.cjs +13 -16
- package/model-provider/llamacpp/LlamaCppTextEmbeddingModel.d.ts +8 -6
- package/model-provider/llamacpp/LlamaCppTextEmbeddingModel.js +13 -16
- package/model-provider/llamacpp/LlamaCppTextGenerationModel.cjs +31 -34
- package/model-provider/llamacpp/LlamaCppTextGenerationModel.d.ts +62 -60
- package/model-provider/llamacpp/LlamaCppTextGenerationModel.js +31 -34
- package/model-provider/lmnt/LmntSpeechSynthesisModel.cjs +7 -12
- package/model-provider/lmnt/LmntSpeechSynthesisModel.d.ts +2 -2
- package/model-provider/lmnt/LmntSpeechSynthesisModel.js +7 -12
- package/model-provider/openai/OpenAIImageGenerationModel.cjs +8 -16
- package/model-provider/openai/OpenAIImageGenerationModel.d.ts +11 -11
- package/model-provider/openai/OpenAIImageGenerationModel.js +8 -16
- package/model-provider/openai/OpenAITextEmbeddingModel.cjs +18 -24
- package/model-provider/openai/OpenAITextEmbeddingModel.d.ts +18 -16
- package/model-provider/openai/OpenAITextEmbeddingModel.js +18 -24
- package/model-provider/openai/OpenAITextGenerationModel.cjs +23 -27
- package/model-provider/openai/OpenAITextGenerationModel.d.ts +31 -33
- package/model-provider/openai/OpenAITextGenerationModel.js +23 -27
- package/model-provider/openai/OpenAITranscriptionModel.cjs +19 -28
- package/model-provider/openai/OpenAITranscriptionModel.d.ts +27 -7
- package/model-provider/openai/OpenAITranscriptionModel.js +19 -28
- package/model-provider/openai/chat/OpenAIChatModel.cjs +82 -86
- package/model-provider/openai/chat/OpenAIChatModel.d.ts +127 -50
- package/model-provider/openai/chat/OpenAIChatModel.js +83 -87
- package/model-provider/openai/chat/OpenAIChatStreamIterable.cjs +4 -3
- package/model-provider/openai/chat/OpenAIChatStreamIterable.d.ts +2 -2
- package/model-provider/openai/chat/OpenAIChatStreamIterable.js +2 -1
- package/model-provider/stability/StabilityImageGenerationModel.cjs +16 -21
- package/model-provider/stability/StabilityImageGenerationModel.d.ts +13 -11
- package/model-provider/stability/StabilityImageGenerationModel.js +16 -21
- package/package.json +1 -1
- package/prompt/PromptFormatTextGenerationModel.cjs +6 -19
- package/prompt/PromptFormatTextGenerationModel.d.ts +14 -10
- package/prompt/PromptFormatTextGenerationModel.js +6 -19
- package/prompt/PromptFormatTextStreamingModel.cjs +31 -0
- package/prompt/PromptFormatTextStreamingModel.d.ts +13 -0
- package/prompt/PromptFormatTextStreamingModel.js +27 -0
- package/prompt/chat/trimChatPrompt.d.ts +2 -2
- package/prompt/index.cjs +1 -0
- package/prompt/index.d.ts +1 -0
- package/prompt/index.js +1 -0
- package/retriever/Retriever.d.ts +3 -6
- package/retriever/retrieve.cjs +2 -2
- package/retriever/retrieve.d.ts +3 -3
- package/retriever/retrieve.js +2 -2
- package/tool/executeTool.cjs +2 -2
- package/tool/executeTool.js +2 -2
- package/tool/useTool.cjs +2 -4
- package/tool/useTool.d.ts +2 -2
- package/tool/useTool.js +2 -4
- package/tool/useToolOrGenerateText.d.ts +2 -2
- package/util/SafeResult.d.ts +1 -1
- package/util/runSafe.cjs +1 -1
- package/util/runSafe.js +1 -1
- package/vector-index/VectorIndexRetriever.cjs +0 -7
- package/vector-index/VectorIndexRetriever.d.ts +5 -5
- package/vector-index/VectorIndexRetriever.js +0 -7
- package/vector-index/upsertIntoVectorIndex.d.ts +4 -4
- package/model-function/DeltaEvent.d.ts +0 -7
- package/model-function/ModelFunctionOptions.d.ts +0 -4
- /package/model-function/{DeltaEvent.cjs → Delta.cjs} +0 -0
- /package/model-function/{DeltaEvent.js → Delta.js} +0 -0
- /package/model-function/{ModelFunctionOptions.cjs → ModelCallMetadata.cjs} +0 -0
- /package/model-function/{ModelFunctionOptions.js → ModelCallMetadata.js} +0 -0
@@ -0,0 +1,27 @@
|
|
1
|
+
import { PromptFormatTextGenerationModel } from "./PromptFormatTextGenerationModel.js";
|
2
|
+
export class PromptFormatTextStreamingModel extends PromptFormatTextGenerationModel {
|
3
|
+
constructor(options) {
|
4
|
+
super(options);
|
5
|
+
}
|
6
|
+
doStreamText(prompt, options) {
|
7
|
+
const mappedPrompt = this.promptFormat.format(prompt);
|
8
|
+
return this.model.doStreamText(mappedPrompt, options);
|
9
|
+
}
|
10
|
+
withPromptFormat(promptFormat) {
|
11
|
+
return new PromptFormatTextStreamingModel({
|
12
|
+
model: this.withSettings({
|
13
|
+
stopSequences: [
|
14
|
+
...(this.settings.stopSequences ?? []),
|
15
|
+
...promptFormat.stopSequences,
|
16
|
+
],
|
17
|
+
}),
|
18
|
+
promptFormat,
|
19
|
+
});
|
20
|
+
}
|
21
|
+
withSettings(additionalSettings) {
|
22
|
+
return new PromptFormatTextStreamingModel({
|
23
|
+
model: this.model.withSettings(additionalSettings),
|
24
|
+
promptFormat: this.promptFormat,
|
25
|
+
});
|
26
|
+
}
|
27
|
+
}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { TextGenerationModel } from "../../model-function/generate-text/TextGenerationModel.js";
|
1
|
+
import { TextGenerationModel, TextGenerationModelSettings } from "../../model-function/generate-text/TextGenerationModel.js";
|
2
2
|
import { ChatPrompt } from "./ChatPrompt.js";
|
3
3
|
/**
|
4
4
|
* Keeps only the most recent messages in the prompt, while leaving enough space for the completion.
|
@@ -12,7 +12,7 @@ import { ChatPrompt } from "./ChatPrompt.js";
|
|
12
12
|
*/
|
13
13
|
export declare function trimChatPrompt({ prompt, model, tokenLimit, }: {
|
14
14
|
prompt: ChatPrompt;
|
15
|
-
model: TextGenerationModel<ChatPrompt,
|
15
|
+
model: TextGenerationModel<ChatPrompt, TextGenerationModelSettings> & {
|
16
16
|
contextWindowSize: number;
|
17
17
|
countPromptTokens: (prompt: ChatPrompt) => PromiseLike<number>;
|
18
18
|
};
|
package/prompt/index.cjs
CHANGED
@@ -19,6 +19,7 @@ __exportStar(require("./InstructionPrompt.cjs"), exports);
|
|
19
19
|
__exportStar(require("./Llama2PromptFormat.cjs"), exports);
|
20
20
|
__exportStar(require("./PromptFormat.cjs"), exports);
|
21
21
|
__exportStar(require("./PromptFormatTextGenerationModel.cjs"), exports);
|
22
|
+
__exportStar(require("./PromptFormatTextStreamingModel.cjs"), exports);
|
22
23
|
__exportStar(require("./TextPromptFormat.cjs"), exports);
|
23
24
|
__exportStar(require("./VicunaPromptFormat.cjs"), exports);
|
24
25
|
__exportStar(require("./chat/ChatPrompt.cjs"), exports);
|
package/prompt/index.d.ts
CHANGED
@@ -3,6 +3,7 @@ export * from "./InstructionPrompt.js";
|
|
3
3
|
export * from "./Llama2PromptFormat.js";
|
4
4
|
export * from "./PromptFormat.js";
|
5
5
|
export * from "./PromptFormatTextGenerationModel.js";
|
6
|
+
export * from "./PromptFormatTextStreamingModel.js";
|
6
7
|
export * from "./TextPromptFormat.js";
|
7
8
|
export * from "./VicunaPromptFormat.js";
|
8
9
|
export * from "./chat/ChatPrompt.js";
|
package/prompt/index.js
CHANGED
@@ -3,6 +3,7 @@ export * from "./InstructionPrompt.js";
|
|
3
3
|
export * from "./Llama2PromptFormat.js";
|
4
4
|
export * from "./PromptFormat.js";
|
5
5
|
export * from "./PromptFormatTextGenerationModel.js";
|
6
|
+
export * from "./PromptFormatTextStreamingModel.js";
|
6
7
|
export * from "./TextPromptFormat.js";
|
7
8
|
export * from "./VicunaPromptFormat.js";
|
8
9
|
export * from "./chat/ChatPrompt.js";
|
package/retriever/Retriever.d.ts
CHANGED
@@ -1,7 +1,4 @@
|
|
1
|
-
import {
|
2
|
-
export interface
|
3
|
-
|
4
|
-
export interface Retriever<OBJECT, QUERY, SETTINGS extends RetrieverSettings> {
|
5
|
-
retrieve(query: QUERY, options?: ModelFunctionOptions<RetrieverSettings>): Promise<OBJECT[]>;
|
6
|
-
withSettings(additionalSettings: Partial<SETTINGS>): this;
|
1
|
+
import { FunctionOptions } from "core";
|
2
|
+
export interface Retriever<OBJECT, QUERY> {
|
3
|
+
retrieve(query: QUERY, options?: FunctionOptions): Promise<OBJECT[]>;
|
7
4
|
}
|
package/retriever/retrieve.cjs
CHANGED
@@ -69,9 +69,9 @@ async function retrieve(retriever, query, options) {
|
|
69
69
|
eventType: "finished",
|
70
70
|
result: {
|
71
71
|
status: "success",
|
72
|
-
|
72
|
+
value: result.value,
|
73
73
|
},
|
74
74
|
});
|
75
|
-
return result.
|
75
|
+
return result.value;
|
76
76
|
}
|
77
77
|
exports.retrieve = retrieve;
|
package/retriever/retrieve.d.ts
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
import {
|
2
|
-
import { Retriever
|
3
|
-
export declare function retrieve<OBJECT, QUERY
|
1
|
+
import { FunctionOptions } from "../core/FunctionOptions.js";
|
2
|
+
import { Retriever } from "./Retriever.js";
|
3
|
+
export declare function retrieve<OBJECT, QUERY>(retriever: Retriever<OBJECT, QUERY>, query: QUERY, options?: FunctionOptions): Promise<OBJECT[]>;
|
package/retriever/retrieve.js
CHANGED
package/tool/executeTool.cjs
CHANGED
@@ -115,12 +115,12 @@ async function doExecuteTool(tool, input, options) {
|
|
115
115
|
message: result.error?.message,
|
116
116
|
});
|
117
117
|
}
|
118
|
-
const output = result.
|
118
|
+
const output = result.value;
|
119
119
|
eventSource.notify({
|
120
120
|
...finishMetadata,
|
121
121
|
result: {
|
122
122
|
status: "success",
|
123
|
-
output,
|
123
|
+
value: output,
|
124
124
|
},
|
125
125
|
});
|
126
126
|
return {
|
package/tool/executeTool.js
CHANGED
@@ -110,12 +110,12 @@ async function doExecuteTool(tool, input, options) {
|
|
110
110
|
message: result.error?.message,
|
111
111
|
});
|
112
112
|
}
|
113
|
-
const output = result.
|
113
|
+
const output = result.value;
|
114
114
|
eventSource.notify({
|
115
115
|
...finishMetadata,
|
116
116
|
result: {
|
117
117
|
status: "success",
|
118
|
-
output,
|
118
|
+
value: output,
|
119
119
|
},
|
120
120
|
});
|
121
121
|
return {
|
package/tool/useTool.cjs
CHANGED
@@ -10,14 +10,12 @@ const executeTool_js_1 = require("./executeTool.cjs");
|
|
10
10
|
* the parameters (`parameters` property, typed),
|
11
11
|
* and the result of the tool execution (`result` property, typed).
|
12
12
|
*/
|
13
|
-
async function useTool(
|
14
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
15
|
-
model, tool, prompt, options) {
|
13
|
+
async function useTool(model, tool, prompt, options) {
|
16
14
|
// Note: PROMPT must not be a function.
|
17
15
|
const expandedPrompt = typeof prompt === "function"
|
18
16
|
? prompt(tool)
|
19
17
|
: prompt;
|
20
|
-
const {
|
18
|
+
const { value } = await (0, generateStructure_js_1.generateStructure)(model, {
|
21
19
|
name: tool.name,
|
22
20
|
description: tool.description,
|
23
21
|
schema: tool.inputSchema,
|
package/tool/useTool.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import { FunctionOptions } from "../core/FunctionOptions.js";
|
2
2
|
import { StructureGenerationModel, StructureGenerationModelSettings } from "../model-function/generate-structure/StructureGenerationModel.js";
|
3
3
|
import { Tool } from "./Tool.js";
|
4
4
|
/**
|
@@ -8,7 +8,7 @@ import { Tool } from "./Tool.js";
|
|
8
8
|
* the parameters (`parameters` property, typed),
|
9
9
|
* and the result of the tool execution (`result` property, typed).
|
10
10
|
*/
|
11
|
-
export declare function useTool<PROMPT,
|
11
|
+
export declare function useTool<PROMPT, TOOL extends Tool<any, any, any>>(model: StructureGenerationModel<PROMPT, StructureGenerationModelSettings>, tool: TOOL, prompt: PROMPT | ((tool: TOOL) => PROMPT), options?: FunctionOptions): Promise<{
|
12
12
|
tool: TOOL["name"];
|
13
13
|
parameters: TOOL["inputSchema"];
|
14
14
|
result: Awaited<ReturnType<TOOL["execute"]>>;
|
package/tool/useTool.js
CHANGED
@@ -7,14 +7,12 @@ import { executeTool } from "./executeTool.js";
|
|
7
7
|
* the parameters (`parameters` property, typed),
|
8
8
|
* and the result of the tool execution (`result` property, typed).
|
9
9
|
*/
|
10
|
-
export async function useTool(
|
11
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
12
|
-
model, tool, prompt, options) {
|
10
|
+
export async function useTool(model, tool, prompt, options) {
|
13
11
|
// Note: PROMPT must not be a function.
|
14
12
|
const expandedPrompt = typeof prompt === "function"
|
15
13
|
? prompt(tool)
|
16
14
|
: prompt;
|
17
|
-
const {
|
15
|
+
const { value } = await generateStructure(model, {
|
18
16
|
name: tool.name,
|
19
17
|
description: tool.description,
|
20
18
|
schema: tool.inputSchema,
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import { FunctionOptions } from "../core/FunctionOptions.js";
|
2
2
|
import { StructureOrTextGenerationModel, StructureOrTextGenerationModelSettings } from "../model-function/generate-structure/StructureOrTextGenerationModel.js";
|
3
3
|
import { Tool } from "./Tool.js";
|
4
4
|
type ToolArray<T extends Tool<any, any, any>[]> = T;
|
@@ -14,7 +14,7 @@ type ToToolUnion<T> = {
|
|
14
14
|
} : never;
|
15
15
|
}[keyof T];
|
16
16
|
type ToOutputValue<TOOLS extends ToolArray<Tool<any, any, any>[]>> = ToToolUnion<ToToolMap<TOOLS>>;
|
17
|
-
export declare function useToolOrGenerateText<PROMPT,
|
17
|
+
export declare function useToolOrGenerateText<PROMPT, SETTINGS extends StructureOrTextGenerationModelSettings, TOOLS extends Array<Tool<any, any, any>>>(model: StructureOrTextGenerationModel<PROMPT, SETTINGS>, tools: TOOLS, prompt: PROMPT | ((tools: TOOLS) => PROMPT), options?: FunctionOptions): Promise<{
|
18
18
|
tool: null;
|
19
19
|
parameters: null;
|
20
20
|
result: null;
|
package/util/SafeResult.d.ts
CHANGED
package/util/runSafe.cjs
CHANGED
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.runSafe = void 0;
|
4
4
|
const runSafe = async (f) => {
|
5
5
|
try {
|
6
|
-
return { ok: true,
|
6
|
+
return { ok: true, value: await f() };
|
7
7
|
}
|
8
8
|
catch (error) {
|
9
9
|
if (error instanceof Error && error.name === "AbortError") {
|
package/util/runSafe.js
CHANGED
@@ -31,13 +31,6 @@ class VectorIndexRetriever {
|
|
31
31
|
};
|
32
32
|
}
|
33
33
|
async retrieve(query, options) {
|
34
|
-
if (options?.settings != null) {
|
35
|
-
return this.withSettings(options.settings).retrieve(query, {
|
36
|
-
functionId: options.functionId,
|
37
|
-
observers: options.observers,
|
38
|
-
run: options.run,
|
39
|
-
});
|
40
|
-
}
|
41
34
|
const embedding = await (0, embed_js_1.embed)(this.embeddingModel, query, {
|
42
35
|
functionId: options?.functionId,
|
43
36
|
run: options?.run,
|
@@ -1,20 +1,20 @@
|
|
1
|
+
import { FunctionOptions } from "../core/FunctionOptions.js";
|
1
2
|
import { EmbeddingModel, EmbeddingModelSettings } from "../model-function/embed/EmbeddingModel.js";
|
2
|
-
import {
|
3
|
-
import { Retriever, RetrieverSettings } from "../retriever/Retriever.js";
|
3
|
+
import { Retriever } from "../retriever/Retriever.js";
|
4
4
|
import { VectorIndex } from "./VectorIndex.js";
|
5
5
|
export interface VectorIndexRetrieverSettings<FILTER> {
|
6
6
|
maxResults?: number;
|
7
7
|
similarityThreshold?: number;
|
8
8
|
filter?: FILTER;
|
9
9
|
}
|
10
|
-
export declare class VectorIndexRetriever<OBJECT, VALUE, INDEX, FILTER> implements Retriever<OBJECT, VALUE
|
10
|
+
export declare class VectorIndexRetriever<OBJECT, VALUE, INDEX, FILTER> implements Retriever<OBJECT, VALUE> {
|
11
11
|
private readonly vectorIndex;
|
12
12
|
private readonly embeddingModel;
|
13
13
|
private readonly settings;
|
14
14
|
constructor({ vectorIndex, embeddingModel, maxResults, similarityThreshold, filter, }: {
|
15
15
|
vectorIndex: VectorIndex<OBJECT, INDEX, FILTER>;
|
16
|
-
embeddingModel: EmbeddingModel<VALUE,
|
16
|
+
embeddingModel: EmbeddingModel<VALUE, EmbeddingModelSettings>;
|
17
17
|
} & VectorIndexRetrieverSettings<FILTER>);
|
18
|
-
retrieve(query: VALUE, options?:
|
18
|
+
retrieve(query: VALUE, options?: FunctionOptions): Promise<OBJECT[]>;
|
19
19
|
withSettings(additionalSettings: Partial<VectorIndexRetrieverSettings<FILTER>>): this;
|
20
20
|
}
|
@@ -28,13 +28,6 @@ export class VectorIndexRetriever {
|
|
28
28
|
};
|
29
29
|
}
|
30
30
|
async retrieve(query, options) {
|
31
|
-
if (options?.settings != null) {
|
32
|
-
return this.withSettings(options.settings).retrieve(query, {
|
33
|
-
functionId: options.functionId,
|
34
|
-
observers: options.observers,
|
35
|
-
run: options.run,
|
36
|
-
});
|
37
|
-
}
|
38
31
|
const embedding = await embed(this.embeddingModel, query, {
|
39
32
|
functionId: options?.functionId,
|
40
33
|
run: options?.run,
|
@@ -1,11 +1,11 @@
|
|
1
|
-
import {
|
1
|
+
import { FunctionOptions } from "../core/FunctionOptions.js";
|
2
2
|
import { EmbeddingModel, EmbeddingModelSettings } from "../model-function/embed/EmbeddingModel.js";
|
3
3
|
import { VectorIndex } from "./VectorIndex.js";
|
4
|
-
export declare function upsertIntoVectorIndex<VALUE, OBJECT
|
4
|
+
export declare function upsertIntoVectorIndex<VALUE, OBJECT>({ vectorIndex, embeddingModel, generateId, objects, getValueToEmbed, getId, }: {
|
5
5
|
vectorIndex: VectorIndex<OBJECT, unknown, unknown>;
|
6
|
-
embeddingModel: EmbeddingModel<VALUE,
|
6
|
+
embeddingModel: EmbeddingModel<VALUE, EmbeddingModelSettings>;
|
7
7
|
generateId?: () => string;
|
8
8
|
objects: OBJECT[];
|
9
9
|
getValueToEmbed: (object: OBJECT, index: number) => VALUE;
|
10
10
|
getId?: (object: OBJECT, index: number) => string | undefined;
|
11
|
-
}, options?:
|
11
|
+
}, options?: FunctionOptions): Promise<void>;
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|