nip.utils.data.prompt_array_to_list#
- nip.utils.data.prompt_array_to_list(prompt_array: Annotated[ndarray[Any, dtype[_ScalarType_co]], 'message field']) list[PromptMessage] [source]#
Convert a prompt in the form of a numpy array to a list of dictionaries.
Each row of the numpy array corresponds to a message in the prompt, and each column corresponds to a field of the message.
The prompt array has a fixed number of rows, but the prompt may be shorter. If any required field is None in a row, we take that to indicate the end of the prompt.
- Parameters:
prompt_array (String[NDArray, "message field"]) – The numpy array to convert.
- Returns:
prompt_list (list[PromptMessage]) – The list of prompts.