HomeGuidesRecipesAPI EndpointsRelease NotesCommunity
Log In
Guides

Submitting a bulk question job

Now that we've learned how to query a single document we will go over batch documents. We will be utilizing the same endpoint but as before but will be focusing on /layar/question/startBulkQuestionAnswerJob

Pre-Reqs

Before a document search can be done the API requests must be authenticated. Make sure you have already followed the instructions for importing dependencies and authentication from the Getting Started Guide.

👍

Check Your Imported Modules

Make sure you have imported the requests and json module before proceeding with this guide.

The following header can be used in your request.

header = {'Accept': 'application/json',
          'Content-Type': 'application/json',
          'Authorization': f"Bearer {token}",
          'X-Vyasa-Client': 'layar',
          'X-Vyasa-Data-Providers' : 'sandbox.certara.ai',
	  'X-Vyasa-Data-Fabric' : 'YOUR_FABRIC_ID'
  	 }

Configuring the Header

The header is going to be different for a bulk QA job. Specifically, the X-Vyasa-Client will be curate.

header = {'Accept': 'application/json',
          'Content-Type': 'application/json',
          'Authorization': f"Bearer {token}",
          'X-Vyasa-Client': 'curate',
          'X-Vyasa-Data-Providers' : 'sandbox.certara.ai'}

Create a Document Set

In order to question the contents of a set, we first need one to work with. You can follow the guide Create a Document Set. Make sure to keep you setId variable from that guide to use in the steps below.

Build the Batch Create Request Body

As with other API calls, we will need to form a body to use without request. For batch questions, we will need a few values; let's go over those parts.

👍

Pro Tip

You can use Swagger to double check all the possible values you can use at https://YOUR_LAYAR_ENVIRONMENT/layar/swagger-ui.html

bulkQuestions

This value is an array with multiple parts.

  • conceptTypes- This is an array where we would use strings like "DISEASE" or "CHEMICAL"
  • questionKey- This is a string that is just a description of the question
  • questionStringVariations - This is an array where you would put variations of your question as a string.
  • deepLearningModelId - This corresponds to the model you want to run the question on.

This is what it would look like in our body variable.

body = {
  'bulkQuestions' : [{
    'conceptTypes' : [
      'CHEMICAL' , 'CHEBI'
                     ],
    'questionKey' : 'Study Drug'
    'questionStringVariations' : [
      'What is the drug or therapeutic being evaluated?'
                                 ],
    'deepLearningModelId' : 'AYz45Lw7gz6XyJQfUcsx'
                     }]
       {

sourceDocumentSearchCommand

This value is an array that can contain a lot of different filters that allow you determine what documents are used when answering questions. We will be using our setId from before as the filter. Below is how the body should look like at this point. We will also be using rows to limit the number of documents looked at, this can be increased or decreased.

body = {
  'bulkQuestions' : [{
    'conceptTypes' : [
      'CHEMICAL' , 'CHEBI'
                     ],
    'questionKey' : 'Study Drug'
    'questionStringVariations' : [
      'What is the drug or therapeutic being evaluated?'
                                 ],
    'deepLearningModelId' : 'AYz45Lw7gz6XyJQfUcsx'
                      }],
  'sourceDocumentSearchCommand' : {
    'rows' : 500,
    'savedListIds' : setId
                                  }
       {

questionGroupingKey

This value is just a string that dictates the name of this batch of questions.

body = {
  'bulkQuestions' : [{
    'conceptTypes' : [
      'CHEMICAL' , 'CHEBI'
                     ],
    'questionKey' : 'Study Drug',
    'questionStringVariations' : [
      'What is the drug or therapeutic being evaluated?'
                                 ],
    'deepLearningModelId' : 'AYz45Lw7gz6XyJQfUcsx'
                      }],
  'sourceDocumentSearchCommand' : {
    'rows' : 500,
    'savedListIds' : setId
                                  },
  'questionGroupingKey' : 'Demo Batch'
                                  {                                    
       {

We now have a body ready to use for our request.

Submitting the Batch Create Request

Now we can use requests.post to submit our QA batch to /layar/question/startBulkQuestionAnswerJob.

submitBatchQaUri = f'{envUrl}/layar/question/startBulkQuestionAnswerJob'

Response = Requests.post(submitBatchQaUri,
                        headers = header,
                        json = body)
pprint(response) #Optional

Get Batch Answers

We can use the questionGroupingKey value that we entered in Defining Question Grouping Key as part of the body.

body = {
  'rows' : 50,
  'batchGroupingKey' : 'INSERT questionGroupingKey'
       }

Submitting the Batch Answers Request

Now we can use requests.get to with the body to obtain answers for the batch of questions.

searchBatchAnswers = f'{envUrl}/layar/answer'

Response = Requests.post(searchBatchAnswers,
                        headers = header,
                        json = body)
pprint(response) #Optional

Up Next

Now that we know how to submit a Batch QA Job. We can specify sections for further questions to be ran against.