mirror of
https://github.com/ItzCrazyKns/Perplexica.git
synced 2026-03-28 23:44:25 +00:00
feat(utils): move hash into utils
This commit is contained in:
@@ -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 {
|
||||||
|
|||||||
@@ -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
7
src/lib/utils/hash.ts
Normal 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;
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user