Open michael-pont opened 1 week ago
Hi @michael-pont, thanks for diving straight into the new client and getting to grips with it!
weaviate.configure
object to define the objects that the .create()
method expects in the correct format. Indeed, you'll find that the types are not as expressive without it!autoTenantX
options are only relevant to recent 1.25.x
releases. In short, autoTenantCreation
will automatically create a tenant if you try to insert objects with an associated tenant that didn't previously exist, e.g. collection.withTenant('tenant').data.insert()
. autoTenantActivation
will automatically activate a tenant if you try to insert/query objects into a tenant that was previously COLD
so that you don't have to pre-activate it.['Class']
then this translates to targetCollection: 'Class'
. You're right that one property referencing multiple collections is confusing but it is a feature of Weaviate! In the GraphQL API, this was traversable at query time through the ... on MyClass { }
fragments syntax.skipVectorization
and vectorizerPropertyName
are definable in the vectorizers:
field rather than in the properties:
field. At the moment, if you set either of these booleans then they will be true
for all named vectors. In future, this will not be the case but it is a current limitation.To help your migration, here's how I would translate your .create()
code to make use of the weaviate.configure
object:
import { type CollectionConfigCreate } from '..'
import { CustomClassName } from '../types'
import weaviate from '../../index'
const className: CustomClassName = CustomClassName.SCOPED_ACCOUNT
export const ScopedAccountClass: CollectionConfigCreate = {
name: className,
description: 'A class holding scoped information about an account',
multiTenancy: weaviate.configure.multiTenancy({ enabled: true }),
vectorizers: weaviate.configure.vectorizer.text2VecOpenAI({
sourceProperties: ['notes'],
vectorIndexConfig: weaviate.configure.vectorIndex.hnsw(),
model: 'text-embedding-3-small',
dimensions: 1536,
type: 'text',
}),
generative: weaviate.configure.generative.openAI({
model: 'gpt-3.5-turbo',
temperature: 0,
}),
references: [
{
name: 'enrichmentRequests',
description:
'Enrichment Requests - which enrichment requests are linked to this account',
targetCollection: CustomClassName.ENRICHMENT_REQUEST,
},
{
name: 'customPropertyValues',
description: 'Custom property values for this scoped account',
targetCollection: CustomClassName.CUSTOM_PROPERTY_VALUE,
},
],
properties: [
{
name: 'accountId',
description: 'The account id', // No cross-reference because querying from tenant to non tenant is not possible
dataType: 'uuid',
},
{
name: 'crmAccountId',
description:
'CRM account identifier - we use this to link the account to our customers CRM',
dataType: 'text',
},
{
name: 'teamId',
description: 'Team ID - we use this as tenant identifier',
dataType: 'uuid',
},
{
name: 'name',
description:
'Name (honestly used for placeholder, as I want notes to be text[] and class creation will throw error)',
dataType: 'text',
},
{
name: 'queryResponses',
description:
'The answers to the queries that are part of this enrichment request',
dataType: 'object[]',
nestedProperties: [
{ dataType: 'text', name: 'query' },
{ dataType: 'text', name: 'customQueryId' },
{ dataType: 'text', name: 'answer' },
{ dataType: 'text', name: 'confidence' },
{ dataType: 'text', name: 'explanation' },
{
name: 'sources',
description: 'The sources of where the answer is found',
dataType: 'object[]',
nestedProperties: [
{ dataType: 'text', name: 'title' },
{ dataType: 'text', name: 'link' },
{ dataType: 'boolean', name: 'isVisitable' },
],
},
],
},
{
name: 'notes',
description: 'Optional notes for the scoped account',
dataType: 'text[]',
},
{
name: 'score',
description: 'The score of the account',
dataType: 'number',
},
{
name: 'originalUrl',
description: 'Original input URL',
dataType: 'text',
skipVectorization: true,
},
],
}
I am having some troubles converting code from previous typescript client (v2) to new client (3.0.5). My confusion revolves around:
Here is the old "class"
Here is the new collection as I have defined it
Questions / Observations I had:
vectorIndex
property on the vectorizer has very little type support compared tovectorizer
property. The same goes forgenerative
field. It's not clear what to write / define or what behavior is expected when defining empty object (does default config override?) I've looked at the 3.0.5 codebase to find examples in tests and all I want to do is define the defaulthsnw
vector index config. I ended up definingconfig
as {}.autoTenantActivation
andautoTenantCreation
properties do for multiTenancy config? I've read 1.25 release notes, however, I'm not 100% sure what the behavior should be here especially coming from v2 client.references
is now a separate field. I've removed the two properties I had previously defined inproperties
field and added them here. Previously I had an array of references so I defined it as[]
anymore when defining thetargetCollection
field? Why is there the pluraltargetCollections
? Can 1 property reference multiple other collections? That seems confusing?notes
within the vectorizer config. I assume any properties I define here will set skipVectorization: false for each property? If I have multiple text data type properties in my collection do I need to explicitly set the skip property to true or false? Or can I just set the properties I want vectorized in the vectorizer config?