I am trying to use Chromadb with langchain. I have a docker running and installed everything it says to on the documentation.
I keep getting these errors when running the code if the docker is on
Generated documents: [
Document {
pageContent: `["Tortoise: Labyrinth? Labyrinth? Could it Are we in the notorious Little\\n Harmonic Labyrinth of the dreaded Majotaur?","Achilles: Yiikes! What is that?","Tortoise: They say-although I person never believed it myself-that an I\\n Majotaur has created a tiny labyrinth sits in a pit in the middle of\\n it, waiting innocent victims to get lost in its fears complexity.\\n Then, when they wander and dazed into the center, he laughs and\\n laughs at them-so hard, that he laughs them to death!","Achilles: Oh, no!","Tortoise: But it's only a myth. Courage, Achilles."]`,
metadata: { loc: [Object] }
}
]
(node:29007) ExperimentalWarning: The Fetch API is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
Error: [object Response]
at ChromaClient.getOrCreateCollection (/Users/caseymackrell/Downloads/FinanceAI/node_modules/chromadb/src/ChromaClient.ts:171:19)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Chroma.ensureCollection (/Users/caseymackrell/Downloads/FinanceAI/node_modules/langchain/dist/vectorstores/chroma.cjs:60:31)
at async Chroma.addVectors (/Users/caseymackrell/Downloads/FinanceAI/node_modules/langchain/dist/vectorstores/chroma.cjs:77:28)
at async Chroma.addDocuments (/Users/caseymackrell/Downloads/FinanceAI/node_modules/langchain/dist/vectorstores/chroma.cjs:52:9)
at async Function.fromDocuments (/Users/caseymackrell/Downloads/FinanceAI/node_modules/langchain/dist/vectorstores/chroma.cjs:121:9)
at async processTextArray (/Users/caseymackrell/Downloads/FinanceAI/src/modules/yahoo/api/yahoo.api.ts:179:26)
at async /Users/caseymackrell/Downloads/FinanceAI/src/index.ts:29:3
if the docker is off it hangs
Here is the code I have to try it out. I am take a simple array of texts, then creating embeddings and saving them to chromadb
export async function processTextArray(test: string[]): Promise<void> {
const test = [
`Tortoise: Labyrinth? Labyrinth? Could it Are we in the notorious Little
Harmonic Labyrinth of the dreaded Majotaur?, 'Achilles: Yiikes! What is that?',
Tortoise: They say-although I person never believed it myself-that an I
Majotaur has created a tiny labyrinth sits in a pit in the middle of
it, waiting innocent victims to get lost in its fears complexity.
Then, when they wander and dazed into the center, he laughs and
laughs at them-so hard, that he laughs them to death!`,
'Achilles: Oh, no!',
"Tortoise: But it's only a myth. Courage, Achilles.",
]
try {
// Initialize a text splitter with your desired chunk size
const text = JSON.stringify(test)
const textSplitter = new RecursiveCharacterTextSplitter({
chunkSize: 1000,
})
const docs = await textSplitter.createDocuments([text])
console.log('Generated documents:', docs) // Logs out the generated documents
const chromaResponse = await Chroma.fromDocuments(
docs,
new OpenAIEmbeddings({ openAIApiKey: process.env.OPENAI_API_KEY }),
{
collectionName:
'test',
}
)
console.log('Chroma response:', chromaResponse) // Logs out the response from ChromaDB
console.log('Text data processed and saved to ChromaDB')
} catch (error) { // Logs out the error message
if (error.response) {
// The request was made and the server responded with a status code
// that falls out of the range of 2xx
console.error('Response data:', error.response.data) // Logs out the data from the response
console.error('Response status:', error.response.status) // Logs out the status code
console.error('Response headers:', error.response.headers) // Logs out the headers
} else if (error.request) {
// The request was made but no response was received
console.error('No response received:', error.request)
} else {console.log(error)}
}
}