How is your experience with the OutSystems Community?
11
Views
3
Comments
Solved
How to Parse the text and join (LLM output) ?
Question

Hi There, 

I need to convert  LLM output to full sentences .  the format below , how can I parse ?

Many Thanks,

Jack

___________________________________

data:{"id":"20260826212233d21d32ac80d84db2","created":1787750553,"object":"chat.completion.chunk","model":"glm-5.2","choices":[{"index":0,"delta":{"role":"assistant","reasoning_content":"用户"}}]} 

data: {"id":"20260826212233d21d32ac80d84db2","created":1787750553,"object":"chat.completion.chunk","model":"glm-5.2","choices":[{"index":0,"delta":{"role":"assistant","reasoning_content":"的需求"}}]} 

data: {"id":"20260826212233d21d32ac80d84db2","created":1787750553,"object":"chat.completion.chunk","model":"glm-5.2","choices":[{"index":0,"delta":{"role":"assistant","reasoning_content":"是作为一个"}}]} 

data: {"id":"20260826212233d21d32ac80d84db2","created":1787750553,"object":"chat.completion.chunk","model":"glm-5.2","choices":[{"index":0,"delta":{"role":"assistant","reasoning_content":"项目文档审核专家,根据"}}]} 

data: {"id":"20260826212233d21d32ac80d84db2","created":1787750553,"object":"chat.completion.chunk","model":"glm-5.2","choices":[{"index":0,"delta":{"role":"assistant","reasoning_content":"提供的审核规则清单对"}}]} 

data: {"id":"20260826212233d21d32ac80d84db2","created":1787750553,"object":"chat.completion.chunk","model":"glm-5.2","choices":[{"index":0,"delta":{"role":"assistant","reasoning_content":"给定的Markdown格式文档进行审核"}}]} 

2026-01-28 16-57-48
Mihai Melencu
Champion
Solution

Hi @Jack Bao ,

I assume you use an API for this and not an agentic implementation in ODC.

You could split the response into separate lines, remove the data: prefix, deserialize each JSON object, and then transform the extracted values into the format you need.

However, these appear to be streaming response chunks. Are you sure you need to process the streamed messages individually? It would also be helpful to know exactly what information you want to extract from the response.

2026-06-20 17-43-43
Sherif El-Habibi
Champion

Hi @Jack Bao,

If you are talking about ODC, you can use Agent Workbench to achieve this. Basically, the data you provide can be used as grounding data, similar to a RAG-based approach, depending on how you configure your agent.

The flow generally works like this:

  1. Configure the grounding data
    Inside your ODC Agent App, you can configure the GetGroundingData action to retrieve the relevant information that will be used to ground the agent's response.
  2. Build the messages
    Inside the BuildMessages action, you can use the retrieved grounding data as part of the system prompt. This allows you to define the agent's persona, behavior, instructions, and the context it should use when responding to the user.
  3. Handle the user input
    The user's input is then included in the messages sent to the agent, together with the system instructions and grounding context.
  4. Configure the agent's response
    You can handle the response in two different ways:
    • Using a Structure: Define a structure and provide detailed descriptions for each attribute. The agent can then generate the response according to that structure and map the values accordingly.
    • Using an Action: You can use an action to process or extract the agent's response as text and handle it according to your required logic.

You can also check these resources for more details:


2026-01-28 16-57-48
Mihai Melencu
Champion
Solution

Hi @Jack Bao ,

I assume you use an API for this and not an agentic implementation in ODC.

You could split the response into separate lines, remove the data: prefix, deserialize each JSON object, and then transform the extracted values into the format you need.

However, these appear to be streaming response chunks. Are you sure you need to process the streamed messages individually? It would also be helpful to know exactly what information you want to extract from the response.

2021-01-01 09-23-30
Michael de Guzman
Champion

Hi @Jack Bao ,


Another approach is to use the LLM to do the heavy lifting fo you.


You can just take that entire raw text block and pass it into another LLM action.  Just give it a simple system prompt like "Extract the reasoning content from this raw data stream and output it as a single, readable sentence."


The model will easily ignore all the JSON formatting and will spit out a clean text you need.  It is a bit of a shortcut, but it works perfectly if you just want to get straight to the final readable text.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.