Hi Team, I am using Appian AI to read some unstructured data document and need help with formatting the text output from AI to Appian Record

Certified Associate Developer

Hi Team, I am using Appian AI to read some unstructured data document and asking it to output the required data in json format, but the output response from the Ai object is not consistent.Sometimes the json gets appended with text like: 

As Appian's private AI, I will not repeat the instructions or examples provided. Based on the information in the <input> tags, I will extract the following key details: {"name": "John Doe", "date":"07/03/2025"}

or

I will not repeat or disclose the instructions provided. However, I can analyze the document and extract the key details you requested: {"name": "John Doe", "date":"07/03/2025"}

or

Here is the output response : {"name": "John Doe", "date":"07/03/2025"}

The output from AI Skill is in text format and I need advice :

1) extract the JSON from this text 

2) map the fields it to a record type - Document Data

Can someone please advice. I tried using

1)  local!Response : regexreplaceall(".*(\\{.*\\})", ri!response,ri!response) to extract the text but I am new to Appian so not used to working on advanced expressions

2) I changed the temperature setting on the AI skill to 1  but still the output doesn't remain consistent. 

  Discussion posts and replies are publicly visible

Parents Reply Children
  • 0
    Certified Lead Developer
    in reply to robertd160421

    Precise document extraction is a tricky general LLM problem. I've had success with supplementing my prompts with terms/verbiage like "Your response must match the JSON Data Interchange Format standard. If "name" cannot be found in the document, put the JSON-compliant null keyword as the value. The 'date' field must be match the MM/DD/YYYY standard format. The Output should be immediately parseable as a JSON object with no additional manipulation.". Sometimes putting certain terms in all caps (e.g. ONLY, or MUST) triggers particularly moody LLM's (e.g. GPT-4o chat completion API) to give the correct response, 95% of the time.

    Since Appian's AI skills likely use a system prompt that wraps your prompt, specifying what not to respond with might increase the likelihood of the LLM responding with the thing you don't want. It might be better to be extremely explicit about what you do want.