mirror of
https://github.com/abhigyanpatwari/GitNexus.git
synced 2026-10-29 06:32:28 +00:00
fix: remove pipeline as any cast; type progress callback with ProgressInfo; remove unused HF_DOWNLOAD_TIMEOUT_MS import
Agent-Logs-Url: https://github.com/abhigyanpatwari/GitNexus/sessions/43e60ccd-6f01-4cec-8ee3-c22e8b000efe Co-authored-by: magyargergo <11230420+magyargergo@users.noreply.github.com>
This commit is contained in:
parent
e6de518777
commit
f5b62e4e23
3 changed files with 14 additions and 10 deletions
|
|
@ -14,7 +14,12 @@ if (!process.env.ORT_LOG_LEVEL) {
|
|||
process.env.ORT_LOG_LEVEL = '3';
|
||||
}
|
||||
|
||||
import { pipeline, env, type FeatureExtractionPipeline } from '@huggingface/transformers';
|
||||
import {
|
||||
pipeline,
|
||||
env,
|
||||
type FeatureExtractionPipeline,
|
||||
type ProgressInfo,
|
||||
} from '@huggingface/transformers';
|
||||
import { existsSync } from 'fs';
|
||||
import { execFileSync } from 'child_process';
|
||||
import { join, dirname } from 'path';
|
||||
|
|
@ -171,13 +176,13 @@ export const initEmbedder = async (
|
|||
}
|
||||
|
||||
const progressCallback = onProgress
|
||||
? (data: any) => {
|
||||
? (data: ProgressInfo) => {
|
||||
const progress: ModelProgress = {
|
||||
status: data.status || 'progress',
|
||||
file: data.file,
|
||||
progress: data.progress,
|
||||
loaded: data.loaded,
|
||||
total: data.total,
|
||||
status: data.status === 'progress_total' ? 'progress' : data.status,
|
||||
file: 'file' in data ? data.file : undefined,
|
||||
progress: 'progress' in data ? data.progress : undefined,
|
||||
loaded: 'loaded' in data ? data.loaded : undefined,
|
||||
total: 'total' in data ? data.total : undefined,
|
||||
};
|
||||
onProgress(progress);
|
||||
}
|
||||
|
|
@ -204,7 +209,7 @@ export const initEmbedder = async (
|
|||
|
||||
embedderInstance = await withHfDownloadRetry(
|
||||
() =>
|
||||
(pipeline as any)('feature-extraction', finalConfig.modelId, {
|
||||
pipeline('feature-extraction', finalConfig.modelId, {
|
||||
device: device,
|
||||
dtype: 'fp32',
|
||||
progress_callback: progressCallback,
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ export const initEmbedder = async (): Promise<FeatureExtractionPipeline> => {
|
|||
process.stderr.write = (() => true) as any;
|
||||
try {
|
||||
embedderInstance = await withHfDownloadRetry(() =>
|
||||
(pipeline as any)('feature-extraction', MODEL_ID, {
|
||||
pipeline('feature-extraction', MODEL_ID, {
|
||||
device: device,
|
||||
dtype: 'fp32',
|
||||
session_options: {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ import {
|
|||
withDownloadTimeout,
|
||||
withHfDownloadRetry,
|
||||
CIRCUIT_OPEN_TAG,
|
||||
HF_DOWNLOAD_TIMEOUT_MS,
|
||||
HF_MAX_ATTEMPTS,
|
||||
HF_MAX_TIMEOUT_MS,
|
||||
HF_MAX_ATTEMPTS_CAP,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue