I’m developing an app that uses Chroma to store vectors. I’m running into the problem that initialy an operation is running fine but after a page refresh I’m getting the following notice: Please install chromadb-default-embed as a dependency with, e.g. npm install chromadb-default-embed. Installing it won´t solve the problem though. It just keeps showing the same behavior of running fine at initial load but after a page refresh it gives me this error.
Below is my code for reference (NuxtJs3)
import { getQuery } from 'h3';
import prisma from '~/server/utils/prisma';
import { ChromaClient } from 'chromadb';
const chromaClient = new ChromaClient();
export default defineEventHandler(async (e) => {
const { userUuid } = getQuery(e);
try {
const user = await prisma.user.findUnique({
where: {
uuid: userUuid
}
});
const { sex, preference, goal } = user;
console.log(sex, preference, goal);
let collection = await chromaClient.getCollection({ name: 'bios' });
const bios = await collection.get({
ids: [userUuid]
});
if (bios.documents.length > 0 && sex && goal) {
let where = {
where: {
'uuid': {
'$ne': userUuid
}
},
'$and': {
'goal': {
'$eq': goal
}
}
};
if (preference) {
where['$and'] = {
'sex': preference
}
}
else {
where['$or'] = [{
'sex': 'Male'
}, {
'sex': 'Female'
}];
where['$or'] = [{
'preference': sex
}, {
'preference': null
}];
}
console.log(where);
const matches = await collection.query({
queryTexts: [bios.documents[0]],
where,
nResults: 3
});
console.log(matches);
}
}
catch (error) {
console.error(error);
throw createError({
statusCode: 500,
message: error
});
}
});
