runCommand() - passing several variables

Based on Michael Becker’s demo of 4 March I got a Tinderbox/ChatGPT integration to work. (Thanks Michael!) This was a really useful exercise for me because in working through this I learned a lot about TB. For example, I hadn’t used runCommand() before.

I have a question about generalising the approach.

The integration works by calling a function, the key line of which is

vResponse=runCommand($Text(CodeNote),$Text(iID));

The runCommand invokes a python script (via CodeNote), and passes the text of the specified note to sys.stdin.readlines() to serve as a prompt for chatGPT. Of course, we can then work with vResponse.

The python script hardcodes a couple of GPT parameters (temperature and top_p). These parameters influence the text that the model generates. It would be nice to play with these two parameters within TB and pass them, along with the prompt text, to the python script.

Anyone know how best to do this within TB? (I’m at the limit of my knowledge of runCommand…)

1 Like

Take a look at runCommand(commandStr[, inputsStr, dirStr]). You can either try and pass the whole command an arguments as one string (difficult if embedded quote characters are needed). Or pass the argument using the second form with an inputsStr argument. I believe that is the form you are using in your example:

vResponse=runCommand($Text(CodeNote),$Text(iID));

It sounds as though you’ve values hardcoded in the commandStr that want to be stored separately in Tinderbox and passed as part of the existing inputsStr argument.

That’s the theory. I’ll let one of those here with more command line experience to delve deeper if needed. I might help is you posted an actual command line, as it is received by the OS command line and annotate which bits you want to no longer hard code.

Thanks Mark. Exactly what I needed. One should always look at the documentation!

I can now pass the various elements (prompt text, temperature, p_top) from a note; get python to send the various parameters to ChatGPT, then write to another note. Nice.

Thanks again.

2 Likes