add fix to HF endpoint

This commit is contained in:
Henry
2023-07-08 21:31:43 +01:00
parent 6a7e378baf
commit 3cda348e95
3 changed files with 21 additions and 14 deletions
@@ -30,12 +30,11 @@ export class HuggingFaceInferenceEmbeddings extends Embeddings implements Huggin
async _embed(texts: string[]): Promise<number[][]> {
// replace newlines, which can negatively affect performance.
const clean = texts.map((text) => text.replace(/\n/g, ' '))
return this.caller.call(() =>
this.client.featureExtraction({
model: this.model,
inputs: clean
})
) as Promise<number[][]>
const obj: any = {
inputs: clean
}
if (!this.endpoint) obj.model = this.model
return this.caller.call(() => this.client.featureExtraction(obj)) as Promise<number[][]>
}
embedQuery(document: string): Promise<number[]> {