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

Prompts

Kedar Vijay Kulkarni edited this page Jan 24, 2022 · 11 revisions

Prompts

List Prompts

List all of your organization's prompts.

Query String Parameters

  • page - The page of records to return. Optional, defaults to page 1.
  • size - the number of records to return for each page. Optional, defaults to 20 - prompts a page.
  • schema_class - not used, exclude.
  • tags - A list of Tag IDs separated by comma used to filter the results, optional.

Document link

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

(async () => {

  await mantiumAi.Auth().accessTokenLogin({
    username: '[email protected]',
    password: 'p@ssWord!'
  })
  .then((response) => {
    // get bearer_id and set to default
    mantiumAi.api_key = response.data.attributes.bearer_id;
    return response;
  });

  await mantiumAi.Prompts().list({ 'page': 1, 'size': 20, 'show_public_shareable': false }).then((response) => {
    console.log('*********** List *********');
    console.log(response.data);
  });
})();

Example of a successful completion response

{
  data: [
    {
      id: 'some-long-id',
      type: 'prompt',
      attributes: {
        prompt_id: 'some-long-id',
        organization_id: 'organization-some-long-id',
        name: 'Basic Prompt',
        description: 'Basic Prompt Description',
        created_at: '2021-09-29T02:54:28.543648+00:00',
        prompt_text: 'Endpoint Settings: Prompt Line',
        share_scope: 'ORGANIZATION_ONLY',
        ai_provider_approved: false,
        adults_only: false,
        ai_method: 'completion',
        ai_provider: 'OpenAI',
        intelets: [

        ],
        default_engine: 'ada',
        status: 'ACTIVE',
        prompt_parameters: [
          {
            prompt_text: 'Endpoint Settings: Prompt Line',
            basic_settings: {
              top_p: '1',
              stop_seq: [
                'Basic Settings: Stop Sequence'
              ],
              max_tokens: '1024',
              temperature: '1',
              presence_penalty: '1',
              frequency_penalty: '1'
            },
            default_engine: 'ada',
            advanced_settings: {
              n: '1',
              echo: true,
              stream: true,
              best_of: '10',
              logprobs: '10',
              logit_bias: [

              ]
            }
          }
        ],
        last_activity: null,
        share_name: null,
        share_description: '',
        share_placeholder: '',
        share_author_name: null,
        share_author_contact: '',
        share_type: null,
        share_allow_input: false,
        share_status: 'ACTIVE'
      },
      relationships: {
        intelets: { data: [ ] },
        tags: {
          data: [
            {
              type: 'tag',
              id: 'tag-some-long-id'
            }
          ]
        },
        security_policies: { data: [ ] },
        prompt_policies: { data: [ ] }
      }
    }
  ],
  included: [
    {
      id: 'tag-some-long-id',
      type: 'tag',
      attributes: [
        { tag_id: 'tag-some-long-id', name: 'Basic Tag' }
      ],
      relationships: {

      }
    }
  ],
  meta: {

  },
  links: {
    total_items: 3,
    current_page: 1
  }
}

Go to Table of Contents

Create a Prompt

Body payload

object { ...data }; Object example

Document link

Example of violate setting value(s) and it's Response(s)

in following example we send number beyond the number range prompt_parameters.advanced_settings.n = 10 this value should between 1 - 3

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

(async () => {

  await mantiumAi.Auth().accessTokenLogin({
    username: '[email protected]',
    password: 'p@ssWord!'
  })
  .then((response) => {
    // get bearer_id and set to default
    mantiumAi.api_key = response.data.attributes.bearer_id;
    return response;
  });

  mantiumAi.Prompts('OpenAI').create({
    "name": "create the Prompt",
    "intelets": [],
    "policies": [],
    "tags": ["tag-some-long-id"],
    "status": "ACTIVE",
    "description": "Basic Prompt Description",
    "prompt_text": "Endpoint Settings: Prompt Line",
    "ai_method": "completion",
    "default_engine": "ada",
    "prompt_parameters": {
      "basic_settings": {
        "temperature": "1",
        "max_tokens": "512",
        "frequency_penalty": "1",
        "presence_penalty": "1",
        "top_p": "1",
        "stop_seq": ["Basic Settings: Stop Sequence"]
      },
      "advanced_settings": {
        "best_of": "5",
        "n": "10",
        "logprobs": "10",
        "echo": true,
        "stream": true,
        "logit_bias": []
      }
    }
  }).then((response) => {
    console.log("*************** Prompt Create ***************");
    console.log(response.detail);
  });
})();

