-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Question] How to convert code for collection creation from ts client v2 to new client v3 #149
Comments
michael-pont
changed the title
[Question] How to convert code for collection creation to ts client v2 to new client v3
[Question] How to convert code for collection creation from ts client v2 to new client v3
Jun 13, 2024
Hi @michael-pont, thanks for diving straight into the new client and getting to grips with it!
To help your migration, here's how I would translate your 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,
},
],
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 <CLASS_NAME>[], do I need the[]
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?The text was updated successfully, but these errors were encountered: