Проблема с использованием Chromadb с Typescript

Я пытаюсь использовать Chromadb с langchain. У меня запущен докер, и я установил все, что указано в документации.

Я продолжаю получать эти ошибки при запуске кода, если докер включен

      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

если докер выключен, он зависает

Вот код, который я должен попробовать. Я беру простой массив текстов, затем создаю вложения и сохраняю их в chromadb.

экспортировать асинхронную функциюprocessTextArray(test: string[]): Promise<void> {

      const test = [
    `Tortoise: Labyrinth? Labyrinth? Could it Are we in the notorious Little

Гармоничный лабиринт ужасного Маджотавра?, 'Achilles: Yiikes! What is that?', Черепаха: Говорят - хотя я сам в это никогда не верил, - что I-Маджотавр создал крошечный лабиринт, сидящий в яме посередине и ожидающий невинных жертв, которые заблудятся в его сложности и страхах. Затем, когда они блуждают и ошеломленные в центре, он смеется и смеется над ними - так сильно, что смеется над ними до смерти!", "Ахиллес: О, нет!", "Черепаха: Но это всего лишь миф. Мужество, Ахиллес.", ]

      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)}
}

}

0 ответов

Другие вопросы по тегам