Example of a Error response

// *************** Prompt Create ***************
{
  detail: [
    {
      loc: [ 'body', 'prompt_parameters', 'advanced_settings', 'n' ],
      msg: 'ensure this value is less than or equal to 3',
      type: 'value_error.number.not_le',
      ctx: { limit_value: 3 }
    }
  ]
}

Example of a successful completion response

// *************** Prompt Create ***************
{
  data: {
    id: 'some-long-id',
    type: 'prompt',
    attributes: {
      prompt_id: 'some-long-id',
      organization_id: 'organization-some-long-id',
      name: 'create the Prompt',
      description: 'Basic Prompt Description',
      created_at: '2021-10-10T15:28:29.026463+00:00',
      prompt_text: 'Endpoint Settings: Prompt Line',
      share_scope: 'ORGANIZATION_ONLY',
      ai_provider_approved: false,
      adults_only: false,
      ai_method: 'completion',
      ai_provider: 'OpenAI',
      default_engine: 'ada',
      status: 'ACTIVE',
      prompt_parameters: [Object],
      last_activity: null,
      share_name: null,
      share_description: '',
      share_placeholder: '',
      share_author_name: null,
      share_author_contact: '',
      share_type: null,
      share_allow_input: false,
      share_status: 'ACTIVE'
    },
    relationships: {
      intelets: [Object],
      tags: [Object],
      security_policies: [Object],
      prompt_policies: [Object]
    }
  },
  included: [
    {
      id: 'tag-some-long-id',
      type: 'tag',
      attributes: [Object],
      relationships: {}
    }
  ],
  meta: {},
  links: {}
}

Go to Table of Contents

Update Prompt

Update details about a specific Prompt.

Prompt Id* (string)* required parameter

Body payload object { ...data }; Object example

Document link

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

(async () => {
  await mantiumAi.Auth().accessTokenLogin({
    username: '[email protected]',
    password: 'p@ssWord!'
  })
    .then((response) => {
      // get bearer_id and set to default
      mantiumAi.api_key = response.data.attributes.bearer_id;
      // console.log(response);
      return response;
    });

  /*
  * API Key is set on above
  * mantiumAi.api_key=`key`
  * so we can call these method directly now
  */
  mantiumAi.Prompts('OpenAI').update({
    "id": "some-long-id",
    "name": "update the Prompt",
    "intelets": [],
    "policies": [],
    "tags": ["383fb5e6-6c30-4641-9850-efeb3cdd77b8"],
    "status": "ACTIVE",
    "description": "Basic Prompt Description",
    "prompt_text": "Endpoint Settings: Prompt Line",
    "ai_method": "completion",
    "default_engine": "ada",
    "prompt_parameters": {
      "basic_settings": {
        "temperature": "1",
        "max_tokens": "512",
        "frequency_penalty": "1",
        "presence_penalty": "1",
        "top_p": "1",
        "stop_seq": ["Basic Settings: Stop Sequence"]
      },
      "advanced_settings": {
        "best_of": "5",
        "n": "2",
        "logprobs": "10",
        "echo": true,
        "stream": true,
        "logit_bias": []
      }
    }
  }).then((response) => {
    console.log("*************** Prompt Update ***************");
    console.log(response);
  });

})();

Example of a successful completion response

