Wished I found this before I spend time looking for the problem. I noticed the difference between the javascript and the python example.
@guptaa.pavan did a wonderful job providing the working code for the complete example, Here is a summarization of what was wrong.
So, what missing is, after line 37, to add the models output to the chat history:
input.push(…response.output);
Also, at line 46 of the example at the doc input_list must be changed to
input
And finally the function name at line 23 should be
get_horoscope