Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion gitnexus/src/core/embeddings/embedder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ if (!process.env.ORT_LOG_LEVEL) {
}

import { pipeline, env, type FeatureExtractionPipeline } from '@huggingface/transformers';
import os from 'os';
import { existsSync } from 'fs';
import { execFileSync } from 'child_process';
import { join, dirname } from 'path';
Expand Down Expand Up @@ -161,7 +162,7 @@ export const initEmbedder = async (
// ./node_modules/.cache inside its own install dir, which is unwritable
// when gitnexus is installed globally (e.g. /usr/lib/node_modules/).
// Respect HF_HOME if set, otherwise fall back to ~/.cache/huggingface.
env.cacheDir = process.env.HF_HOME ?? `${process.env.HOME}/.cache/huggingface`;
env.cacheDir = process.env.HF_HOME ?? join(os.homedir(), '.cache', 'huggingface');

const isDev = process.env.NODE_ENV === 'development';
if (isDev) {
Expand Down
4 changes: 3 additions & 1 deletion gitnexus/src/mcp/core/embedder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
*/

import { pipeline, env, type FeatureExtractionPipeline } from '@huggingface/transformers';
import os from 'os';
import { join } from 'path';
import {
isHttpMode,
getHttpDimensions,
Expand Down Expand Up @@ -46,7 +48,7 @@ export const initEmbedder = async (): Promise<FeatureExtractionPipeline> => {
// ./node_modules/.cache inside its own install dir, which is unwritable
// when gitnexus is installed globally (e.g. /usr/lib/node_modules/).
// Respect HF_HOME if set, otherwise fall back to ~/.cache/huggingface.
env.cacheDir = process.env.HF_HOME ?? `${process.env.HOME}/.cache/huggingface`;
env.cacheDir = process.env.HF_HOME ?? join(os.homedir(), '.cache', 'huggingface');

console.error('GitNexus: Loading embedding model (first search may take a moment)...');

Expand Down
Loading