Configure Message Appender
This example pipeline demonstrates how to merge document streams into a single output stream using the Message Appender Snap.
-
Add three JSON Generator Snaps to the Designer
Canvas.
-
JSON Generator 1 (Tool Calling Result): Configure the Snap with the following JSON
data:
The Tool Calling Result (representing the tool call response from LLM) creates a sample JSON object representing the output of a tool call. This could be any external tool or API, such as fetching weather data or performing some calculations.[ { "output": { "message": { "role": "assistant", "content": [ { "text": "Based on the information from the get_weather tool, here are the current weather details for San Francisco, CA:\n\n- Temperature: 63°F/17.2°C\n- Condition: Partly cloudy\n- Wind: 6.1 kph/3.8 mph from the West \n- Humidity: 75%\n- Feels like: 63°F/17.2°C\n\nLet me invoke the get_wiki tool to get the Wikipedia link for San Francisco:" }, { "toolUse": { "toolUseId": "tooluse_4iRMIVi-SR2C5hf-qQUYDw", "toolName": "get_wiki", "input": { "city": "San Francisco, CA" } } } ] } }, "stopReason": "tool_use", "usage": { "inputTokens": 847, "outputTokens": 166, "totalTokens": 1013 }, "metrics": { "latencyMs": 3766 }, "messages": [ { "content": "You are a friendly helpful assistant\n - You should only use the functions you have been provided with to answer enquiries.\n - If you're unsure of an answer, you can say 'Sorry, I don't have the information right now'.\n - Some of the functions has dependencies on other functions, so make sure to execute them in the correct order.", "sl_role": "ASSISTANT" }, { "content": "You are a friendly and helpful assistant that are equipped with some tools, please use your judge to decide whether to use the tools or not to answer questions from the user.\nQuestion: What's the weather and wiki link of San Francisco?", "sl_role": "USER" }, { "role": "assistant", "content": [ { "text": "Okay, let me try to get the weather and wiki link for San Francisco using the available tools." }, { "toolUse": { "toolUseId": "tooluse_608_fL1YR4e3glq-FkmShw", "toolName": "get_weather", "input": { "city": "San Francisco, CA" } } } ] }, { "role": "user", "content": { "toolResult": { "content": [ [ { "last_updated_epoch": 1726072200, "last_updated": "2024-09-11 09:30", "temp_c": 17.2, "temp_f": 63, "is_day": 1, "condition": { "text": "Partly cloudy", "icon": "//cdn.weatherapi.com/weather/64x64/day/116.png", "code": 1003 }, "wind_mph": 3.8, "wind_kph": 6.1, "wind_degree": 270, "wind_dir": "W", "pressure_mb": 1012, "pressure_in": 29.88, "precip_mm": 0, "precip_in": 0, "humidity": 75, "cloud": 25, "feelslike_c": 17.2, "feelslike_f": 63, "windchill_c": 14.7, "windchill_f": 58.5, "heatindex_c": 15.1, "heatindex_f": 59.2, "dewpoint_c": 11.3, "dewpoint_f": 52.3, "vis_km": 16, "vis_miles": 9, "uv": 4, "gust_mph": 10.6, "gust_kph": 17.1 } ] ], "toolUseId": "tooluse_sA4hBZ_lQd6Oowo-Dxbaxw" } } }, { "role": "assistant", "content": [ { "text": "Based on the information from the get_weather tool, here are the current weather details for San Francisco, CA:\n\n- Temperature: 63°F/17.2°C\n- Condition: Partly cloudy\n- Wind: 6.1 kph/3.8 mph from the West \n- Humidity: 75%\n- Feels like: 63°F/17.2°C\n\nLet me invoke the get_wiki tool to get the Wikipedia link for San Francisco:" }, { "toolUse": { "toolUseId": "tooluse_4iRMIVi-SR2C5hf-qQUYDw", "toolName": "get_wiki", "input": { "city": "San Francisco, CA" } } } ] } ] } ]
-
JSON Generator 2 (Function Result Generator1): This Snap represents the result of a
tool usage by a user within an AI or chatbot framework. It communicates the result of
a tool's operation back to the AI assistant. The "
get_wiki
" tool, is used to fetch the Wikipedia link for "San Francisco, CA.
" The assistant can then use this result to respond to the user or to proceed with further actions based on this information. -
JSON Generator 3 (Function Result Generator2): This Snap simulates the responses
from other functions or components. These could represent additional pieces of data
that need to be aggregated along with the tool response.This Snap provides the
assistant with the result of a previously invoked tool (the
"
get_wiki
" tool). The assistant can use this information to construct a response for the user or to proceed with further actions based on this tool's output. It conveys the outcome of a tool's operation back to the AI assistant.
-
JSON Generator 1 (Tool Calling Result): Configure the Snap with the following JSON
data:
-
Configure the Message Appender Snap to
append the function results (represented by JSON Generator 2 and JSON Generator 3) to the
messages list of the LLM base response (represented by JSON Generator 1)
On validation, the Snap appends the messages using themessages
into a single JSON object as a unified result.This pipeline is useful in scenarios where responses from multiple tools or services need to be consolidated into a single output for downstream use.
- Download and import the pipeline into the SnapLogic Platform.
- Configure Snap accounts, as applicable.
- Provide pipeline parameters, as applicable.