// *************** Prompt Update ***************
{
  data: {
    id: 'some-long-id',
    type: 'prompt',
    attributes: {
      prompt_id: 'some-long-id',
      organization_id: 'organization-some-long-id',
      name: 'update the Prompt',
      description: 'Basic Prompt Description',
      created_at: '2021-10-10T15:28:29.026463+00:00',
      prompt_text: 'Endpoint Settings: Prompt Line',
      share_scope: 'ORGANIZATION_ONLY',
      ai_provider_approved: false,
      adults_only: false,
      ai_method: 'completion',
      ai_provider: 'OpenAI',
      default_engine: 'ada',
      status: 'ACTIVE',
      prompt_parameters: {
        basic_settings: {
          top_p: '1',
          stop_seq: [Array],
          max_tokens: '512',
          temperature: '1',
          presence_penalty: '1',
          frequency_penalty: '1'
        },
        advanced_settings: {
          n: '2',
          echo: true,
          stream: true,
          best_of: '5',
          logprobs: '10',
          logit_bias: []
        }
      },
      last_activity: null,
      share_name: null,
      share_description: '',
      share_placeholder: '',
      share_author_name: null,
      share_author_contact: '',
      share_type: null,
      share_allow_input: false,
      share_status: 'ACTIVE'
    },
    relationships: {
      intelets: { data: [] },
      tags: { data: [ [Object] ] },
      security_policies: { data: [] },
      prompt_policies: { data: [] }
    }
  },
  included: [
    {
      id: 'tag-some-long-id',
      type: 'tag',
      attributes: {
        tag_id: 'tag-some-long-id',
        name: 'Basic Tag'
      },
      relationships: {}
    }
  ],
  meta: {},
  links: {}
}

Go to Table of Contents

Get Prompt using ID url

Get details about a specific Prompt.

Prompt Id* (string)* required parameter

Document link

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

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

  /*
  * API Key is set on above
  * mantiumAi.api_key=`key`
  * so we can call these method directly now
  */
  await mantiumAi.Prompts()
    .retreiveId('fab6e007-dab2-4245-907e-e1edf6f5f690')
    .then((response) => {
      console.log("*************** Retreive ***************");
      console.log(response);
    });
})();

Example of a successful completion response

{
  data: {
    id: 'fab6e007-dab2-4245-907e-e1edf6f5f690',
    type: 'prompt',
    attributes: {
      prompt_id: 'fab6e007-dab2-4245-907e-e1edf6f5f690',
      organization_id: 'c68c07c9-d11a-4b54-8823-1dff6792916d',
      name: 'update the Prompt',
      description: 'Basic Prompt Description',
      created_at: '2021-10-10T15:28:29.026463+00:00',
      prompt_text: 'Endpoint Settings: Prompt Line',
      share_scope: 'ORGANIZATION_ONLY',
      ai_provider_approved: false,
      adults_only: false,
      ai_method: 'completion',
      ai_provider: 'OpenAI',
      default_engine: 'ada',
      status: 'ACTIVE',
      prompt_parameters: {
        basic_settings: {
          top_p: '1',
          stop_seq: [Array],
          max_tokens: '512',
          temperature: '1',
          presence_penalty: '1',
          frequency_penalty: '1'
        },
        advanced_settings: {
          n: '2',
          echo: true,
          stream: true,
          best_of: '5',
          logprobs: '10',
          logit_bias: []
        }
      },
      last_activity: null,
      share_name: null,
      share_description: '',
      share_placeholder: '',
      share_author_name: null,
      share_author_contact: '',
      share_type: null,
      share_allow_input: false,
      share_status: 'ACTIVE'
    },
    relationships: {
      intelets: { data: [] },
      tags: { data: [ [Object] ] },
      security_policies: { data: [] },
      prompt_policies: { data: [] }
    }
  },
  included: [
    {
      id: '383fb5e6-6c30-4641-9850-efeb3cdd77b8',
      type: 'tag',
      attributes: {
        tag_id: '383fb5e6-6c30-4641-9850-efeb3cdd77b8',
        name: 'Basic Tag'
      },
      relationships: {}
    }
  ],
  meta: {},
  links: {}
}

Go to Table of Contents

Get Prompt

Get details about a specific Prompt.

Prompt Id* (string)* required parameter

Document link

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

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

  /*
  * API Key is set on above
  * mantiumAi.api_key=`key`
  * so we can call these method directly now
  */
  await mantiumAi.Prompts()
    .retreive('fab6e007-dab2-4245-907e-e1edf6f5f690')
    .then((response) => {
      console.log("*************** Retreive ***************");
      console.log(response);
    });
})();

Example of a successful completion response

{
  data: {
    id: 'fab6e007-dab2-4245-907e-e1edf6f5f690',
    type: 'prompt',
    attributes: {
      prompt_id: 'fab6e007-dab2-4245-907e-e1edf6f5f690',
      organization_id: 'c68c07c9-d11a-4b54-8823-1dff6792916d',
      name: 'update the Prompt',
      description: 'Basic Prompt Description',
      created_at: '2021-10-10T15:28:29.026463+00:00',
      prompt_text: 'Endpoint Settings: Prompt Line',
      share_scope: 'ORGANIZATION_ONLY',
      ai_provider_approved: false,
      adults_only: false,
      ai_method: 'completion',
      ai_provider: 'OpenAI',
      default_engine: 'ada',
      status: 'ACTIVE',
      prompt_parameters: {
        basic_settings: {
          top_p: '1',
          stop_seq: [Array],
          max_tokens: '512',
          temperature: '1',
          presence_penalty: '1',
          frequency_penalty: '1'
        },
        advanced_settings: {
          n: '2',
          echo: true,
          stream: true,
          best_of: '5',
          logprobs: '10',
          logit_bias: []
        }
      },
      last_activity: null,
      share_name: null,
      share_description: '',
      share_placeholder: '',
      share_author_name: null,
      share_author_contact: '',
      share_type: null,
      share_allow_input: false,
      share_status: 'ACTIVE'
    },
    relationships: {
      intelets: { data: [] },
      tags: { data: [ [Object] ] },
      security_policies: { data: [] },
      prompt_policies: { data: [] }
    }
  },
  included: [
    {
      id: '383fb5e6-6c30-4641-9850-efeb3cdd77b8',
      type: 'tag',
      attributes: {
        tag_id: '383fb5e6-6c30-4641-9850-efeb3cdd77b8',
        name: 'Basic Tag'
      },
      relationships: {}
    }
  ],
  meta: {},
  links: {}
}

Go to Table of Contents

Delete Prompt

Delete a specific Prompt.

Prompt Id* (string)* required parameter

Document link

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

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

  /*
  * API Key is set on above
  * mantiumAi.api_key=`key`
  * so we can call these method directly now
  */
  await mantiumAi.Prompts()
    .remove('fab6e007-dab2-4245-907e-e1edf6f5f690')
    .then((response) => {
      console.log("*************** Remove ***************");
      console.log(response);
    });
})();

/*
* run command
* node prompt/retreive.js
*/

Example of a successful completion response

{}

Go to Table of Contents

Execute Prompt

Asynchronously submit a prompt by prompt_id. If successful, the status and results of the prompt can be retrieved from the /v1/prompt/result/{prompt_execution_id} endpoint by prompt_execution_id.

Prompt Id* (string)* required parameter

Input* (string)* Input for executing a prompt asynchronously

Document link

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

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

  /*
  * API Key is set on above
  * mantiumAi.api_key=`key`
  * so we can call these method directly now
  */

  let prompt_id = 'b1c01f1a-ff6c-45e8-8378-d23d11d7de9c';
  let input = 'This is my first test execute prompt';

  await mantiumAi.Prompts('OpenAI')
    .execute({
      id: prompt_id,
      input
    })
    .then(async (res) => {
      console.log("*************** Execute ***************");
      console.log(res);
    });
})();

Example of a successful completion response

// *************** Execute ***************
{
  success: true,
  prompt_id: 'b1c01f1a-ff6c-45e8-8378-d23d11d7de9c',
  input: 'This is my first test execute prompt',
  status: 'QUEUED',
  prompt_execution_id: 'd96d6f42-05a3-4ae6-b846-a891af8a8635',
  error: '',
  warning_message: ''
}

Go to Table of Contents

Get Prompt Result

Returns execution status of a prompt ran through the prompt execution workflow asynchronously.

Prompt Execution Id* (string)* this can be achieved from the successful response from the execute prompt method.

Document link

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

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

  /*
  * API Key is set on above
  * mantiumAi.api_key=`key`
  * so we can call these method directly now
  */

  let prompt_id = 'b1c01f1a-ff6c-45e8-8378-d23d11d7de9c';
  let input = 'This is my second test execute prompt';

  await mantiumAi.Prompts('OpenAI')
    .execute({
      id: prompt_id,
      input
    })
    .then(async (res) => {
      /*
      * from the successful response collect the prompt_execution_id
      * and then pass this to the result method
      */
      if(res?.prompt_execution_id) {
        await mantiumAi.Prompts('OpenAI').result(res.prompt_execution_id)
        .then((response) => {
          console.log("*************** Execute Result ***************");
          console.log(response);
        });
      }
    });
})();

Example of a successful completion response

// *************** Execute Result ***************
{
  prompt_execution_id: 'd96d6f42-05a3-4ae6-b846-a891af8a8635',
  prompt_id: 'b1c01f1a-ff6c-45e8-8378-d23d11d7de9c',
  status: 'COMPLETED',
  input: 'This is my second test execute prompt',
  output: "Endpoint Settings: Prompt LineThis is my second test execute prompt, but my last one worked fine. I thought this was rough except for Thoughtnet having doubts about working with it... I found another test which showed interaction with the NavigatorHelpers class. But, now my memory is terrible. Part of that may be hardware ghosting or at least faulty programming on bad servers.....I tried to use InsertPageName here only to find that didn't work though. So, if extra query pages fail because not everything's Showed in Page Name window, something cleantly isn't done.... Now the question is whether Thoughtnet will comply so they don't have to deal w/ weird loading times?????Edit: You can go straight off After powering up after this screen appearsoted by Admin using Command Prompt",
  error: '',
  reason: '',
  hitl_info: null,
  warning_message: ''
}

Go to Table of Contents

Try Prompt

Execute a prompt specified by given prompt ID synchronously.

Prompt Id* (string)* required parameter

Input* (string)* Input for executing a prompt asynchronously

Document link

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

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

  /*
  * API Key is set on above
  * mantiumAi.api_key=`key`
  * so we can call these method directly now
  */

  let prompt_id = 'b1c01f1a-ff6c-45e8-8378-d23d11d7de9c';
  let input = 'This is my first try prompt';

  await mantiumAi.Prompts('OpenAI')
    .tryPrompt({
      id: prompt_id,
      input
    })
    .then(async (res) => {
      console.log("*************** Execute ***************");
      console.log(res);
    });
})();

Example of a successful completion response

// *************** Execute ***************
{
  success: true,
  prompt: 'Endpoint Settings: Prompt Line',
  input: 'This is my first try prompt',
  answer: "Endpoint Settings: Prompt LineThis is my first try prompt feature (there are of course many others). For example:Nick Name This can be any name or alias you may think fit.But I don't know how to set this one range..ziplist Also, my question is what happens if someone else requests permission to add a ZFS directory i.e. create something and that's why they didnt put it?",
  provider_response: {
    id: 'cmpl-3tGId5EkVU9gdYeWEiQzWn8fVDrQt',
    object: 'text_completion',
    created: 1634299707,
    model: 'ada:2020-05-03',
    choices: [
      {
        text: "Endpoint Settings: Prompt LineThis is my first try prompt feature (there are of course many others). For example:Nick Name This can be any name or alias you may think fit.But I don't know how to set this one range..ziplist Also, my question is what happens if someone else requests permission to add a ZFS directory i.e. create something and that's why they didnt put it?",
        index: 0,
        logprobs: [Object],
        finish_reason: 'stop'
      },
      {
        text: 'Endpoint Settings: Prompt LineThis is my first try prompt, becuase i got faced trouble with this, however it helped me try.Continue Reading here: https://helpme.m...',
        index: 1,
        logprobs: [Object],
        finish_reason: 'stop'
      }
    ]
  },
  warning_message: null
}

Go to Table of Contents