@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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@rws-framework/ai-tools",
3
3
  "private": false,
4
- "version": "1.0.5",
4
+ "version": "1.1.0",
5
5
  "description": "",
6
6
  "main": "src/index.ts",
7
7
  "scripts": {},
@@ -25,16 +25,18 @@ interface ILLMChunk {
25
25
 
26
26
  interface IPromptParams {
27
27
  hyperParameters?: IPromptHyperParameters;
28
- input?: string;
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: string
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: string;
60
+ input: CompoundInput[];
59
61
  enhancedInput: IPromptEnchantment[];
60
- sentInput: string;
61
- originalInput: string;
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: string = '';
88
+ private input: CompoundInput[] = [];
77
89
  private enhancedInput: IPromptEnchantment[];
78
- private sentInput: string = '';
79
- private originalInput: string = '';
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 = enchantment.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(): string
151
+ readSentInput(): CompoundInput[]
140
152
  {
141
153
  return this.sentInput;
142
154
  }
143
155
 
144
- readInput(): string
156
+ readInput(): CompoundInput[]
145
157
  {
146
158
  return this.input;
147
159
  }
148
160
 
149
161
 
150
- readBaseInput(): string
162
+ readBaseInput(): CompoundInput[]
151
163
  {
152
164
  return this.originalInput;
153
165
  }
154
166
 
155
- setBaseInput(input: string): RWSPrompt
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
- setInput(content: string): RWSPrompt
270
+ addInput(content: CompoundInput): RWSPrompt
259
271
  {
260
- this.input = content;
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 + this.input;
361
+ this.input = [{type: 'text', text: prompt}, ...this.input];
350
362
  }
351
363
  }
352
364