Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RAGEmbedding singleton mode issue #188

Open
kangfenmao opened this issue Dec 25, 2024 · 0 comments
Open

RAGEmbedding singleton mode issue #188

kangfenmao opened this issue Dec 25, 2024 · 0 comments
Assignees

Comments

@kangfenmao
Copy link

🐛 Describe the bug

export class RAGEmbedding {
    static singleton;
    static async init(embeddingModel) {
        if (!this.singleton) {
            await embeddingModel.init();
            this.singleton = new RAGEmbedding(embeddingModel);
        }
    }
    static getInstance() {
        return RAGEmbedding.singleton;
    }
    static getEmbedding() {
        return RAGEmbedding.getInstance().embedding;
    }
    static translateChunks(chunks) {
        return chunks.map((chunk) => {
            return {
                pageContent: chunk.pageContent,
                metadata: chunk.metadata,
            };
        });
    }
    embedding;
    constructor(embeddingModel) {
        this.embedding = embeddingModel;
    }
}
//# sourceMappingURL=rag-embedding.js.map

The singleton pattern can cause problems when using multiple APIs

API1: openai
API2: ollama

First embedding text with ollama, then, embedding will always use ollama, never use openai

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants