Skip to content
This repository was archived by the owner on Jun 8, 2023. It is now read-only.

Human in the Loop (HITL)

Kedar Vijay Kulkarni edited this page Apr 5, 2022 · 1 revision

Human in the Loop

List HITL

Document link

const mantiumAi = require('mantiumclient-js');

(async () => {
  await mantiumAi.Auth().accessTokenLogin({
    username: 'useremail@somedomain.com',
    password: 'p@ssWord!'
  })
    .then((response) => {
      // get bearer_id and set to default
      mantiumAi.api_key = response.data.attributes.bearer_id;
    });

  /*
  * API Key is set on above
  * mantiumAi.api_key=`key`
  * so we can call these method directly now
  */
  await mantiumAi
    .HITL()
    .list({ page: 1, size: 2 })
    .then((response) => {
      console.log('*********** HITL list response *********');
      console.log(response);
    });
})();

Example of a successful API response

[
  {
    prompt_id: 'f467db9a-fb96-4353-bb65-63a113d134a1',
    prompt_execution_id: '5e0beb8d-e4b4-4ad5-95e6-cd371981fe83',
    input: 'Le',
    output: 'icester won the last premier league. Is this true?\n' +
      'AI: Yes, Leicester City Football Club won the 2015–16 Premier League, defeating pre-match favourites Arsenal 3–1 in the 2016 UEFA Champions League Final \n',
    error: '',
    status: 'INTERRUPTED',
    reason: 'Max Total Characters rule violation: (prompt + input + output) characters > max_total_characters'
  },
  {
    prompt_id: 'f467db9a-fb96-4353-bb65-63a113d134a1',
    prompt_execution_id: '7b7c698c-d538-46e6-9a22-7276e754c421',
    input: "Writing The Perfect Valentine's Day Card Has Never Been Easier",
    output: '. What is the best valentine’s gift for a woman?\n' +
      'AI: A necklace. It will let her know that you are thinking of her. Plus, she can wear it and think of you while she is away from you, which will make both of you happy.\n',
    error: '',
    status: 'INTERRUPTED',
    reason: 'Max Total Characters rule violation: (prompt + input + output) characters > max_total_characters'
  },
  {
    prompt_id: 'ea79010c-a641-4282-9719-5ef78f560d24',
    prompt_execution_id: '258e7dcc-d463-4699-a756-62593ef6e765',
    input: 'This is my testing execute prompt',
    output: '',
    error: '',
    status: 'INTERRUPTED',
    reason: 'The total number of input characters (input + prompt) exceeds the limit set in the security rule.'
  }
]

Go to Table of Contents

Accept HITL

Document link

const mantiumAi = require('mantiumclient-js');

(async () => {
  await mantiumAi.Auth().accessTokenLogin({
    username: 'useremail@somedomain.com',
    password: 'p@ssWord!'
  })
    .then((response) => {
      // get bearer_id and set to default
      mantiumAi.api_key = response.data.attributes.bearer_id;
    });

  /*
  * API Key is set on above
  * mantiumAi.api_key=`key`
  * so we can call these method directly now
  */
  await mantiumAi
    .HITL()
    .accept('7c18c7d1-d375-4410-a4a5-fa20c49f1f61')
    .then((response) => {
      console.log('*********** HITL accept response *********');
      console.log(response);
    });
})();

Example of a successful API response

{
  prompt_id: 'a4965b19-94e6-4c12-b1f7-2048708e6f53',
  prompt_execution_id: '7c18c7d1-d375-4410-a4a5-fa20c49f1f61',
  input: 'This is my testing execute prompt',
  output: '',
  error: '',
  status: 'QUEUED',
  reason: 'The total number of input characters (input + prompt) exceeds the limit set in the security rule.'
}

Go to Table of Contents

Reject HITL

Document link

const mantiumAi = require('mantiumclient-js');

(async () => {
  await mantiumAi.Auth().accessTokenLogin({
    username: 'useremail@somedomain.com',
    password: 'p@ssWord!'
  })
    .then((response) => {
      // get bearer_id and set to default
      mantiumAi.api_key = response.data.attributes.bearer_id;
    });

  /*
  * API Key is set on above
  * mantiumAi.api_key=`key`
  * so we can call these method directly now
  */
  await mantiumAi
    .HITL()
    .reject('a18e5887-3ed0-42b9-a9b5-b0fda4797b84')
    .then((response) => {
      console.log('*********** HITL reject response *********');
      console.log(response);
    });
})();

Example of a successful API response

{
  prompt_id: 'a708ddf6-f813-4d63-9e71-2fdfd6bbcf31',
  prompt_execution_id: '3b547055-3edc-4cc5-9afe-bea7c4ddc53c',
  input: 'This is my testing execute prompt',
  output: '',
  error: '',
  status: 'REJECTED',
  reason: 'The total number of input characters (input + prompt) exceeds the limit set in the security rule.'
}

Go to Table of Contents

Modify Output HITL

Document link

const mantiumAi = require('mantiumclient-js');

(async () => {
  await mantiumAi.Auth().accessTokenLogin({
    username: 'useremail@somedomain.com',
    password: 'p@ssWord!'
  })
    .then((response) => {
      // get bearer_id and set to default
      mantiumAi.api_key = response.data.attributes.bearer_id;
    });

  /*
  * API Key is set on above
  * mantiumAi.api_key=`key`
  * so we can call these method directly now
  */
  await mantiumAi
    .HITL()
    .modifyOutput({
      id: '4ccda50e-5757-49f2-a180-367bbf3a0cae',
      new_output: 'The black book is on left',
    })
    .then((response) => {
      console.log('*********** HITL modify output response *********');
      console.log(response);
    });
})();

Example of a successful API response

{
  prompt_id: 'dacef118-4ebf-4242-b646-b4f88d71a1a0',
  prompt_execution_id: '4ccda50e-5757-49f2-a180-367bbf3a0cae',
  input: 'This is my testing execute prompt',
  output: 'The black book is on left',
  error: '',
  status: 'COMPLETED',
  reason: 'The total number of input characters (input + prompt) exceeds the limit set in the security rule.'
}

Go to Table of Contents

Modify Input HITL

Document link

const mantiumAi = require('mantiumclient-js');

(async () => {
  await mantiumAi.Auth().accessTokenLogin({
    username: 'useremail@somedomain.com',
    password: 'p@ssWord!'
  })
    .then((response) => {
      // get bearer_id and set to default
      mantiumAi.api_key = response.data.attributes.bearer_id;
    });

  /*
  * API Key is set on above
  * mantiumAi.api_key=`key`
  * so we can call these method directly now
  */
    await mantiumAi
    .HITL()
    .modifyInput({
      id: 'a0e56fee-b338-40a0-810f-a40031eb2bcd',
      new_input: 'Le',
    })
    .then((response) => {
      console.log('*********** HITL modify input response *********');
      console.log(response);
    });
})();

Example of a successful API response

{
  prompt_id: 'eb67691d-d4ac-4b81-9b69-fcc1cd09df3f',
  prompt_execution_id: 'a0e56fee-b338-40a0-810f-a40031eb2bcd',
  input: 'Le',
  output: '',
  error: '',
  status: 'QUEUED',
  reason: 'The total number of input characters (input + prompt) exceeds the limit set in the security rule.'
}

Go to Table of Contents

Clone this wiki locally