Add support for custom embedding URL in HypaProcesser

This commit is contained in:
kwaroran
2024-04-29 01:53:27 +09:00
parent 4fe027f306
commit cf8c83c799

View File

@@ -38,7 +38,7 @@ export class HypaProcesser{
}
async getEmbeds(input:string[]|string) {
async getEmbeds(input:string[]|string):Promise<VectorArray[]> {
if(this.model === 'MiniLM' || this.model === 'nomic'){
const inputs:string[] = Array.isArray(input) ? input : [input]
let results:Float32Array[] = await runEmbedding(inputs, this.model === 'nomic' ? 'nomic-ai/nomic-embed-text-v1.5' : 'Xenova/all-MiniLM-L6-v2')
@@ -47,8 +47,7 @@ export class HypaProcesser{
let gf = null;
if(this.model === 'custom'){
if(!this.customEmbeddingUrl){
alertError('Custom model requires a Custom Server URL')
return [0]
throw new Error('Custom model requires a Custom Server URL')
}
const {customEmbeddingUrl} = this
const replaceUrl = customEmbeddingUrl.endsWith('/embeddings')?customEmbeddingUrl:appendLastPath(customEmbeddingUrl,'embeddings')