Positron recording action

Oxygen general issues.
sljohns
Posts: 8
Joined: Wed Mar 01, 2023 5:45 pm

Positron recording action

Post by sljohns »

I am trying to create a custom positron action using the record feature. The action should read the current topic and add keywords that are applicable from an approved list. My recording did not work. Here is the json file that was created.

Code: Select all

[ {
  "id" : "add.approved.terms",
  "title" : "Add approved terms",
  "input-type" : "markup",
  "type" : "replace-selection-with-fragment",
  "description" : "Use this action to insert index terms from the approved list",
  "context" : "${contextInfo} Read through the file and only add index terms from the list below if they are applicable. Here is the list of approved index terms:\noperation\nwarranty\nraider\nhibiscus\nflower",
  "examples" : [ {
    "prompt" : "",
    "completion" : "<prolog>         <metadata>             <keywords>                 <indexterm>operation</indexterm>                 <indexterm>warranty</indexterm>             </keywords>         </metadata>     </prolog>"
  } ]
} ]
I appreciate any help that I can get
alex_jitianu
Posts: 1009
Joined: Wed Nov 16, 2005 11:11 am

Re: Positron recording action

Post by alex_jitianu »

Hi,

I've changed the action a bit. I've used different terms, to help me understand if the response is correct.

Code: Select all

[ {
  "id" : "add.approved.terms",
  "title" : "Add approved terms",
  "input-type" : "markup",
  "type" : "insert-schema-aware-fragment",
  "description" : "Use this action to insert index terms from the approved list",
  "context" : "${contextInfo} Read through the file and add index terms from the list below only if they are applicable on the text. Here is the list of approved index terms:\nengine\nrepair\nwarranty\nflower",
  "examples" : [ 
  {
    "prompt" : "Engine repairs require skilled expertise to diagnose and fix underlying issues efficiently. Regular maintenance and timely engine repairs can extend the lifespan and enhance the performance of your vehicle.",
    "completion" : "<prolog><metadata><keywords><indexterm>engine</indexterm><indexterm>repair</indexterm></keywords></metadata></prolog>"
  } ,
  {
    "prompt" : "A product warranty is a promise made by the manufacturer or seller to repair or replace a product if it becomes faulty or fails to meet certain standards within a specified period.",
    "completion" : "<prolog><metadata><keywords><indexterm>warranty</indexterm></keywords></metadata></prolog>"
  } ,
  {
    "prompt" : "Flowers are nature's delicate masterpieces that breathe life and beauty into our surroundings. Their vibrant colors and enchanting fragrances have the power to uplift our spirits and bring joy to any occasion. ",
    "completion" : "<prolog><metadata><keywords><indexterm>flower</indexterm></keywords></metadata></prolog>"
  } 
  ]
} ]
Best regards,
Alex
sljohns
Posts: 8
Joined: Wed Mar 01, 2023 5:45 pm

Re: Positron recording action

Post by sljohns »

Oh that's awesome! Do I need to add an example for every word in the list? Or will 4 or 5 be sufficient?
alex_jitianu
Posts: 1009
Joined: Wed Nov 16, 2005 11:11 am

Re: Positron recording action

Post by alex_jitianu »

Hi,

Actually, one example is enough. The value of the example in this case is to make him understand how to structure the response so from that perspective we don't need more than one. I'm not sure why I kept three of them in my first example! :)

Best regards,
Alex
sljohns
Posts: 8
Joined: Wed Mar 01, 2023 5:45 pm

Re: Positron recording action

Post by sljohns »

One last thing, is there documentation of the allowed values in the "type" value field?
alex_jitianu
Posts: 1009
Joined: Wed Nov 16, 2005 11:11 am

Re: Positron recording action

Post by alex_jitianu »

Hi,
Once you save the json in the location from where the actions are loaded you should have content completion for property names and values. I will more details in the documentation, but refering to the "type" property, I would say that the most useful ones are:
-"replace-selection-with-fragment"
-"insert-schema-aware-fragment" - inserts the response as specified in "insert-modes"

Code: Select all

{
    "id": "generate.shortdescription",
    "title": "Shortdesc",
    "type": "insert-schema-aware-fragment",
    "context": "Generate a short description",
    "insert-modes": [{
        "target-location": "/topic/title",
        "action": "insert-after"
    }]
}
Post Reply