@rws-framework/ai-tools 2.0.4 → 2.1.1

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": "2.0.4",
4
+ "version": "2.1.1",
5
5
  "description": "",
6
6
  "main": "src/index.ts",
7
7
  "scripts": {},
@@ -21,6 +21,7 @@ import {
21
21
  ToolHandler
22
22
  } from '../../types/IPrompt';
23
23
  import { IContextToken } from '../../types/IContextToken';
24
+ import { text } from 'stream/consumers';
24
25
 
25
26
  type EntryParams = {
26
27
  modelId: string,
@@ -31,7 +32,7 @@ type EntryParams = {
31
32
  class RWSPrompt {
32
33
  public _stream: ChainStreamType;
33
34
  private input: CompoundInput[] = [];
34
- private enhancedInput: IPromptEnchantment[];
35
+ private enhancedInput: IPromptEnchantment[] = [];
35
36
  private sentInput: CompoundInput[] = [];
36
37
  private originalInput: CompoundInput[] = [];
37
38
  private output: string = '';
@@ -79,13 +80,12 @@ class RWSPrompt {
79
80
 
80
81
  addEnchantment(enchantment: IPromptEnchantment): void
81
82
  {
82
- this.enhancedInput.push(enchantment);
83
- this.input.push(enchantment.input);
83
+ this.enhancedInput.push(enchantment);
84
84
  }
85
85
 
86
- getEnchantedInput(): string | null
86
+ getEnchantedInputs(): IPromptEnchantment[]
87
87
  {
88
- return this.enhancedInput[this.enhancedInput.length - 1].output;
88
+ return this.enhancedInput;
89
89
  }
90
90
 
91
91
  getModelId(): string
@@ -100,7 +100,8 @@ class RWSPrompt {
100
100
 
101
101
  readInput(): CompoundInput[]
102
102
  {
103
- return this.input;
103
+ const enchantedInput: CompoundInput[] = this.enhancedInput.map(enchantment => ({ role: 'user', type: enchantment.input.type, text: enchantment.input.text }));
104
+ return [...enchantedInput, ...this.input];
104
105
  }
105
106
 
106
107
 
@@ -75,8 +75,7 @@ interface IPromptEnchantment {
75
75
  enhancementId: string,
76
76
  enhancementName: string,
77
77
  enhancementParams: any,
78
- input: CompoundInput
79
- output: string
78
+ input: CompoundInput
80
79
  }
81
80
 
82
81
  // Forward reference to RWSPrompt to avoid circular dependencies
@@ -126,6 +125,7 @@ type ChainStreamType = AsyncGenerator<IterableReadableStream<ChainValues>>;
126
125
  interface CompoundInput {
127
126
  type: InputType,
128
127
  text?: string,
128
+ role?: 'user' | 'assistant' | 'system',
129
129
  source?: {
130
130
  type: string,
131
131
  media_type: string,