@rws-framework/ai-tools 3.0.0 → 3.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": "3.0.0",
4
+ "version": "3.1.1",
5
5
  "description": "",
6
6
  "main": "src/index.ts",
7
7
  "scripts": {},
@@ -15,7 +15,8 @@
15
15
  "@rws-framework/db": "*",
16
16
  "@rws-framework/console": "*",
17
17
  "uuid": "^9.0.0",
18
- "xml2js": "^0.6.2"
18
+ "xml2js": "^0.6.2",
19
+ "zod": "^3.25.76"
19
20
  },
20
21
  "devDependencies": {
21
22
  "@types/xml2js": "^0.4.14"
package/src/index.ts CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- import RWSPrompt, { IChainCallOutput } from '@rws-framework/ai-tools/src/models/prompts/_prompt';
2
+ import RWSPrompt, { IChainCallOutput } from './models/prompts/_prompt';
3
3
  import { ILLMChunk, IRWSPromptRequestExecutor, IRWSSinglePromptRequestExecutor, IRWSPromptStreamExecutor, IRWSPromptJSON, ChainStreamType, IAIRequestOptions, IAITool, IAIToolSchema, IAIToolParameter, IToolCall, ToolHandler } from './types/IPrompt';
4
4
  import { EmbedLoader as RWSEmbed, IConvoDebugXMLData, IEmbeddingsHandler, ISplitterParams } from './models/convo/EmbedLoader';
5
5
  import RWSVectorStore from './models/convo/VectorStore';
@@ -9,8 +9,10 @@ import { LangChainRAGService, ILangChainRAGConfig, IRAGIndexRequest, IRAGSearchR
9
9
  import { IContextToken } from './types/IContextToken';
10
10
  import { IEmbeddingConfig, IChunkConfig } from './types';
11
11
  import type { IAiCfg } from './types/IAiCfg';
12
+ import { z as ZOD } from 'zod/v4';
12
13
 
13
14
  export {
15
+ ZOD,
14
16
  IAiCfg,
15
17
  RWSVectorStore,
16
18
  RWSEmbed,
@@ -69,7 +69,7 @@ class RWSPrompt implements IPromptInstance {
69
69
  }
70
70
 
71
71
  // Delegation methods for input/output management
72
- listen(source: string, stream: boolean = true): RWSPrompt {
72
+ listen(source: string | object, stream: boolean = true): RWSPrompt {
73
73
  this.ioManager.listen(source, stream);
74
74
  return this;
75
75
  }
@@ -108,7 +108,7 @@ class RWSPrompt implements IPromptInstance {
108
108
  return this;
109
109
  }
110
110
 
111
- readOutput(): string {
111
+ readOutput(): string | object {
112
112
  return this.ioManager.readOutput();
113
113
  }
114
114
 
@@ -7,11 +7,11 @@ import {
7
7
  } from './types';
8
8
 
9
9
  export interface IPromptInstance {
10
- readOutput(): string;
10
+ readOutput(): string | object;
11
11
  readInput(): any[];
12
12
  getInput(): any[];
13
13
  setSentInput(input: any[]): void;
14
- injestOutput(content: string): void;
14
+ injestOutput(content: string | object): void;
15
15
  }
16
16
 
17
17
  export class ExecutionMethodsHandler {
@@ -5,7 +5,7 @@ export class InputOutputManager {
5
5
  private enhancedInput: IPromptEnchantment[] = [];
6
6
  private sentInput: CompoundInput[] = [];
7
7
  private originalInput: CompoundInput[] = [];
8
- private output: string = '';
8
+ private output: string | object = null;
9
9
  private onStream: (chunk: string) => void = () => {};
10
10
 
11
11
  constructor(input: CompoundInput[]) {
@@ -54,18 +54,20 @@ export class InputOutputManager {
54
54
  this.output = content;
55
55
  }
56
56
 
57
- readOutput(): string {
57
+ readOutput(): string | object{
58
58
  return this.output;
59
59
  }
60
60
 
61
- listen(source: string, stream: boolean = true): void {
62
- this.output = '';
61
+ listen(source: string | object, stream: boolean = true): void {
62
+ if(stream){
63
+ this.output = '';
64
+ }
63
65
 
64
66
  if (!stream) {
65
67
  this.output = source;
66
68
  } else {
67
- this.output += source;
68
- this.onStream(source);
69
+ this.output += source as string;
70
+ this.onStream(source as string);
69
71
  }
70
72
  }
71
73
 
@@ -114,7 +116,7 @@ export class InputOutputManager {
114
116
  return this.originalInput;
115
117
  }
116
118
 
117
- getOutput(): string {
119
+ getOutput(): string | object {
118
120
  return this.output;
119
121
  }
120
122
  }
@@ -3,6 +3,7 @@ import { IterableReadableStream } from '@langchain/core/utils/stream';
3
3
  import { ChainValues } from '@langchain/core/utils/types';
4
4
  import { IContextToken } from './IContextToken';
5
5
  import { BaseChatModel } from '@langchain/core/language_models/chat_models';
6
+ import z4, { Schema } from 'zod/v4';
6
7
 
7
8
  // General tool interfaces for AI models
8
9
  interface IAIToolParameterBase {
@@ -92,6 +93,7 @@ interface IAIRequestOptions {
92
93
  intruderPrompt?: string | null,
93
94
  ensureJson?: boolean,
94
95
  debugVars?: any,
96
+ schema?: z4.core.$ZodType | Schema,
95
97
  tools?: IAITool[]
96
98
  }
97
99
 
@@ -114,7 +116,7 @@ interface IRWSPromptJSON {
114
116
  enhancedInput: IPromptEnchantment[];
115
117
  sentInput: CompoundInput[];
116
118
  originalInput: CompoundInput[];
117
- output: string;
119
+ output: string | object;
118
120
  modelId: string;
119
121
  modelType: string;
120
122
  multiTemplate: PromptTemplate;