Now assist skill kit & displaying response of LLM in a pop-up

mouradhadj-
Tera Contributor

Hello,
i am facing a issue in displaying a response of an LLM in a pop-up which the text displayed with no space or not correctly formatted, its not lisible for users. but its seem good when i display the response in an alert. did any one know how i can fix that ?

so what i did is in my UI Action i transferred the response of my LLM to an UI Page 
UI Action:

function checkSimilarIncidents() {
    var sysId = g_form.getUniqueValue();

    var ga = new GlideAjax('GenAISkillExecutor');
    ga.addParam('sysparm_name', 'runSimilarIncidentSkill');
    ga.addParam('sysparm_sys_id', sysId);

    ga.getXMLAnswer(function(response) {
        if (!response) {
            alert("GenAI response is empty.");
            return;
        }

        alert("GenAI output received:\n\n" + response); // DEBUG

        var dialog = new GlideDialogWindow('check_similar_incidents_ui');
        dialog.setTitle("GenAI - Similar Incidents");
        dialog.setWidth(1000);
        dialog.setHeight(600);
        dialog.setPreference('output', response);
        dialog.render();
    });
}

checkSimilarIncidents();


UI Page:
<j:jelly xmlns:j="jelly:core" xmlns:g="glide" >

  <g:ui_form>
    <style>
      #ai_response {
        width: 1050px;
        height: 500px;
        font-family: Arial, sans-serif;
        font-size: 14px;
        line-height: 1.6;
        padding: 20px;
        overflow-y: auto;
        border-radius: 8px;
        border: 1px solid #ccc;
        background-color: #fafafa;
      }

   

    </style>

   

    <table>
      <tr>
        <td>
          <label><b>GenAI Suggested Response:</b></label><br/>
           <g:evaluate var="jvar_text" expression="RP.getWindowProperties().get('output')" />
           
          <div id="ai_response" contenteditable="true">${jvar_text}</div>
        </td>
      </tr>
      <tr>
        <td style="padding-top: 20px;">
          <g:dialog_buttons_ok_cancel
            ok="return addToWorkNote();"
            ok_text="Add to Work Notes"
            cancel="return GlideDialogWindow.get().destroy();" />
        </td>
      </tr>
    </table>
  </g:ui_form>


</j:jelly>





0 REPLIES 0