@rws-framework/ai-tools 3.6.0 → 3.8.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/.bin/add-v.sh CHANGED
File without changes
File without changes
File without changes
File without changes
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@rws-framework/ai-tools",
3
3
  "private": false,
4
- "version": "3.6.0",
4
+ "version": "3.8.0",
5
5
  "description": "",
6
6
  "main": "src/index.ts",
7
7
  "scripts": {},
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -127,15 +127,15 @@ export class LangChainEmbeddingService {
127
127
  /**
128
128
  * Split text into chunks
129
129
  */
130
- async chunkText(text: string): Promise<string[]> {
130
+ async chunkText(text: string, ragOverride?: IChunkConfig): Promise<string[]> {
131
131
  this.ensureInitialized();
132
132
 
133
133
  // Use our custom TextChunker instead of LangChain's splitter
134
134
  // Use safe token limits - the TextChunker handles token estimation internally
135
- const maxTokens = this.chunkConfig?.chunkSize || 450; // Safe token limit for embedding models
136
- const overlap = this.chunkConfig?.chunkOverlap || 50; // Character overlap, not token
137
-
138
- return TextChunker.chunkText(text, maxTokens, overlap);
135
+ const maxTokens = ragOverride ? ragOverride.chunkSize : (this.chunkConfig?.chunkSize || 450); // Safe token limit for embedding models
136
+ const overlap = ragOverride ? ragOverride.chunkOverlap : (this.chunkConfig?.chunkOverlap || 50); // Character overlap, not token
137
+ const separators = ragOverride?.separators || this.chunkConfig?.separators || TextChunker.DEFAULT_SEPARATORS; // Default separators
138
+ return TextChunker.chunkText(text, maxTokens, overlap, separators);
139
139
  }
140
140
 
141
141
  /**
@@ -85,7 +85,8 @@ export class LangChainRAGService {
85
85
  async indexKnowledge(
86
86
  fileId: string | number,
87
87
  content: string,
88
- metadata: Record<string, any> = {}
88
+ metadata: Record<string, any> = {},
89
+ ragOverride?: IChunkConfig
89
90
  ): Promise<IRAGResponse<{ chunkIds: string[] }>> {
90
91
  this.log('log', `[INDEXING] Starting indexKnowledge for fileId: ${fileId}`);
91
92
  this.log('debug', `[INDEXING] Content length: ${content.length} characters`);
@@ -94,7 +95,7 @@ export class LangChainRAGService {
94
95
  await this.ensureInitialized();
95
96
 
96
97
  // Chunk the content using the embedding service
97
- const chunks = await this.embeddingService.chunkText(content);
98
+ const chunks = await this.embeddingService.chunkText(content, ragOverride);
98
99
  this.log('debug', `[INDEXING] Split content into ${chunks.length} chunks for file ${fileId}`);
99
100
 
100
101
  // Generate embeddings for all chunks at once (batch processing for speed)
File without changes
File without changes
File without changes
File without changes
@@ -4,6 +4,7 @@ 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
6
  import z4, { Schema } from 'zod/v4';
7
+ import { z } from 'zod'; // Import regular zod for zodSchema
7
8
 
8
9
  // General tool interfaces for AI models
9
10
  interface IAIToolParameterBase {
@@ -49,7 +50,8 @@ interface IAITool {
49
50
  name: string;
50
51
  description: string;
51
52
  input_schema?: IAIToolSchema;
52
- transparent?: boolean;
53
+ zodSchema?: z.ZodTypeAny; // Support for regular Zod schemas
54
+ blockStream?: boolean;
53
55
  }
54
56
 
55
57
  interface IPromptHyperParameters {
File without changes
File without changes
File without changes
File without changes
File without changes