Track Time in GPT with Code Interpreter

creating a "loading bar"!

Track Time in GPT with Code Interpreter
0:00
/0:28

GPT can track time, it turns out. With some help from code interpreter.

Using a one-shot (instructions below), you can chain real time with time.sleep to your custom GPT/assistant functionality with no external servers needed.

Each ping comes in after 3 seconds (+ small amount of time for GPT to load in the interpreter).

Instructions

on start;

1) use code interpreter to run a timer for three seconds
2) after the three seconds are up, finish the code interpreter and print ping {counter}
3) run it 3 times

ex:

start
code_interpreter()
assistant: ping 1!
code_interpreter()
assistant: ping 2!
...

We are basically invoking multiple required_action states in the same run, and leaving a very clear exit point to return the "thread" to the assistant. We then spin up another instance passing in the state from the previous interpreter, and we have a one shot, one user message "clock"!

Addendum

I'm collecting a new set of UX patterns enabled by GPTs. You can check it out below:

GPT UX Patterns
New UX patterns are being discovered every day!

Here is how I'm using this pattern in one of my production GPTs

# Loading Bar Instructions

These are the instructions to break up a long running task.

1) use code interpreter to run a timer for ten seconds and start work on LONG TASK below, but first set up a ruler timer that breaks after the five seconds are up. Timer takes priority. This means write time.sleep functionality FIRST and keep it IN SCOPE
2) after the ten seconds are up, STOP the code interpreter and BREAK to print the gif below to keep user engaged
3) IMMEDIATELY START A NEW code interpreter where you left off in the next code interpeter until LONG TASK below is complete
4) Once done, pass thread over to LONG TASK and continue instructions as according to LONG TASK

ex of two loading gifs surfacing, but remember, you can load in as many as are needed, if task takes 20 second thats 2 gifs, if it takes 30 seconds, thats 3 gifs, etc.:

start
code_interpreter() # starts writing LONG TASK code and breaks after 10 seconds
assistant: "![bear dancing](https://media.giphy.com/media/v1.Y2lkPTc5MGI3NjExZzJwaDNjZHNsNWthNjFhNno4djFsdHVjcngxc2F4MzhudW1jMWoxMSZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/tsX3YMWYzDPjAARfeg/giphy.gif)"
code_interpreter() # PICK UP WRITING LONG TASK code and breaks after 10 seconds
assistant: "![bear dancing](https://media.giphy.com/media/v1.Y2lkPTc5MGI3NjExZzJwaDNjZHNsNWthNjFhNno4djFsdHVjcngxc2F4MzhudW1jMWoxMSZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/tsX3YMWYzDPjAARfeg/giphy.gif)"
...DO THIS AS MANY TIMES AS NECESSARY UNTIL LONG TASK COMPLETES...(if task takes 20 second thats 2 gifs, if it takes 30 seconds, thats 3 gifs, etc.)

# End Loading Bar Instructions

# LONG TASK

30sec+ code interpreter task here...