Skip to content

embedjs llama-cpp integration fails to run #180

Open
@GhostDog98

Description

🐛 Describe the bug

To reproduce:

import { RAGApplicationBuilder, TextLoader } from '@llm-tools/embedjs'
import { LlamaCppEmbeddings, LlamaCpp } from '@llm-tools/embedjs-llama-cpp';
import { HNSWDb } from '@llm-tools/embedjs-hnswlib'

const app = await new RAGApplicationBuilder()
    .setModel(new LlamaCpp({modelPath:"./models/Llama-3.2-3B-Instruct-f16.gguf"}))
    .setEmbeddingModel(new LlamaCppEmbeddings({modelPath: "./models/dragon-yi-1-5-9.gguf"}))
    .setVectorDatabase(new HNSWDb())
    .build();

This code works if ran with ollama on both setModel and setEmbeddingModel.
It appears that it fails due to the file at models/embedjs-llama-cpp/src/llama-cpp-embeddings.ts not importing the requisite function getEmbeddingFor as called on line 24. Resulting in error;

TypeError: Cannot read properties of undefined (reading 'getEmbeddingFor')
    at file:///home/ghostdog/private-site/models/embedjs-llama-cpp/src/llama-cpp-embeddings.ts:24:50
    at Array.map (<anonymous>)
    at LlamaCppEmbeddings.embedDocuments (file:///home/ghostdog/private-site/models/embedjs-llama-cpp/src/llama-cpp-embeddings.ts:23:33)
    at LlamaCppEmbeddings.getDimensions (file:///home/ghostdog/private-site/models/embedjs-llama-cpp/src/llama-cpp-embeddings.ts:17:35)
    at RAGApplication.init (file:///home/ghostdog/private-site/core/embedjs/src/core/rag-application.ts:71:88)
    at async RAGApplicationBuilder.build (file:///home/ghostdog/private-site/core/embedjs/src/core/rag-application-builder.ts:46:9)
    at async file:///home/ghostdog/private-site/index.js:40:13

Am i missing any imports or obvious errors?

Metadata

Assignees

Labels

bugSomething isn't workingstale

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions