Mappable parameter array to communication body formatting

I’m trying to format a body message output using an array which may have multiple values of an internal collection but I can’t get it to format correctly to iterate through the array.

Communication:
{

“url”: “/chat/completions”,

“method”: “POST”,

“body”: {

"iterate": {

"messages": 

    [

  {

    "role": "{{parameters.messages.role}}",

    "content": "{{parameters.messages.prompt}}"

  }

]

},

"model": "{{parameters.model}}",

"temperature": "{{parameters.temperature}}",

"max_tokens": "{{parameters.max_tokens}}",

"top_p": "{{parameters.top_p}}",

"stop": "{{parameters.stop}}"

}

}

Parameters:
[

{

	"name": "messages",

	"spec": [

		{

			"name": "role",

			"type": "select",

			"label": "Role",

			"options": [

				{

					"label": "System",

					"value": "system"

				},

				{

					"label": "User",

					"value": "user"

				},

				{

					"label": "Assistant",

					"value": "assistant"

				}

			],

			"required": true

		}, {



			"name": "prompt",

			"type": "text",

			"label": "Prompt",

			"multiline": true,

			"required": true



		}



	],

	"type": "array",

	"label": "Messages"

},

{

	"name": "model",

	"type": "select",

	"label": "Model",

	"options": [

		{

			"label": "Mixtral",

			"value": "mixtral-8x7b-32768"

		},

		{

			"label": "Llama 2",

			"value": "llama2-70b-4096"

		}

	],

	"default": "mixtral-8x7b-32768",

	"required": true

},

{

	"name": "temperature",

	"type": "number",

	"label": "Temperature",

	"help": "Valid Values: 0 - 2; Randomness increases with value.",

	"validate": { "min": 0, "max": 2 },

	"advanced": true,

	"required": false

},

{

	"name": "max_tokens",

	"type": "integer",

	"label": "Max Tokens",

	"default": "4096",

	"validate": { "min": 0, "max": 32768 },

	"help": "Requests can use up to tokens shared between prompt and completion. Limits: 32768 for Mixtral, 4096 for LLama2.",

	"advanced": true,

	"required": false

},

{

	"name": "top_p",

	"type": "number",

	"label": "Top P",

	"validate": { "min": 0, "max": 1 },

	"help": "Valid Values: 0 to 1, Controls diversity via nucleus sampling: 0.5 means half of all likelihood-weighted options are considered.",

	"advanced": true,

	"required": false

},

{

	"name": "stop",

	"type": "text",

	"label": "Stop Sequence",

	"help": "text string to tell AI to stop generating content such as punctuation marks or markers like [end].",

	"advanced": true,

	"required": false

}

]

You may want to include the blueprint of an example scenario for us to look at. It looks like you also have some formatting issue with the JSON you added here…

Is your end goal to iterate through the responses and do something with the contents?

Aggregate to JSON might be what you’re looking for
image

2 Likes

I was able to figure it out:

“body”: {
“messages”: {
“iterate”: “{{parameters.messages}}”,
“message”: {
“role”: “{{item.role}}”,
“content”: “{{item.prompt}}”
}
},

1 Like

well I thought I had, it seems to be generating correctly but I no longer get a response from the API it complains of a problem with my collection, 400 error