diff options
| author | Dhravya Shah <[email protected]> | 2024-06-17 07:26:58 -0500 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-06-17 07:26:58 -0500 |
| commit | 5af20f7b6f2cfceed999dbd9e6244238c82a46b4 (patch) | |
| tree | 8a5737911d5b5e9585e2f8de84025e2651cc7af8 | |
| parent | gpt-4o is already a default model, so no error-checking required (diff) | |
| parent | add js docs (diff) | |
| download | archived-supermemory-5af20f7b6f2cfceed999dbd9e6244238c82a46b4.tar.xz archived-supermemory-5af20f7b6f2cfceed999dbd9e6244238c82a46b4.zip | |
Merge pull request #70 from CodeTorso/codetorso
add js docs
| -rw-r--r-- | apps/cf-ai-backend/src/utils/chonker.ts | 3 | ||||
| -rw-r--r-- | apps/cf-ai-backend/src/utils/seededRandom.ts | 7 |
2 files changed, 10 insertions, 0 deletions
diff --git a/apps/cf-ai-backend/src/utils/chonker.ts b/apps/cf-ai-backend/src/utils/chonker.ts index 39d4b458..c63020be 100644 --- a/apps/cf-ai-backend/src/utils/chonker.ts +++ b/apps/cf-ai-backend/src/utils/chonker.ts @@ -1,5 +1,8 @@ import nlp from "compromise"; +/** + * Split text into chunks of specified max size with some overlap for continuity. + */ export default function chunkText( text: string, maxChunkSize: number, diff --git a/apps/cf-ai-backend/src/utils/seededRandom.ts b/apps/cf-ai-backend/src/utils/seededRandom.ts index 36a1e4f9..9e315ee8 100644 --- a/apps/cf-ai-backend/src/utils/seededRandom.ts +++ b/apps/cf-ai-backend/src/utils/seededRandom.ts @@ -1,5 +1,9 @@ import { MersenneTwister19937, integer } from "random-js"; +/** + * Hashes a string to a 32-bit integer. + * @param {string} seed - The input string to hash. + */ function hashString(seed: string) { let hash = 0; for (let i = 0; i < seed.length; i++) { @@ -10,6 +14,9 @@ function hashString(seed: string) { return hash; } +/** + * returns a funtion that generates same sequence of random numbers for a given seed between 0 and 1. + */ export function seededRandom(seed: string) { const seedHash = hashString(seed); const engine = MersenneTwister19937.seed(seedHash); |