How to use Question Answering module with TypeScript v3 client?

Description

I’m currently migrating our app to TypeScript client v3 from v2, and we heavily rely on the QnA Transformers module. However, I couldn’t find any info on how to use it with TypeScript client v3, as all the examples are only for v2 of the library:

Server Setup Information

  • Weaviate Server Version:
  • Deployment Method: docker
  • Multi Node? Number of Running Nodes: 1
  • Client Language and Version: TypeScript, weaviate-client@3.1.2
  • Multitenancy?: yes

Any additional Information

hi @evenfrost !!

The ask capability was not added to the grpc endpoint.

in ts client v2 you can do a raw graphql query using:
client.graphql.raw()

however this raw graphql query method was not included in ts v3 yet. :frowning:

I have asked internally, and it will be included in the next release.

Thanks for pointing it out!

Hi @DudaNogueira ,

But in v2 you can just use

await client.graphql
  .get()
  .withClassName('Article')
  .withAsk({
    question: 'Who is the king of the Netherlands?',
    properties: ['summary'],
  })

Without running the raw query. Is this functionality planned for v3?
Because otherwise you’ll have to write a pretty complex wrapper around client.graphql.raw() by yourself if you need e.g. filters and additional params in the query (along with ask).

I am not sure this will be ported to the new client.

Can you please open a feature request in GitHub - weaviate/weaviate: Weaviate is an open-source vector database that stores both objects and vectors, allowing for the combination of vector search with structured filtering with the fault tolerance and scalability of a cloud-native database​. so we can track the popularity of porting this feature to grpc?

Thanks!

Thanks for the explanation. To me, it looks more like the issue with the client library’s API and the necessity to write complex raw queries than the need for this module to use the new protocol. Because currently if you want add the ask part in your query, you’ll have to dump all the convenience of the client library with already defined methods for querying, filtering, choosing what to return etc., and write the same stuff by yourself to use the QnA module.

It would be great to write something like

const result = await myCollection.query.fetchObjects({
  returnProperties: ['question', 'answer','round', 'points'],
  filters: Filters.and(
     myCollection.filter.byProperty('round').equal('Double Jeopardy!'),
     myCollection.filter.byProperty('points').lessThan(600)
    ),
  limit: 3,
  ask: {
    question: 'Who is the king of the Netherlands?',
    properties: ['summary'],
 })

and leave the burden of choosing the internal stuff (e.g. protocol) to the client itself.

But these are just my considerations, for sure.

I understand.

However, the problem is that the new clients (both python v4 and ts v3 and) relies on GRPC for querying.

The old ones builds the graphql using the client syntax.

The new one builds the a GRPC query using the client syntax.

That’s why for using the client syntax as you described, it would need to expose the ask also in GRPC.

1 Like

To give a bit more context - there are some older features that are rarely used anymore and the ask module is among them. They would need special support in the new GRPC protocoll which is not always easy to do and we decided against adding them. Given our capacity constrains it is unlikely that we will add it.

However you can:

  • continue to use TS v2 for the forseeable future. We do not have any plans to deprecate it
  • use TS v2 to build the gql query for you and pipe that into v3 raw gql query
2 Likes