OpenAi API call - How to show only a part of generated text?

Hi!

I have set up a simple API call for OpenAI where I generate a text with a prompt.

It’s easy to display the result of the prompt as a text in a Text Field but how can I restrict this text to a certain number of characters? (for example half of the “completion_tokens”)

API text:truncated to (# characters)

1 Like

Thanks a lot! Is there a way to make this number dynamic?

I would like to take a “completion_tokens” form JSON file and make it in half:

I’m trying to set a state for a number of completion_tokens but the expression turned RED. Any idea how to make it work?

image

Result of Step 2’s choices:first item’s message content:truncated to (Result of step 2’s usage completion tokens / 2)

@georgecollier Thanks for the help!