feat(server): split embedding client (#12809)

This commit is contained in:
DarkSky
2025-06-13 12:37:05 +08:00
committed by GitHub
parent 1d4bc81e90
commit e98f035f97
12 changed files with 32 additions and 39 deletions
@@ -11,11 +11,11 @@ import {
FileChunkSimilarity,
Models,
} from '../../../models';
import { EmbeddingClient } from './types';
import { EmbeddingClient } from '../embedding';
export class ContextSession implements AsyncDisposable {
constructor(
private readonly client: EmbeddingClient,
private readonly client: EmbeddingClient | undefined,
private readonly contextId: string,
private readonly config: ContextConfig,
private readonly models: Models,
@@ -204,6 +204,7 @@ export class ContextSession implements AsyncDisposable {
scopedThreshold: number = 0.85,
threshold: number = 0.5
): Promise<FileChunkSimilarity[]> {
if (!this.client) return [];
const embedding = await this.client.getEmbedding(content, signal);
if (!embedding) return [];
@@ -256,6 +257,7 @@ export class ContextSession implements AsyncDisposable {
scopedThreshold: number = 0.85,
threshold: number = 0.5
) {
if (!this.client) return [];
const embedding = await this.client.getEmbedding(content, signal);
if (!embedding) return [];