@yesvara/svara 0.1.1 → 0.1.3

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/src/core/agent.ts CHANGED
@@ -173,6 +173,7 @@ export class SvaraAgent extends EventEmitter {
173
173
  private retriever: any = null; // Store VectorRetriever for retrieveChunks access
174
174
  private knowledgePaths: string[] = [];
175
175
  private isStarted = false;
176
+ private isKnowledgeInitialized = false;
176
177
  private db: SvaraDB;
177
178
 
178
179
  constructor(config: AgentConfig) {
@@ -303,6 +304,17 @@ export class SvaraAgent extends EventEmitter {
303
304
  */
304
305
  handler(): RequestHandler {
305
306
  return async (req, res) => {
307
+ // Auto-initialize knowledge on first request (lazy loading)
308
+ if (this.knowledgePaths.length > 0 && !this.isKnowledgeInitialized) {
309
+ try {
310
+ await this.initKnowledge(this.knowledgePaths);
311
+ this.isKnowledgeInitialized = true;
312
+ } catch (err) {
313
+ const error = err as Error;
314
+ this.log('error', `Failed to initialize knowledge: ${error.message}`);
315
+ }
316
+ }
317
+
306
318
  const { message, sessionId, userId } = req.body as {
307
319
  message?: string;
308
320
  sessionId?: string;
package/svara@1.0.0 DELETED
File without changes
package/test-rag.ts DELETED
@@ -1,20 +0,0 @@
1
- import 'dotenv/config';
2
- import { SvaraApp, SvaraAgent } from './src/index.js';
3
-
4
- async function main() {
5
- const app = new SvaraApp({ cors: true });
6
-
7
- const agent = new SvaraAgent({
8
- name: 'TestAgent',
9
- model: 'gpt-4o-mini',
10
- knowledge: '/Users/920078/Documents/svara/contoh_folder_knowledge/**/*',
11
- verbose: true,
12
- });
13
-
14
- await agent.start();
15
- app.route('/chat', agent.handler());
16
- app.listen(3000);
17
- console.log('✓ Test server on port 3000');
18
- }
19
-
20
- main().catch(console.error);
package/tsx DELETED
File without changes