Skip to content

Commit

Permalink
lower the treshold
Browse files Browse the repository at this point in the history
  • Loading branch information
indowebdeveloper committed Feb 1, 2025
1 parent b8bcfb8 commit 9dfa137
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions packages/core/src/ragknowledge.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { existsSync } from "fs";
import { join } from "path";
import { embed } from "./embedding.ts";
import { splitChunks } from "./generation.ts";
import elizaLogger from "./logger.ts";
Expand All @@ -9,8 +11,6 @@ import {
KnowledgeScope,
} from "./types.ts";
import { stringToUuid } from "./uuid.ts";
import { existsSync } from "fs";
import { join } from "path";

/**
* Manage knowledge in the database.
Expand Down Expand Up @@ -47,7 +47,7 @@ export class RAGKnowledgeManager implements IRAGKnowledgeManager {
this.knowledgeRoot = opts.knowledgeRoot;
}

private readonly defaultRAGMatchThreshold = 0.85;
private readonly defaultRAGMatchThreshold = 0.75;
private readonly defaultRAGMatchCount = 5;

/**
Expand Down Expand Up @@ -507,7 +507,9 @@ export class RAGKnowledgeManager implements IRAGKnowledgeManager {
try {
const fileSizeKB = new TextEncoder().encode(content).length / 1024;
elizaLogger.info(
`[File Progress] Starting ${file.path} (${fileSizeKB.toFixed(2)} KB)`
`[File Progress] Starting ${file.path} (${fileSizeKB.toFixed(
2
)} KB)`
);

// Generate scoped ID for the file
Expand Down Expand Up @@ -571,8 +573,9 @@ export class RAGKnowledgeManager implements IRAGKnowledgeManager {
// Batch database operations
await Promise.all(
embeddings.map(async (embeddingArray, index) => {
const chunkId =
`${scopedId}-chunk-${i + index}` as UUID;
const chunkId = `${scopedId}-chunk-${
i + index
}` as UUID;
const chunkEmbedding = new Float32Array(embeddingArray);

await this.runtime.databaseAdapter.createKnowledge({
Expand All @@ -599,7 +602,11 @@ export class RAGKnowledgeManager implements IRAGKnowledgeManager {
processedChunks += batch.length;
const batchTime = (Date.now() - batchStart) / 1000;
elizaLogger.info(
`[Batch Progress] ${file.path}: Processed ${processedChunks}/${totalChunks} chunks (${batchTime.toFixed(2)}s for batch)`
`[Batch Progress] ${
file.path
}: Processed ${processedChunks}/${totalChunks} chunks (${batchTime.toFixed(
2
)}s for batch)`
);
}

Expand Down

0 comments on commit 9dfa137

Please sign in to comment.