How to make an HTTP Request node accept stream response?
I’m trying to use HTTP Request to query GCP Llama 3.2 API Service.
For curl request response looks like this:
ta: {"choices":[{"delta":{"content":"Once upon a time, in a small village nestled between two great mountains, there","role":"assistant"},"index":0,"logprobs":null}],"created":1727443031,"id":"2024-09-27|06:17:11.418330-07|2.65.8.115|-1089744740","model":"meta/llama3-405b-instruct-maas","object":"chat.completion.chunk","system_fingerprint":""}
data: {"choices":[{"delta":{"content":" lived a young girl named Luna. Luna was a curious and adventurous child, with","role":"assistant"},"index":0,"logprobs":null}],"created":1727443031,"id":"2024-09-27|06:17:11.418330-07|2.65.8.115|-1089744740","model":"meta/llama3-405b-instruct-maas","object":"chat.completion.chunk","system_fingerprint":""}
....
Many strings here
....
data: {"choices":[{"delta":{"content":" and determination was passed down through generations, inspiring others to protect and preserve the beauty","role":"assistant"},"index":0,"logprobs":null}],"created":1727443031,"id":"2024-09-27|06:17:11.418330-07|2.65.8.115|-1089744740","model":"meta/llama3-405b-instruct-maas","object":"chat.completion.chunk","system_fingerprint":""}
data: {"choices":[{"delta":{"content":" and magic of the world around them.","role":"assistant"},"index":0,"logprobs":null}],"created":1727443031,"id":"2024-09-27|06:17:11.418330-07|2.65.8.115|-1089744740","model":"meta/llama3-405b-instruct-maas","object":"chat.completion.chunk","system_fingerprint":""}
data: {"choices":[{"delta":{"content":"","role":"assistant"},"finish_reason":"stop","index":0,"logprobs":null}],"created":1727443031,"id":"2024-09-27|06:17:11.418330-07|2.65.8.115|-1089744740","model":"meta/llama3-405b-instruct-maas","object":"chat.completion.chunk","system_fingerprint":"","usage":{"completion_tokens":704,"prompt_tokens":4,"total_tokens":708}}
data: [DONE]
How to make the HTTP request wait for the end of response? data: [DONE]
workflow
Share the output returned by the last node
[
{
"data": "data: {\"choices\":[{\"delta\":{\"content\":\"Once upon a time, in a small village nestled in the rolling hills of T\",\"role\":\"assistant\"},\"index\":0,\"logprobs\":null}],\"created\":1727443528,\"id\":\"2024-09-27|06:25:28.175470-07|7.229.140.102|1361085055\",\"model\":\"meta/llama-3.2-90b-vision-instruct-maas\",\"object\":\"chat.completion.chunk\",\"system_fingerprint\":\"\"}\n\ndata: {\"choices\":[{\"delta\":{\"content\":\"uscany, there was a tiny shop called \\\"Mirabel's Marvels.\\\"\",\"role\":\"assistant\"},\"index\":0,\"logprobs\":null}],\"created\":1727443528,\"id\":\"2024-09-27|06:25:28.175470-07|7.229.140.102|1361085055\",\"model\":\"meta/llama-3.2-90b-vision-instruct-maas\",\"object\":\"chat.completion.chunk\",\"system_fingerprint\":\"\"}\n\ndata: {\"choices\":[{\"delta\":{\"content\":\" The shop was run by a kind-hearted\",\"role\":\"assistant\"},\"finish_reason\":\"length\",\"index\":0,\"logprobs\":null}],\"created\":1727443528,\"id\":\"2024-09-27|06:25:28.175470-07|7.229.140.102|1361085055\",\"model\":\"meta/llama-3.2-90b-vision-instruct-maas\",\"object\":\"chat.completion.chunk\",\"system_fingerprint\":\"\",\"usage\":{\"completion_tokens\":41,\"prompt_tokens\":4,\"total_tokens\":45}}\n\ndata: [DONE]\n\n"
}
]
Information on your n8n setup
- n8n version: 1.60.1
- Database: postgres
- n8n EXECUTIONS_PROCESS setting: regular
- Running n8n via (k8s):
- Operating system: n/a