@rws-framework/ai-tools 1.0.5 → 1.1.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/package.json +1 -1
- package/src/models/prompts/_prompt.ts +28 -16
package/package.json
CHANGED
|
@@ -25,16 +25,18 @@ interface ILLMChunk {
|
|
|
25
25
|
|
|
26
26
|
interface IPromptParams {
|
|
27
27
|
hyperParameters?: IPromptHyperParameters;
|
|
28
|
-
input
|
|
28
|
+
input: CompoundInput[];
|
|
29
29
|
modelId: string;
|
|
30
30
|
modelType: string;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
type InputType = 'text' | 'image';
|
|
34
|
+
|
|
33
35
|
interface IPromptEnchantment {
|
|
34
36
|
enhancementId: string,
|
|
35
37
|
enhancementName: string,
|
|
36
38
|
enhancementParams: any,
|
|
37
|
-
input:
|
|
39
|
+
input: CompoundInput
|
|
38
40
|
output: string
|
|
39
41
|
}
|
|
40
42
|
|
|
@@ -55,10 +57,10 @@ interface IRWSPromptStreamExecutor {
|
|
|
55
57
|
}
|
|
56
58
|
|
|
57
59
|
interface IRWSPromptJSON {
|
|
58
|
-
input:
|
|
60
|
+
input: CompoundInput[];
|
|
59
61
|
enhancedInput: IPromptEnchantment[];
|
|
60
|
-
sentInput:
|
|
61
|
-
originalInput:
|
|
62
|
+
sentInput: CompoundInput[];
|
|
63
|
+
originalInput: CompoundInput[];
|
|
62
64
|
output: string;
|
|
63
65
|
modelId: string;
|
|
64
66
|
modelType: string;
|
|
@@ -71,12 +73,22 @@ interface IRWSPromptJSON {
|
|
|
71
73
|
|
|
72
74
|
type ChainStreamType = AsyncGenerator<IterableReadableStream<ChainValues>>;
|
|
73
75
|
|
|
76
|
+
interface CompoundInput {
|
|
77
|
+
type: InputType,
|
|
78
|
+
text?: string,
|
|
79
|
+
source?: {
|
|
80
|
+
type: string,
|
|
81
|
+
media_type: string,
|
|
82
|
+
data: string
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
74
86
|
class RWSPrompt {
|
|
75
87
|
public _stream: ChainStreamType;
|
|
76
|
-
private input:
|
|
88
|
+
private input: CompoundInput[] = [];
|
|
77
89
|
private enhancedInput: IPromptEnchantment[];
|
|
78
|
-
private sentInput:
|
|
79
|
-
private originalInput:
|
|
90
|
+
private sentInput: CompoundInput[] = [];
|
|
91
|
+
private originalInput: CompoundInput[] = [];
|
|
80
92
|
private output: string = '';
|
|
81
93
|
private modelId: string;
|
|
82
94
|
private modelType: string;
|
|
@@ -123,7 +135,7 @@ class RWSPrompt {
|
|
|
123
135
|
addEnchantment(enchantment: IPromptEnchantment): void
|
|
124
136
|
{
|
|
125
137
|
this.enhancedInput.push(enchantment);
|
|
126
|
-
this.input
|
|
138
|
+
this.input.push(enchantment.input);
|
|
127
139
|
}
|
|
128
140
|
|
|
129
141
|
getEnchantedInput(): string | null
|
|
@@ -136,23 +148,23 @@ class RWSPrompt {
|
|
|
136
148
|
return this.modelId;
|
|
137
149
|
}
|
|
138
150
|
|
|
139
|
-
readSentInput():
|
|
151
|
+
readSentInput(): CompoundInput[]
|
|
140
152
|
{
|
|
141
153
|
return this.sentInput;
|
|
142
154
|
}
|
|
143
155
|
|
|
144
|
-
readInput():
|
|
156
|
+
readInput(): CompoundInput[]
|
|
145
157
|
{
|
|
146
158
|
return this.input;
|
|
147
159
|
}
|
|
148
160
|
|
|
149
161
|
|
|
150
|
-
readBaseInput():
|
|
162
|
+
readBaseInput(): CompoundInput[]
|
|
151
163
|
{
|
|
152
164
|
return this.originalInput;
|
|
153
165
|
}
|
|
154
166
|
|
|
155
|
-
setBaseInput(input:
|
|
167
|
+
setBaseInput(input: CompoundInput[]): RWSPrompt
|
|
156
168
|
{
|
|
157
169
|
this.originalInput = input;
|
|
158
170
|
|
|
@@ -255,9 +267,9 @@ class RWSPrompt {
|
|
|
255
267
|
return executor.promptStream(this, read, end, debugVars);
|
|
256
268
|
}
|
|
257
269
|
|
|
258
|
-
|
|
270
|
+
addInput(content: CompoundInput): RWSPrompt
|
|
259
271
|
{
|
|
260
|
-
this.input
|
|
272
|
+
this.input.push(content);
|
|
261
273
|
return this;
|
|
262
274
|
}
|
|
263
275
|
|
|
@@ -346,7 +358,7 @@ class RWSPrompt {
|
|
|
346
358
|
if(callback){
|
|
347
359
|
callback(messages, prompt);
|
|
348
360
|
}else{
|
|
349
|
-
this.input = prompt
|
|
361
|
+
this.input = [{type: 'text', text: prompt}, ...this.input];
|
|
350
362
|
}
|
|
351
363
|
}
|
|
352
364
|
|