Quantcast
Channel: Weaviate Community Forum - Latest posts
Viewing all articles
Browse latest Browse all 3588

Failed to create collection with vectorizers using demo code in nodejs

$
0
0

hi @Sandon !

What is the error message you get?

here is a full working code for typescript:

import weaviate, { dataType, vectorizer, WeaviateClient } from 'weaviate-client';

async function runFullExample() {
  
  const client: WeaviateClient = await weaviate.connectToLocal(
  )
  console.log(await client.isReady());

  await client.collections.delete("Test")

  await client.collections.create({
    name: "Test",
    vectorizers: vectorizer.text2VecOpenAI(),
    properties: [
      { name: 'category', dataType: dataType.TEXT },
      { name: 'question', dataType: dataType.TEXT },
      { name: 'answer', dataType: dataType.TEXT },
    ]
  })

  const collection = client.collections.get("Test")
  await collection.data.insert({
    "category": "cat1",
    "question": "q1",
    "answer": "a1"
  })

  const obj = (await collection.query.fetchObjects({limit:1, includeVector:true})).objects[0]
  console.log(obj.vectors)
  
}

runFullExample();

Let me know if this helps!


Viewing all articles
Browse latest Browse all 3588

Trending Articles