Giter Site home page Giter Site logo

Comments (1)

tsmith023 avatar tsmith023 commented on June 27, 2024 1

Hi @michael-pont, thanks for diving straight into the new client and getting to grips with it!

  • Perhaps it's not so clearly explained or pointed towards in the docs (we'll make sure to add this to the migration guide) but we strongly encourage you to make use of the 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!
  • The 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.
  • If your reference was defined as ['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.
  • Your final question touches on something we're not happy about with the vectors syntax currently but is blocked by the current server-side capabilities. We would like to have it that 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,
    },
  ],
}

from typescript-client.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.