feat(utils): move hash into utils

This commit is contained in:
ItzCrazyKns
2026-03-26 22:19:48 +05:30
parent 0c101d9704
commit 58ed869b3d
3 changed files with 9 additions and 3 deletions

View File

@@ -1,7 +1,7 @@
import path from 'node:path'; import path from 'node:path';
import fs from 'fs'; import fs from 'fs';
import { Config, ConfigModelProvider, UIConfigSections } from './types'; import { Config, ConfigModelProvider, UIConfigSections } from './types';
import { hashObj } from '../serverUtils'; import { hashObj } from '../utils/hash';
import { getModelProvidersUIConfigSection } from '../models/providers'; import { getModelProvidersUIConfigSection } from '../models/providers';
class ConfigManager { class ConfigManager {

View File

@@ -2,8 +2,7 @@ import BaseEmbedding from "../models/base/embedding";
import UploadManager from "./manager"; import UploadManager from "./manager";
import computeSimilarity from "../utils/computeSimilarity"; import computeSimilarity from "../utils/computeSimilarity";
import { Chunk } from "../types"; import { Chunk } from "../types";
import { hashObj } from "../serverUtils"; import { hashObj } from '../utils/hash';
import fs from 'fs';
type UploadStoreParams = { type UploadStoreParams = {
embeddingModel: BaseEmbedding<any>; embeddingModel: BaseEmbedding<any>;

7
src/lib/utils/hash.ts Normal file
View File

@@ -0,0 +1,7 @@
import crypto from 'crypto';
export const hashObj = (obj: { [key: string]: any }) => {
const json = JSON.stringify(obj, Object.keys(obj).sort());
const hash = crypto.createHash('sha256').update(json).digest('hex');
return hash;
};